StrategyBlindBin.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.view.subscriber.Seal;
15
import com.jsql.model.exception.StoppedByUserSlidingException;
16
import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator;
17
import com.jsql.model.injection.strategy.blind.InjectionBlindBin;
18
import com.jsql.model.injection.engine.model.EngineYaml;
19
import com.jsql.model.suspendable.AbstractSuspendable;
20
import com.jsql.util.I18nUtil;
21
import com.jsql.util.LogLevelUtil;
22
import com.jsql.util.StringUtil;
23
import org.apache.commons.lang3.StringUtils;
24
import org.apache.logging.log4j.LogManager;
25
import org.apache.logging.log4j.Logger;
26
27
public class StrategyBlindBin extends AbstractStrategy {
28
29
    private static final Logger LOGGER = LogManager.getRootLogger();
30
31
    private InjectionBlindBin injection;
32
33
    public StrategyBlindBin(InjectionModel injectionModel) {
34
        super(injectionModel);
35
    }
36
37
    @Override
38
    public void checkApplicability() throws StoppedByUserSlidingException {
39 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().preferencesUtil().isStrategyBlindBinDisabled()) {
40
            LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName());
41
            return;
42 1 1. checkApplicability : negated conditional → NO_COVERAGE
        } else if (StringUtils.isEmpty(
43
            this.injectionModel.getMediatorEngine().getEngine().instance().getModelYaml().getStrategy().getBinary().getTest().getBin()
44
        )) {
45
            LOGGER.log(
46
                LogLevelUtil.CONSOLE_INFORM,
47
                AbstractStrategy.FORMAT_STRATEGY_NOT_IMPLEMENTED,
48
                this.getName(),
49
                this.injectionModel.getMediatorEngine().getEngine()
50
            );
51
            return;
52
        }
53
54 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.OR);
55 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.AND);
56 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.STACK);
57 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.NO_MODE);
58
59 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
60 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::allow → NO_COVERAGE
            this.allow();
61 1 1. checkApplicability : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(new Seal.MessageBinary(this.injection.getInfoMessage()));
62
        } else {
63 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::unallow → NO_COVERAGE
            this.unallow();
64
        }
65
    }
66
67
    private void checkInjection(BlindOperator blindOperator) throws StoppedByUserSlidingException {
68 1 1. checkInjection : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
69
            return;
70
        }
71
        LOGGER.log(
72
            LogLevelUtil.CONSOLE_DEFAULT,
73
            "{} [{}] with [{}]...",
74 1 1. lambda$checkInjection$0 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$0 → NO_COVERAGE
            () -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_CHECKING_STRATEGY),
75
            this::getName,
76 1 1. lambda$checkInjection$1 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$1 → NO_COVERAGE
            () -> blindOperator
77
        );
78
        this.injection = new InjectionBlindBin(this.injectionModel, blindOperator);
79
        this.isApplicable = this.injection.isInjectable();
80 1 1. checkInjection : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
81
            LOGGER.log(
82
                LogLevelUtil.CONSOLE_SUCCESS,
83
                "{} [{}] injection with [{}]",
84 1 1. lambda$checkInjection$2 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$2 → NO_COVERAGE
                () -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_VULNERABLE),
85
                this::getName,
86 1 1. lambda$checkInjection$3 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$3 → NO_COVERAGE
                () -> blindOperator
87
            );
88
        }
89
    }
90
91
    @Override
92
    public void allow(int... i) {
93 1 1. allow : removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE
        this.injectionModel.appendAnalysisReport(
94
            StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName())
95
            + this.injectionModel.getReportWithoutIndex(
96
                this.injectionModel.getMediatorEngine().getEngine().instance().sqlTestBlindWithOperator(
97
                    this.injectionModel.getMediatorEngine().getEngine().instance().sqlBlind(StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "<query>"), "0", true),
98
                    this.injection.getBlindOperator()
99
                ),
100
                "metadataInjectionProcess",
101
                null
102
            )
103
        );
104 1 1. allow : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
        this.injectionModel.sendToViews(new Seal.MarkStrategyVulnerable(this));
105
    }
106
107
    @Override
108
    public void unallow(int... i) {
109 1 1. unallow : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
        this.injectionModel.sendToViews(new Seal.MarkStrategyInvulnerable(this));
110
    }
111
112
    @Override
113
    public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) throws StoppedByUserSlidingException {
114 1 1. inject : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::inject → NO_COVERAGE
        return this.injection.inject(
115
            this.injectionModel.getMediatorEngine().getEngine().instance().sqlBlind(sqlQuery, startPosition, false),
116
            stoppable
117
        );
118
    }
119
120
    @Override
121
    public void activateWhenApplicable() {
122 2 1. activateWhenApplicable : negated conditional → NO_COVERAGE
2. activateWhenApplicable : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorStrategy().getStrategy() == null && this.isApplicable()) {
123
            LOGGER.log(
124
                LogLevelUtil.CONSOLE_INFORM,
125
                "{} [{}] with [{}]",
126 1 1. lambda$activateWhenApplicable$4 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$4 → NO_COVERAGE
                () -> I18nUtil.valueByKey("LOG_USING_STRATEGY"),
127
                this::getName,
128 1 1. lambda$activateWhenApplicable$5 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$5 → NO_COVERAGE
                () -> this.injection.getBlindOperator().name()
129
            );
130 1 1. activateWhenApplicable : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE
            this.injectionModel.getMediatorStrategy().setStrategy(this);
131 1 1. activateWhenApplicable : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(new Seal.ActivateStrategy(this));
132
        }
133
    }
134
    
135
    @Override
136
    public String getPerformanceLength() {
137 1 1. getPerformanceLength : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getPerformanceLength → NO_COVERAGE
        return EngineYaml.DEFAULT_CAPACITY;
138
    }
139
    
140
    @Override
141
    public String getName() {
142 1 1. getName : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getName → NO_COVERAGE
        return "Blind bin";
143
    }
144
}

Mutations

39

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

42

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

54

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

55

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

56

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

57

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

59

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

60

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

61

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

63

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

68

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

74

1.1
Location : lambda$checkInjection$0
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$0 → NO_COVERAGE

76

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

80

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

84

1.1
Location : lambda$checkInjection$2
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$2 → NO_COVERAGE

86

1.1
Location : lambda$checkInjection$3
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$3 → NO_COVERAGE

93

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

104

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

109

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

114

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

122

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

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

126

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

128

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

130

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

131

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

137

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

142

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

Active mutators

Tests examined


Report generated by PIT 1.22.1