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