| 1 | package com.jsql.util; | |
| 2 | ||
| 3 | import com.jsql.model.InjectionModel; | |
| 4 | import com.jsql.view.subscriber.Seal; | |
| 5 | import com.jsql.model.exception.InjectionFailureException; | |
| 6 | import com.jsql.model.injection.method.AbstractMethodInjection; | |
| 7 | import org.apache.commons.lang3.StringUtils; | |
| 8 | import org.apache.logging.log4j.LogManager; | |
| 9 | import org.apache.logging.log4j.Logger; | |
| 10 | ||
| 11 | import java.net.IDN; | |
| 12 | import java.net.MalformedURLException; | |
| 13 | import java.net.URI; | |
| 14 | import java.net.URISyntaxException; | |
| 15 | import java.util.AbstractMap.SimpleEntry; | |
| 16 | import java.util.Arrays; | |
| 17 | import java.util.List; | |
| 18 | import java.util.Objects; | |
| 19 | import java.util.concurrent.CopyOnWriteArrayList; | |
| 20 | import java.util.regex.Matcher; | |
| 21 | import java.util.regex.Pattern; | |
| 22 | import java.util.stream.Collectors; | |
| 23 | ||
| 24 | public class ParameterUtil { | |
| 25 | ||
| 26 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 27 | ||
| 28 | /** | |
| 29 | * Query string built from the URL submitted by user. | |
| 30 | */ | |
| 31 | // Fix #95787: ConcurrentModificationException | |
| 32 | private List<SimpleEntry<String, String>> listQueryString = new CopyOnWriteArrayList<>(); | |
| 33 | ||
| 34 | /** | |
| 35 | * Request submitted by user. | |
| 36 | */ | |
| 37 | private List<SimpleEntry<String, String>> listRequest = new CopyOnWriteArrayList<>(); | |
| 38 | ||
| 39 | /** | |
| 40 | * Header submitted by user. | |
| 41 | */ | |
| 42 | private List<SimpleEntry<String, String>> listHeader = new CopyOnWriteArrayList<>(); | |
| 43 | ||
| 44 | private String rawRequest = StringUtils.EMPTY; | |
| 45 | private String rawHeader = StringUtils.EMPTY; | |
| 46 | private boolean isMultipartRequest = false; | |
| 47 | ||
| 48 | public static final String PREFIX_COMMAND_QUERY = "Query#"; | |
| 49 | public static final String PREFIX_COMMAND_REQUEST = "Request#"; | |
| 50 | public static final String PREFIX_COMMAND_HEADER = "Header#"; | |
| 51 | public static final String PREFIX_COMMAND_COOKIE = "Cookie#"; | |
| 52 | private static final String FORMAT_KEY_VALUE = "%s=%s"; | |
| 53 | ||
| 54 | // ABNF primitives defined in RFC 7230 | |
| 55 | private static final boolean[] TCHAR = new boolean[256]; | |
| 56 | ||
| 57 | static { | |
| 58 | char[] allowedTokenChars = ( | |
| 59 | "!#$%&'*+-.^_`|~0123456789" + | |
| 60 | "abcdefghijklmnopqrstuvwxyz" + | |
| 61 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| 62 | ).toCharArray(); | |
| 63 | for (char c : allowedTokenChars) { | |
| 64 | ParameterUtil.TCHAR[c] = true; | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | private final InjectionModel injectionModel; | |
| 69 | | |
| 70 | public ParameterUtil(InjectionModel injectionModel) { | |
| 71 | this.injectionModel = injectionModel; | |
| 72 | } | |
| 73 | | |
| 74 | /** | |
| 75 | * Send each parameter from the GUI to the model in order to | |
| 76 | * start the preparation of injection, the injection process is | |
| 77 | * started in a new thread via model function inputValidation(). | |
| 78 | */ | |
| 79 | public void controlInput( | |
| 80 | String selectionCommand, | |
| 81 | String urlQuery, | |
| 82 | String rawRequest, | |
| 83 | String rawHeader, | |
| 84 | AbstractMethodInjection methodInjection, | |
| 85 | String typeRequest, | |
| 86 | boolean isScanning | |
| 87 | ) { | |
| 88 | try { | |
| 89 | String urlQueryFixed = urlQuery; | |
| 90 | // Keep single check | |
| 91 |
1
1. controlInput : negated conditional → NO_COVERAGE |
if (urlQueryFixed.isEmpty()) { |
| 92 | throw new MalformedURLException("empty URL"); | |
| 93 |
1
1. controlInput : negated conditional → NO_COVERAGE |
} else if (!urlQueryFixed.matches("(?i)^https?://.*")) { |
| 94 |
1
1. controlInput : negated conditional → NO_COVERAGE |
if (!urlQueryFixed.matches("(?i)^\\w+://.*")) { |
| 95 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, "Undefined URL protocol, forcing to [http://]"); | |
| 96 | urlQueryFixed = "http://"+ urlQueryFixed; | |
| 97 | } else { | |
| 98 | throw new MalformedURLException("unknown URL protocol"); | |
| 99 | } | |
| 100 | } | |
| 101 | ||
| 102 | int port = URI.create(urlQueryFixed).getPort(); | |
| 103 |
2
1. controlInput : changed conditional boundary → NO_COVERAGE 2. controlInput : negated conditional → NO_COVERAGE |
if (port > 65535) { // Fix #96227: IllegalArgumentException on checkConnectionResponse() |
| 104 | throw new MalformedURLException("port must be 65535 or lower"); | |
| 105 | } | |
| 106 | String authority = URI.create(urlQueryFixed).getAuthority(); | |
| 107 |
1
1. controlInput : negated conditional → NO_COVERAGE |
if (authority == null) { |
| 108 | throw new MalformedURLException("undefined domain authority"); | |
| 109 | } | |
| 110 | String authorityPunycode = IDN.toASCII(authority); | |
| 111 |
1
1. controlInput : negated conditional → NO_COVERAGE |
if (!authority.equals(authorityPunycode)) { |
| 112 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, "Punycode domain detected, using [{}] instead of [{}]", authorityPunycode, authority); | |
| 113 | urlQueryFixed = urlQueryFixed.replace(authority, authorityPunycode); | |
| 114 | } | |
| 115 | ||
| 116 |
1
1. controlInput : removed call to com/jsql/util/ParameterUtil::initQueryString → NO_COVERAGE |
this.initQueryString(urlQueryFixed, selectionCommand); |
| 117 |
1
1. controlInput : removed call to com/jsql/util/ParameterUtil::initRequest → NO_COVERAGE |
this.initRequest(rawRequest, selectionCommand); |
| 118 |
1
1. controlInput : removed call to com/jsql/util/ParameterUtil::initHeader → NO_COVERAGE |
this.initHeader(rawHeader, selectionCommand); |
| 119 | ||
| 120 | this.injectionModel.getMediatorUtils().connectionUtil().withMethodInjection(methodInjection); | |
| 121 | this.injectionModel.getMediatorUtils().connectionUtil().withTypeRequest(typeRequest); | |
| 122 | | |
| 123 |
1
1. controlInput : negated conditional → NO_COVERAGE |
if (isScanning) { |
| 124 |
1
1. controlInput : removed call to com/jsql/model/InjectionModel::beginInjection → NO_COVERAGE |
this.injectionModel.beginInjection(); |
| 125 | } else { | |
| 126 |
1
1. controlInput : removed call to java/lang/Thread::start → NO_COVERAGE |
new Thread(this.injectionModel::beginInjection, "ThreadBeginInjection").start(); // in thread |
| 127 | } | |
| 128 | } catch (IllegalArgumentException | MalformedURLException | URISyntaxException e) { | |
| 129 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Incorrect Url: {}", e.getMessage()); | |
| 130 | | |
| 131 | // Incorrect URL, reset the start button | |
| 132 |
1
1. controlInput : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE |
this.injectionModel.sendToViews(new Seal.EndPreparation()); |
| 133 | } | |
| 134 | } | |
| 135 | ||
| 136 | /** | |
| 137 | * Check integrity of parameters defined by user. | |
| 138 | * @throws InjectionFailureException when params integrity is failure | |
| 139 | */ | |
| 140 | public void checkParametersFormat() throws InjectionFailureException { | |
| 141 |
1
1. checkParametersFormat : removed call to com/jsql/util/ParameterUtil::checkOneOrLessStar → KILLED |
this.checkOneOrLessStar(); |
| 142 |
1
1. checkParametersFormat : removed call to com/jsql/util/ParameterUtil::checkStarMatchMethod → SURVIVED |
this.checkStarMatchMethod(); |
| 143 |
1
1. checkParametersFormat : removed call to com/jsql/util/ParameterUtil::checkMethodNotEmpty → KILLED |
this.checkMethodNotEmpty(); |
| 144 |
1
1. checkParametersFormat : removed call to com/jsql/util/ParameterUtil::checkMultipart → NO_COVERAGE |
this.checkMultipart(); |
| 145 |
1
1. checkParametersFormat : negated conditional → NO_COVERAGE |
if (ParameterUtil.isInvalidName(this.injectionModel.getMediatorUtils().connectionUtil().getTypeRequest())) { |
| 146 | throw new InjectionFailureException(String.format( | |
| 147 | "Illegal method: %s", | |
| 148 | this.injectionModel.getMediatorUtils().connectionUtil().getTypeRequest() | |
| 149 | )); | |
| 150 | } | |
| 151 | } | |
| 152 | ||
| 153 | /* | |
| 154 | * Validates an RFC 7230 field-name. | |
| 155 | */ | |
| 156 | public static boolean isInvalidName(String token) { | |
| 157 |
2
1. isInvalidName : negated conditional → NO_COVERAGE 2. isInvalidName : changed conditional boundary → NO_COVERAGE |
for (int i = 0 ; i < token.length() ; i++) { |
| 158 | char c = token.charAt(i); | |
| 159 |
3
1. isInvalidName : negated conditional → NO_COVERAGE 2. isInvalidName : negated conditional → NO_COVERAGE 3. isInvalidName : changed conditional boundary → NO_COVERAGE |
if (c > 255 || !ParameterUtil.TCHAR[c]) { |
| 160 |
1
1. isInvalidName : replaced boolean return with false for com/jsql/util/ParameterUtil::isInvalidName → NO_COVERAGE |
return true; |
| 161 | } | |
| 162 | } | |
| 163 |
2
1. isInvalidName : replaced boolean return with true for com/jsql/util/ParameterUtil::isInvalidName → NO_COVERAGE 2. isInvalidName : replaced boolean return with false for com/jsql/util/ParameterUtil::isInvalidName → NO_COVERAGE |
return token.isEmpty(); |
| 164 | } | |
| 165 | ||
| 166 | private void checkMultipart() throws InjectionFailureException { | |
| 167 | this.isMultipartRequest = false; | |
| 168 | ||
| 169 | if ( | |
| 170 | this.getListHeader() | |
| 171 | .stream() | |
| 172 |
2
1. lambda$checkMultipart$0 : replaced boolean return with true for com/jsql/util/ParameterUtil::lambda$checkMultipart$0 → NO_COVERAGE 2. lambda$checkMultipart$0 : replaced boolean return with false for com/jsql/util/ParameterUtil::lambda$checkMultipart$0 → NO_COVERAGE |
.filter(entry -> "Content-Type".equals(entry.getKey())) |
| 173 |
1
1. checkMultipart : negated conditional → NO_COVERAGE |
.anyMatch(entry -> |
| 174 |
2
1. lambda$checkMultipart$1 : replaced boolean return with true for com/jsql/util/ParameterUtil::lambda$checkMultipart$1 → NO_COVERAGE 2. lambda$checkMultipart$1 : negated conditional → NO_COVERAGE |
entry.getValue() != null |
| 175 |
1
1. lambda$checkMultipart$1 : negated conditional → NO_COVERAGE |
&& entry.getValue().contains("multipart/form-data") |
| 176 |
1
1. lambda$checkMultipart$1 : negated conditional → NO_COVERAGE |
&& entry.getValue().contains("boundary=") |
| 177 | ) | |
| 178 | ) { | |
| 179 | LOGGER.log(LogLevelUtil.CONSOLE_DEFAULT, "Multipart boundary found in header"); | |
| 180 | Matcher matcherBoundary = Pattern.compile("boundary=([^;]*)").matcher(this.getHeaderFromEntries()); | |
| 181 |
1
1. checkMultipart : negated conditional → NO_COVERAGE |
if (matcherBoundary.find()) { |
| 182 | String boundary = matcherBoundary.group(1); | |
| 183 |
1
1. checkMultipart : negated conditional → NO_COVERAGE |
if (!this.rawRequest.contains(boundary)) { |
| 184 | throw new InjectionFailureException( | |
| 185 | String.format("Incorrect multipart data, boundary not found in body: %s", boundary) | |
| 186 | ); | |
| 187 | } else { | |
| 188 | this.isMultipartRequest = true; | |
| 189 | } | |
| 190 | } | |
| 191 | } | |
| 192 | } | |
| 193 | ||
| 194 | private void checkOneOrLessStar() throws InjectionFailureException { | |
| 195 | var nbStarAcrossParameters = 0; | |
| 196 | | |
| 197 |
1
1. checkOneOrLessStar : negated conditional → KILLED |
if (this.getQueryStringFromEntries().contains(InjectionModel.STAR)) { |
| 198 |
1
1. checkOneOrLessStar : Changed increment from 1 to -1 → KILLED |
nbStarAcrossParameters++; |
| 199 | } | |
| 200 |
1
1. checkOneOrLessStar : negated conditional → KILLED |
if (this.getRequestFromEntries().contains(InjectionModel.STAR)) { |
| 201 |
1
1. checkOneOrLessStar : Changed increment from 1 to -1 → KILLED |
nbStarAcrossParameters++; |
| 202 | } | |
| 203 | if ( | |
| 204 |
1
1. checkOneOrLessStar : negated conditional → SURVIVED |
this.getHeaderFromEntries().contains(InjectionModel.STAR) |
| 205 |
2
1. checkOneOrLessStar : negated conditional → SURVIVED 2. checkOneOrLessStar : changed conditional boundary → SURVIVED |
&& this.getCountHeadersWithStar() > 1 |
| 206 | ) { | |
| 207 |
1
1. checkOneOrLessStar : Changed increment from 1 to -1 → NO_COVERAGE |
nbStarAcrossParameters++; |
| 208 | } | |
| 209 | ||
| 210 |
2
1. checkOneOrLessStar : changed conditional boundary → KILLED 2. checkOneOrLessStar : negated conditional → KILLED |
if ( |
| 211 | nbStarAcrossParameters >= 2 | |
| 212 |
2
1. checkOneOrLessStar : changed conditional boundary → SURVIVED 2. checkOneOrLessStar : negated conditional → SURVIVED |
|| StringUtils.countMatches(this.getQueryStringFromEntries(), "*") >= 2 |
| 213 |
2
1. checkOneOrLessStar : negated conditional → SURVIVED 2. checkOneOrLessStar : changed conditional boundary → SURVIVED |
|| StringUtils.countMatches(this.getRequestFromEntries(), "*") >= 2 |
| 214 |
2
1. checkOneOrLessStar : negated conditional → SURVIVED 2. checkOneOrLessStar : changed conditional boundary → SURVIVED |
|| this.getCountHeadersWithStar() > 1 |
| 215 | ) { | |
| 216 | throw new InjectionFailureException("param selected or [*] can be only used once in URL, Request or Header"); | |
| 217 | } | |
| 218 | } | |
| 219 | ||
| 220 | private long getCountHeadersWithStar() { | |
| 221 |
1
1. getCountHeadersWithStar : replaced long return with 0 for com/jsql/util/ParameterUtil::getCountHeadersWithStar → SURVIVED |
return this.getListHeader().stream() |
| 222 |
2
1. lambda$getCountHeadersWithStar$2 : replaced boolean return with false for com/jsql/util/ParameterUtil::lambda$getCountHeadersWithStar$2 → SURVIVED 2. lambda$getCountHeadersWithStar$2 : replaced boolean return with true for com/jsql/util/ParameterUtil::lambda$getCountHeadersWithStar$2 → SURVIVED |
.filter(s -> s.getValue().contains(InjectionModel.STAR)) |
| 223 | .filter(s -> | |
| 224 |
1
1. lambda$getCountHeadersWithStar$3 : replaced boolean return with true for com/jsql/util/ParameterUtil::lambda$getCountHeadersWithStar$3 → SURVIVED |
!List.of( |
| 225 | "accept", "accept-encoding", "accept-language", "access-control-request-headers", "if-match", "if-none-match", "allow" | |
| 226 |
1
1. lambda$getCountHeadersWithStar$3 : negated conditional → SURVIVED |
).contains(s.getKey().toLowerCase()) |
| 227 | ) | |
| 228 | .count(); | |
| 229 | } | |
| 230 | ||
| 231 | public void checkStarMatchMethod() throws InjectionFailureException { | |
| 232 | AbstractMethodInjection methodInjection = this.injectionModel.getMediatorUtils().connectionUtil().getMethodInjection(); | |
| 233 | boolean isCheckingAllParam = this.injectionModel.getMediatorUtils().preferencesUtil().isCheckingAllParam(); | |
| 234 | ||
| 235 | if ( | |
| 236 |
1
1. checkStarMatchMethod : negated conditional → SURVIVED |
this.getQueryStringFromEntries().contains(InjectionModel.STAR) |
| 237 |
2
1. checkStarMatchMethod : negated conditional → SURVIVED 2. checkStarMatchMethod : negated conditional → SURVIVED |
&& methodInjection != this.injectionModel.getMediatorMethod().getQuery() |
| 238 | && !isCheckingAllParam | |
| 239 | ) { | |
| 240 | throw new InjectionFailureException("param in URL selected but method Request or Header selected"); | |
| 241 | } else if ( | |
| 242 |
1
1. checkStarMatchMethod : negated conditional → SURVIVED |
this.getRequestFromEntries().contains(InjectionModel.STAR) |
| 243 |
2
1. checkStarMatchMethod : negated conditional → SURVIVED 2. checkStarMatchMethod : negated conditional → SURVIVED |
&& methodInjection != this.injectionModel.getMediatorMethod().getRequest() |
| 244 | && !isCheckingAllParam | |
| 245 | ) { | |
| 246 | throw new InjectionFailureException("param in Request selected but method URL or Header selected"); | |
| 247 | } else if ( | |
| 248 |
1
1. checkStarMatchMethod : negated conditional → SURVIVED |
this.getHeaderFromEntries().contains(InjectionModel.STAR) |
| 249 |
2
1. checkStarMatchMethod : negated conditional → SURVIVED 2. checkStarMatchMethod : negated conditional → SURVIVED |
&& methodInjection != this.injectionModel.getMediatorMethod().getHeader() |
| 250 | && !isCheckingAllParam | |
| 251 |
2
1. checkStarMatchMethod : changed conditional boundary → NO_COVERAGE 2. checkStarMatchMethod : negated conditional → NO_COVERAGE |
&& this.getCountHeadersWithStar() > 0 |
| 252 | ) { | |
| 253 | throw new InjectionFailureException("param in Header selected but method URL or Request selected"); | |
| 254 | } | |
| 255 | } | |
| 256 | | |
| 257 | public void checkMethodNotEmpty() throws InjectionFailureException { | |
| 258 | AbstractMethodInjection methodInjection = this.injectionModel.getMediatorUtils().connectionUtil().getMethodInjection(); | |
| 259 | ||
| 260 | if ( | |
| 261 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
methodInjection == this.injectionModel.getMediatorMethod().getQuery() |
| 262 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
&& this.getListQueryString().isEmpty() |
| 263 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
&& !this.injectionModel.getMediatorUtils().connectionUtil().getUrlBase().contains(InjectionModel.STAR) |
| 264 | ) { | |
| 265 | throw new InjectionFailureException("empty URL param"); | |
| 266 | } else if ( | |
| 267 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
methodInjection == this.injectionModel.getMediatorMethod().getRequest() |
| 268 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
&& this.getListRequest().isEmpty() |
| 269 | ) { | |
| 270 | throw new InjectionFailureException("empty Request param"); | |
| 271 | } else if ( | |
| 272 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
methodInjection == this.injectionModel.getMediatorMethod().getHeader() |
| 273 |
1
1. checkMethodNotEmpty : negated conditional → KILLED |
&& this.getListHeader().isEmpty() |
| 274 | ) { | |
| 275 | throw new InjectionFailureException("empty Header param"); | |
| 276 | } | |
| 277 | } | |
| 278 | | |
| 279 | public String initStar(SimpleEntry<String, String> parameterToInject) { | |
| 280 | String characterInsertionByUser; | |
| 281 |
1
1. initStar : negated conditional → NO_COVERAGE |
if (parameterToInject.getValue().contains(InjectionModel.STAR)) { // star already set into value when checking all cookies |
| 282 | characterInsertionByUser = parameterToInject.getValue().replace( | |
| 283 | InjectionModel.STAR, | |
| 284 | InjectionModel.STAR | |
| 285 | + this.injectionModel.getMediatorEngine().getEngine().instance().endingComment() | |
| 286 | ); | |
| 287 | } else { | |
| 288 | characterInsertionByUser = parameterToInject.getValue() | |
| 289 |
1
1. initStar : negated conditional → NO_COVERAGE |
+ (parameterToInject.getValue().matches("\\d$") ? "+" : StringUtils.EMPTY) // required when char insertion numeric by user and not found, space not working as zipped |
| 290 | + InjectionModel.STAR | |
| 291 | + this.injectionModel.getMediatorEngine().getEngine().instance().endingComment(); | |
| 292 | } | |
| 293 | // char insertion contains remainder payload when found | |
| 294 | parameterToInject.setValue( | |
| 295 | InjectionModel.STAR | |
| 296 | + this.injectionModel.getMediatorEngine().getEngine().instance().endingComment() | |
| 297 | ); | |
| 298 |
1
1. initStar : replaced return value with "" for com/jsql/util/ParameterUtil::initStar → NO_COVERAGE |
return characterInsertionByUser; |
| 299 | } | |
| 300 | ||
| 301 | public void initQueryString(String urlQuery) throws MalformedURLException, URISyntaxException { | |
| 302 |
1
1. initQueryString : removed call to com/jsql/util/ParameterUtil::initQueryString → KILLED |
this.initQueryString(urlQuery, StringUtils.EMPTY); |
| 303 | } | |
| 304 | ||
| 305 | public void initQueryString(String urlQuery, String selectionCommand) throws MalformedURLException, URISyntaxException { | |
| 306 | // Format and get rid of anchor fragment using native URL | |
| 307 | var url = new URI(urlQuery).toURL(); | |
| 308 | | |
| 309 | if ( | |
| 310 |
1
1. initQueryString : negated conditional → KILLED |
StringUtils.isEmpty(urlQuery) |
| 311 |
1
1. initQueryString : negated conditional → KILLED |
|| StringUtils.isEmpty(url.getHost()) |
| 312 | ) { | |
| 313 | throw new MalformedURLException("empty URL"); | |
| 314 | } | |
| 315 | | |
| 316 |
1
1. initQueryString : removed call to com/jsql/util/ConnectionUtil::setUrlByUser → SURVIVED |
this.injectionModel.getMediatorUtils().connectionUtil().setUrlByUser(urlQuery); |
| 317 |
1
1. initQueryString : removed call to com/jsql/util/ConnectionUtil::setUrlBase → KILLED |
this.injectionModel.getMediatorUtils().connectionUtil().setUrlBase(urlQuery); |
| 318 |
1
1. initQueryString : removed call to java/util/List::clear → SURVIVED |
this.listQueryString.clear(); |
| 319 | | |
| 320 | // Parse url and GET query string | |
| 321 | var regexQueryString = Pattern.compile("(.*\\?)(.*)").matcher(urlQuery); | |
| 322 |
1
1. initQueryString : negated conditional → KILLED |
if (!regexQueryString.find()) { |
| 323 | return; | |
| 324 | } | |
| 325 | | |
| 326 |
1
1. initQueryString : removed call to com/jsql/util/ConnectionUtil::setUrlBase → SURVIVED |
this.injectionModel.getMediatorUtils().connectionUtil().setUrlBase(regexQueryString.group(1)); |
| 327 | | |
| 328 |
1
1. initQueryString : negated conditional → KILLED |
if (StringUtils.isNotEmpty(url.getQuery())) { |
| 329 | this.listQueryString = Pattern.compile("&") | |
| 330 | .splitAsStream(url.getQuery()) | |
| 331 |
1
1. lambda$initQueryString$4 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initQueryString$4 → KILLED |
.map(keyValue -> Arrays.copyOf(keyValue.split("="), 2)) |
| 332 | .map(keyValue -> { | |
| 333 | var paramToAddStar = selectionCommand.replaceAll("^"+ ParameterUtil.PREFIX_COMMAND_QUERY, StringUtils.EMPTY); | |
| 334 |
1
1. lambda$initQueryString$5 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initQueryString$5 → KILLED |
return new SimpleEntry<>( |
| 335 | keyValue[0], | |
| 336 |
1
1. lambda$initQueryString$5 : negated conditional → KILLED |
(keyValue[1] == null ? StringUtils.EMPTY : keyValue[1]) |
| 337 |
1
1. lambda$initQueryString$5 : negated conditional → SURVIVED |
+ (paramToAddStar.equals(keyValue[0]) ? InjectionModel.STAR : StringUtils.EMPTY) |
| 338 | ); | |
| 339 | }).collect(Collectors.toCollection(CopyOnWriteArrayList::new)); // Fix #96224: ConcurrentModificationException | |
| 340 | } | |
| 341 | } | |
| 342 | ||
| 343 | public void initRequest(String rawRequest) { | |
| 344 |
1
1. initRequest : removed call to com/jsql/util/ParameterUtil::initRequest → KILLED |
this.initRequest(rawRequest, StringUtils.EMPTY); |
| 345 | } | |
| 346 | ||
| 347 | public void initRequest(String rawRequest, String selectionCommand) { | |
| 348 | this.rawRequest = rawRequest; | |
| 349 |
1
1. initRequest : removed call to java/util/List::clear → SURVIVED |
this.listRequest.clear(); |
| 350 |
1
1. initRequest : negated conditional → KILLED |
if (StringUtils.isNotEmpty(rawRequest)) { |
| 351 |
2
1. initRequest : negated conditional → SURVIVED 2. initRequest : negated conditional → SURVIVED |
if (this.isMultipartRequest || this.isRequestSoap()) { |
| 352 | // Pass request containing star * param without any parsing | |
| 353 | this.listRequest = new CopyOnWriteArrayList<>(List.of(new SimpleEntry<>( | |
| 354 | rawRequest, | |
| 355 | StringUtils.EMPTY | |
| 356 | ))); | |
| 357 | } else { | |
| 358 | this.listRequest = Pattern.compile("&") | |
| 359 | .splitAsStream(rawRequest) | |
| 360 |
1
1. lambda$initRequest$6 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initRequest$6 → KILLED |
.map(keyValue -> Arrays.copyOf(keyValue.split("="), 2)) |
| 361 | .map(keyValue -> { | |
| 362 | var paramToAddStar = selectionCommand.replaceAll("^"+ ParameterUtil.PREFIX_COMMAND_REQUEST, StringUtils.EMPTY); | |
| 363 |
1
1. lambda$initRequest$7 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initRequest$7 → KILLED |
return new SimpleEntry<>( |
| 364 | keyValue[0], | |
| 365 |
1
1. lambda$initRequest$7 : negated conditional → KILLED |
(keyValue[1] == null ? StringUtils.EMPTY : keyValue[1].replace("\\n", "\n")) |
| 366 |
1
1. lambda$initRequest$7 : negated conditional → SURVIVED |
+ (paramToAddStar.equals(keyValue[0]) ? InjectionModel.STAR : StringUtils.EMPTY) |
| 367 | ); | |
| 368 | }).collect(Collectors.toCollection(CopyOnWriteArrayList::new)); | |
| 369 | } | |
| 370 | } | |
| 371 | } | |
| 372 | ||
| 373 | public void initHeader(String rawHeader) { | |
| 374 |
1
1. initHeader : removed call to com/jsql/util/ParameterUtil::initHeader → SURVIVED |
this.initHeader(rawHeader, StringUtils.EMPTY); |
| 375 | } | |
| 376 | ||
| 377 | public void initHeader(String rawHeader, String selectionCommand) { | |
| 378 | this.rawHeader = rawHeader; | |
| 379 |
1
1. initHeader : removed call to java/util/List::clear → SURVIVED |
this.listHeader.clear(); |
| 380 |
1
1. initHeader : negated conditional → KILLED |
if (StringUtils.isNotEmpty(rawHeader)) { |
| 381 | this.listHeader = Pattern.compile("\\\\r\\\\n") | |
| 382 | .splitAsStream(rawHeader) | |
| 383 |
1
1. lambda$initHeader$8 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initHeader$8 → KILLED |
.map(keyValue -> Arrays.copyOf(keyValue.split(":"), 2)) |
| 384 | .map(keyValue -> { | |
| 385 | var paramToAddStar = selectionCommand.replaceAll("^"+ ParameterUtil.PREFIX_COMMAND_HEADER, StringUtils.EMPTY); | |
| 386 |
1
1. lambda$initHeader$9 : replaced return value with null for com/jsql/util/ParameterUtil::lambda$initHeader$9 → KILLED |
return new SimpleEntry<>( |
| 387 | keyValue[0], | |
| 388 |
1
1. lambda$initHeader$9 : negated conditional → SURVIVED |
(keyValue[1] == null ? StringUtils.EMPTY : keyValue[1]) |
| 389 |
1
1. lambda$initHeader$9 : negated conditional → SURVIVED |
+ (paramToAddStar.equals(keyValue[0]) ? InjectionModel.STAR : StringUtils.EMPTY) |
| 390 | ); | |
| 391 | }).collect(Collectors.toCollection(CopyOnWriteArrayList::new)); | |
| 392 | } | |
| 393 | } | |
| 394 | | |
| 395 | public String getQueryStringFromEntries() { | |
| 396 |
1
1. getQueryStringFromEntries : replaced return value with "" for com/jsql/util/ParameterUtil::getQueryStringFromEntries → KILLED |
return this.listQueryString.stream() |
| 397 | .filter(Objects::nonNull) | |
| 398 |
1
1. lambda$getQueryStringFromEntries$10 : replaced return value with "" for com/jsql/util/ParameterUtil::lambda$getQueryStringFromEntries$10 → KILLED |
.map(entry -> String.format( |
| 399 | ParameterUtil.FORMAT_KEY_VALUE, | |
| 400 | entry.getKey(), | |
| 401 | entry.getValue()) | |
| 402 | ) | |
| 403 | .collect(Collectors.joining("&")); | |
| 404 | } | |
| 405 | ||
| 406 | public String getRequestFromEntries() { | |
| 407 |
1
1. getRequestFromEntries : replaced return value with "" for com/jsql/util/ParameterUtil::getRequestFromEntries → KILLED |
return this.listRequest.stream() |
| 408 | .filter(Objects::nonNull) | |
| 409 |
1
1. lambda$getRequestFromEntries$11 : replaced return value with "" for com/jsql/util/ParameterUtil::lambda$getRequestFromEntries$11 → KILLED |
.map(entry -> String.format( |
| 410 | ParameterUtil.FORMAT_KEY_VALUE, | |
| 411 | entry.getKey(), | |
| 412 |
1
1. lambda$getRequestFromEntries$11 : negated conditional → KILLED |
StringUtils.isEmpty(entry.getValue()) ? StringUtils.EMPTY : entry.getValue() |
| 413 | )) | |
| 414 | .collect(Collectors.joining("&")); | |
| 415 | } | |
| 416 | | |
| 417 | public String getHeaderFromEntries() { | |
| 418 |
1
1. getHeaderFromEntries : replaced return value with "" for com/jsql/util/ParameterUtil::getHeaderFromEntries → SURVIVED |
return this.listHeader.stream() |
| 419 | .filter(Objects::nonNull) | |
| 420 |
1
1. lambda$getHeaderFromEntries$12 : replaced return value with "" for com/jsql/util/ParameterUtil::lambda$getHeaderFromEntries$12 → SURVIVED |
.map(entry -> String.format("%s:%s", entry.getKey(), entry.getValue())) |
| 421 | .collect(Collectors.joining("\\r\\n")); | |
| 422 | } | |
| 423 | ||
| 424 | public boolean isRequestSoap() { | |
| 425 |
2
1. isRequestSoap : replaced boolean return with false for com/jsql/util/ParameterUtil::isRequestSoap → SURVIVED 2. isRequestSoap : replaced boolean return with true for com/jsql/util/ParameterUtil::isRequestSoap → SURVIVED |
return this.rawRequest.trim().matches("(?s)^\\s*(<soapenv:|<\\?xml).*"); |
| 426 | } | |
| 427 | ||
| 428 | | |
| 429 | // Getters / setters | |
| 430 | | |
| 431 | public String getRawRequest() { | |
| 432 |
1
1. getRawRequest : replaced return value with "" for com/jsql/util/ParameterUtil::getRawRequest → NO_COVERAGE |
return this.rawRequest; |
| 433 | } | |
| 434 | ||
| 435 | public String getRawHeader() { | |
| 436 |
1
1. getRawHeader : replaced return value with "" for com/jsql/util/ParameterUtil::getRawHeader → NO_COVERAGE |
return this.rawHeader; |
| 437 | } | |
| 438 | ||
| 439 | public List<SimpleEntry<String, String>> getListRequest() { | |
| 440 |
1
1. getListRequest : replaced return value with Collections.emptyList for com/jsql/util/ParameterUtil::getListRequest → SURVIVED |
return this.listRequest; |
| 441 | } | |
| 442 | ||
| 443 | public List<SimpleEntry<String, String>> getListHeader() { | |
| 444 |
1
1. getListHeader : replaced return value with Collections.emptyList for com/jsql/util/ParameterUtil::getListHeader → SURVIVED |
return this.listHeader; |
| 445 | } | |
| 446 | ||
| 447 | public List<SimpleEntry<String, String>> getListQueryString() { | |
| 448 |
1
1. getListQueryString : replaced return value with Collections.emptyList for com/jsql/util/ParameterUtil::getListQueryString → SURVIVED |
return this.listQueryString; |
| 449 | } | |
| 450 | | |
| 451 | public boolean isMultipartRequest() { | |
| 452 |
2
1. isMultipartRequest : replaced boolean return with false for com/jsql/util/ParameterUtil::isMultipartRequest → NO_COVERAGE 2. isMultipartRequest : replaced boolean return with true for com/jsql/util/ParameterUtil::isMultipartRequest → NO_COVERAGE |
return this.isMultipartRequest; |
| 453 | } | |
| 454 | } | |
Mutations | ||
| 91 |
1.1 |
|
| 93 |
1.1 |
|
| 94 |
1.1 |
|
| 103 |
1.1 2.2 |
|
| 107 |
1.1 |
|
| 111 |
1.1 |
|
| 116 |
1.1 |
|
| 117 |
1.1 |
|
| 118 |
1.1 |
|
| 123 |
1.1 |
|
| 124 |
1.1 |
|
| 126 |
1.1 |
|
| 132 |
1.1 |
|
| 141 |
1.1 |
|
| 142 |
1.1 |
|
| 143 |
1.1 |
|
| 144 |
1.1 |
|
| 145 |
1.1 |
|
| 157 |
1.1 2.2 |
|
| 159 |
1.1 2.2 3.3 |
|
| 160 |
1.1 |
|
| 163 |
1.1 2.2 |
|
| 172 |
1.1 2.2 |
|
| 173 |
1.1 |
|
| 174 |
1.1 2.2 |
|
| 175 |
1.1 |
|
| 176 |
1.1 |
|
| 181 |
1.1 |
|
| 183 |
1.1 |
|
| 197 |
1.1 |
|
| 198 |
1.1 |
|
| 200 |
1.1 |
|
| 201 |
1.1 |
|
| 204 |
1.1 |
|
| 205 |
1.1 2.2 |
|
| 207 |
1.1 |
|
| 210 |
1.1 2.2 |
|
| 212 |
1.1 2.2 |
|
| 213 |
1.1 2.2 |
|
| 214 |
1.1 2.2 |
|
| 221 |
1.1 |
|
| 222 |
1.1 2.2 |
|
| 224 |
1.1 |
|
| 226 |
1.1 |
|
| 236 |
1.1 |
|
| 237 |
1.1 2.2 |
|
| 242 |
1.1 |
|
| 243 |
1.1 2.2 |
|
| 248 |
1.1 |
|
| 249 |
1.1 2.2 |
|
| 251 |
1.1 2.2 |
|
| 261 |
1.1 |
|
| 262 |
1.1 |
|
| 263 |
1.1 |
|
| 267 |
1.1 |
|
| 268 |
1.1 |
|
| 272 |
1.1 |
|
| 273 |
1.1 |
|
| 281 |
1.1 |
|
| 289 |
1.1 |
|
| 298 |
1.1 |
|
| 302 |
1.1 |
|
| 310 |
1.1 |
|
| 311 |
1.1 |
|
| 316 |
1.1 |
|
| 317 |
1.1 |
|
| 318 |
1.1 |
|
| 322 |
1.1 |
|
| 326 |
1.1 |
|
| 328 |
1.1 |
|
| 331 |
1.1 |
|
| 334 |
1.1 |
|
| 336 |
1.1 |
|
| 337 |
1.1 |
|
| 344 |
1.1 |
|
| 349 |
1.1 |
|
| 350 |
1.1 |
|
| 351 |
1.1 2.2 |
|
| 360 |
1.1 |
|
| 363 |
1.1 |
|
| 365 |
1.1 |
|
| 366 |
1.1 |
|
| 374 |
1.1 |
|
| 379 |
1.1 |
|
| 380 |
1.1 |
|
| 383 |
1.1 |
|
| 386 |
1.1 |
|
| 388 |
1.1 |
|
| 389 |
1.1 |
|
| 396 |
1.1 |
|
| 398 |
1.1 |
|
| 407 |
1.1 |
|
| 409 |
1.1 |
|
| 412 |
1.1 |
|
| 418 |
1.1 |
|
| 420 |
1.1 |
|
| 425 |
1.1 2.2 |
|
| 432 |
1.1 |
|
| 436 |
1.1 |
|
| 440 |
1.1 |
|
| 444 |
1.1 |
|
| 448 |
1.1 |
|
| 452 |
1.1 2.2 |