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