StrategyMultibit.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2025.
3
 * This program and the accompanying materials
4
 * are made available under no term at all, use it like
5
 * you want, but share and discuss it
6
 * every time possible with every body.
7
 *
8
 * Contributors:
9
 *      ron190 at ymail dot com - initial implementation
10
 *******************************************************************************/
11
package com.jsql.model.injection.strategy;
12
13
import com.jsql.model.InjectionModel;
14
import com.jsql.model.bean.util.Interaction;
15
import com.jsql.model.bean.util.Request;
16
import com.jsql.model.exception.StoppedByUserSlidingException;
17
import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator;
18
import com.jsql.model.injection.strategy.blind.InjectionMultibit;
19
import com.jsql.model.injection.vendor.model.VendorYaml;
20
import com.jsql.model.suspendable.AbstractSuspendable;
21
import com.jsql.util.I18nUtil;
22
import com.jsql.util.LogLevelUtil;
23
import com.jsql.util.StringUtil;
24
import org.apache.logging.log4j.LogManager;
25
import org.apache.logging.log4j.Logger;
26
27
public class StrategyMultibit extends AbstractStrategy {
28
29
    /**
30
     * Log4j logger sent to view.
31
     */
32
    private static final Logger LOGGER = LogManager.getRootLogger();
33
34
    private InjectionMultibit injectionMultibit;
35
36
    public StrategyMultibit(InjectionModel injectionModel) {
37
        super(injectionModel);
38
    }
39
40
    @Override
41
    public void checkApplicability() throws StoppedByUserSlidingException {
42 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyMultibitDisabled()) {
43
            LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName());
44
            return;
45
        }
46 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::logChecking → NO_COVERAGE
        this.logChecking();
47
48
        this.injectionMultibit = new InjectionMultibit(this.injectionModel, BlindOperator.STACK);
49
        this.isApplicable = this.injectionMultibit.isInjectable();
50
51 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
52
            LOGGER.log(LogLevelUtil.CONSOLE_SUCCESS, "{} Multibit injection", () -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_VULNERABLE));
53 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::allow → NO_COVERAGE
            this.allow();
54
55
            var requestMessageBinary = new Request();
56 1 1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
            requestMessageBinary.setMessage(Interaction.MESSAGE_BINARY);
57 1 1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE
            requestMessageBinary.setParameters(this.injectionMultibit.getInfoMessage());
58 1 1. checkApplicability : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(requestMessageBinary);
59
        } else {
60 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::unallow → NO_COVERAGE
            this.unallow();
61
        }
62
    }
63
64
    @Override
65
    public void allow(int... i) {
66 1 1. allow : removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE
        this.injectionModel.appendAnalysisReport(
67
            StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName())
68
            + this.injectionModel.getReportWithoutIndex(
69
                    this.injectionModel.getMediatorVendor().getVendor().instance().sqlMultibit(
70
                    this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(
71
                        StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "<query>"),
72
                        "0",
73
                        true
74
                    ),
75
                    0,
76
                    1
77
                ),
78
                "metadataInjectionProcess",
79
                null
80
            )
81
        );
82 1 1. allow : removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE
        this.markVulnerability(Interaction.MARK_MULTIBIT_VULNERABLE);
83
    }
84
85
    @Override
86
    public void unallow(int... i) {
87 1 1. unallow : removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE
        this.markVulnerability(Interaction.MARK_MULTIBIT_INVULNERABLE);
88
    }
89
90
    @Override
91
    public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) throws StoppedByUserSlidingException {
92 1 1. inject : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::inject → NO_COVERAGE
        return this.injectionMultibit.inject(
93
            this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(sqlQuery, startPosition, false),
94
            stoppable
95
        );
96
    }
97
98
    @Override
99
    public void activateWhenApplicable() {
100 2 1. activateWhenApplicable : negated conditional → NO_COVERAGE
2. activateWhenApplicable : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorStrategy().getStrategy() == null && this.isApplicable()) {
101
            LOGGER.log(
102
                LogLevelUtil.CONSOLE_INFORM,
103
                "{} [{}]",
104 1 1. lambda$activateWhenApplicable$1 : replaced return value with null for com/jsql/model/injection/strategy/StrategyMultibit::lambda$activateWhenApplicable$1 → NO_COVERAGE
                () -> I18nUtil.valueByKey("LOG_USING_STRATEGY"),
105
                this::getName
106
            );
107 1 1. activateWhenApplicable : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE
            this.injectionModel.getMediatorStrategy().setStrategy(this);
108
109
            var requestMarkMultibitStrategy = new Request();
110 1 1. activateWhenApplicable : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
            requestMarkMultibitStrategy.setMessage(Interaction.MARK_MULTIBIT_STRATEGY);
111 1 1. activateWhenApplicable : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(requestMarkMultibitStrategy);
112
        }
113
    }
114
    
115
    @Override
116
    public String getPerformanceLength() {
117 1 1. getPerformanceLength : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getPerformanceLength → NO_COVERAGE
        return VendorYaml.DEFAULT_CAPACITY;
118
    }
119
    
120
    @Override
121
    public String getName() {
122 1 1. getName : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getName → NO_COVERAGE
        return "Multibit";
123
    }
124
}

Mutations

42

1.1
Location : checkApplicability
Killed by : none
negated conditional → NO_COVERAGE

46

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyMultibit::logChecking → NO_COVERAGE

51

1.1
Location : checkApplicability
Killed by : none
negated conditional → NO_COVERAGE

53

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyMultibit::allow → NO_COVERAGE

56

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

57

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE

58

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

60

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyMultibit::unallow → NO_COVERAGE

66

1.1
Location : allow
Killed by : none
removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE

82

1.1
Location : allow
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE

87

1.1
Location : unallow
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE

92

1.1
Location : inject
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::inject → NO_COVERAGE

100

1.1
Location : activateWhenApplicable
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : activateWhenApplicable
Killed by : none
negated conditional → NO_COVERAGE

104

1.1
Location : lambda$activateWhenApplicable$1
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyMultibit::lambda$activateWhenApplicable$1 → NO_COVERAGE

107

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE

110

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

111

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

117

1.1
Location : getPerformanceLength
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getPerformanceLength → NO_COVERAGE

122

1.1
Location : getName
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getName → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1