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.commons.lang3.StringUtils; | |
25 | import org.apache.logging.log4j.LogManager; | |
26 | import org.apache.logging.log4j.Logger; | |
27 | ||
28 | public class StrategyMultibit extends AbstractStrategy { | |
29 | ||
30 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
31 | ||
32 | private InjectionMultibit injection; | |
33 | ||
34 | public StrategyMultibit(InjectionModel injectionModel) { | |
35 | super(injectionModel); | |
36 | } | |
37 | ||
38 | @Override | |
39 | public void checkApplicability() throws StoppedByUserSlidingException { | |
40 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyMultibitDisabled()) { |
41 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName()); | |
42 | return; | |
43 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
} else if (StringUtils.isEmpty( |
44 | this.injectionModel.getMediatorVendor().getVendor().instance().getModelYaml().getStrategy().getBinary().getMultibit() | |
45 | )) { | |
46 | LOGGER.log( | |
47 | LogLevelUtil.CONSOLE_INFORM, | |
48 | AbstractStrategy.FORMAT_STRATEGY_NOT_IMPLEMENTED, | |
49 | this.getName(), | |
50 | this.injectionModel.getMediatorVendor().getVendor() | |
51 | ); | |
52 | return; | |
53 | } | |
54 | ||
55 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::checkInjection → NO_COVERAGE |
this.checkInjection(BlindOperator.NO_MODE); |
56 | ||
57 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
58 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::allow → NO_COVERAGE |
this.allow(); |
59 | var requestMessageBinary = new Request(); | |
60 |
1
1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE |
requestMessageBinary.setMessage(Interaction.MESSAGE_BINARY); |
61 |
1
1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE |
requestMessageBinary.setParameters(this.injection.getInfoMessage()); |
62 |
1
1. checkApplicability : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE |
this.injectionModel.sendToViews(requestMessageBinary); |
63 | } else { | |
64 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyMultibit::unallow → NO_COVERAGE |
this.unallow(); |
65 | } | |
66 | } | |
67 | ||
68 | private void checkInjection(BlindOperator blindOperator) throws StoppedByUserSlidingException { | |
69 |
1
1. checkInjection : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
70 | return; | |
71 | } | |
72 |
1
1. checkInjection : removed call to com/jsql/model/injection/strategy/StrategyMultibit::logChecking → NO_COVERAGE |
this.logChecking(); |
73 | this.injection = new InjectionMultibit(this.injectionModel, blindOperator); | |
74 | this.isApplicable = this.injection.isInjectable(); | |
75 |
1
1. checkInjection : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
76 | LOGGER.log( | |
77 | LogLevelUtil.CONSOLE_SUCCESS, | |
78 | "{} Multibit injection", | |
79 |
1
1. lambda$checkInjection$0 : replaced return value with null for com/jsql/model/injection/strategy/StrategyMultibit::lambda$checkInjection$0 → NO_COVERAGE |
() -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_VULNERABLE) |
80 | ); | |
81 | } | |
82 | } | |
83 | ||
84 | @Override | |
85 | public void allow(int... i) { | |
86 |
1
1. allow : removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE |
this.injectionModel.appendAnalysisReport( |
87 | StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName()) | |
88 | + this.injectionModel.getReportWithoutIndex( | |
89 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlMultibit( | |
90 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind( | |
91 | StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "<query>"), | |
92 | "0", | |
93 | true | |
94 | ), | |
95 | 0, | |
96 | 1 | |
97 | ), | |
98 | "metadataInjectionProcess", | |
99 | null | |
100 | ) | |
101 | ); | |
102 |
1
1. allow : removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE |
this.markVulnerability(Interaction.MARK_MULTIBIT_VULNERABLE); |
103 | } | |
104 | ||
105 | @Override | |
106 | public void unallow(int... i) { | |
107 |
1
1. unallow : removed call to com/jsql/model/injection/strategy/StrategyMultibit::markVulnerability → NO_COVERAGE |
this.markVulnerability(Interaction.MARK_MULTIBIT_INVULNERABLE); |
108 | } | |
109 | ||
110 | @Override | |
111 | public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) throws StoppedByUserSlidingException { | |
112 |
1
1. inject : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::inject → NO_COVERAGE |
return this.injection.inject( |
113 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(sqlQuery, startPosition, false), | |
114 | stoppable | |
115 | ); | |
116 | } | |
117 | ||
118 | @Override | |
119 | public void activateWhenApplicable() { | |
120 |
2
1. activateWhenApplicable : negated conditional → NO_COVERAGE 2. activateWhenApplicable : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorStrategy().getStrategy() == null && this.isApplicable()) { |
121 | LOGGER.log( | |
122 | LogLevelUtil.CONSOLE_INFORM, | |
123 | "{} [{}]", | |
124 |
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"), |
125 | this::getName | |
126 | ); | |
127 |
1
1. activateWhenApplicable : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE |
this.injectionModel.getMediatorStrategy().setStrategy(this); |
128 | ||
129 | var request = new Request(); | |
130 |
1
1. activateWhenApplicable : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE |
request.setMessage(Interaction.MARK_MULTIBIT_STRATEGY); |
131 |
1
1. activateWhenApplicable : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE |
this.injectionModel.sendToViews(request); |
132 | } | |
133 | } | |
134 | | |
135 | @Override | |
136 | public String getPerformanceLength() { | |
137 |
1
1. getPerformanceLength : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getPerformanceLength → NO_COVERAGE |
return VendorYaml.DEFAULT_CAPACITY; |
138 | } | |
139 | | |
140 | @Override | |
141 | public String getName() { | |
142 |
1
1. getName : replaced return value with "" for com/jsql/model/injection/strategy/StrategyMultibit::getName → NO_COVERAGE |
return "Multibit"; |
143 | } | |
144 | } | |
Mutations | ||
40 |
1.1 |
|
43 |
1.1 |
|
55 |
1.1 |
|
57 |
1.1 |
|
58 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
64 |
1.1 |
|
69 |
1.1 |
|
72 |
1.1 |
|
75 |
1.1 |
|
79 |
1.1 |
|
86 |
1.1 |
|
102 |
1.1 |
|
107 |
1.1 |
|
112 |
1.1 |
|
120 |
1.1 2.2 |
|
124 |
1.1 |
|
127 |
1.1 |
|
130 |
1.1 |
|
131 |
1.1 |
|
137 |
1.1 |
|
142 |
1.1 |