Skip to content

Commit

Permalink
Merge pull request #1353 from akto-api-security/list_payload_fix
Browse files Browse the repository at this point in the history
list payload length percent match fix
  • Loading branch information
ayushaga14 authored Aug 14, 2024
2 parents 4b1446a + f406923 commit 1328e95
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public DataOperandsFilterResponse applyFilterOnResponsePayload(FilterActionReque

public DataOperandsFilterResponse applyFilterOnPayload(FilterActionRequest filterActionRequest, String payload) {

String origPayload = payload;
BasicDBObject payloadObj = new BasicDBObject();
try {
payload = Utils.jsonifyIfArray(payload);
Expand Down Expand Up @@ -339,16 +340,16 @@ public DataOperandsFilterResponse applyFilterOnPayload(FilterActionRequest filte
return new DataOperandsFilterResponse(false, matchingValueKeySet, null, null, validationReason.toString());
}
} else if (filterActionRequest.getConcernedSubProperty() == null) {
Object val = payload;
Object val = origPayload;

if (filterActionRequest.getBodyOperand() != null && filterActionRequest.getBodyOperand().equalsIgnoreCase(BodyOperator.LENGTH.toString())) {
val = payload.trim().length() - 2; // todo:
val = origPayload.trim().length() - 2; // todo:
} else if (filterActionRequest.getBodyOperand() != null && filterActionRequest.getBodyOperand().equalsIgnoreCase(BodyOperator.PERCENTAGE_MATCH.toString())) {
RawApi sampleRawApi = filterActionRequest.getRawApi();
if (sampleRawApi == null) {
return new DataOperandsFilterResponse(false, null, null, null);
}
double percentageMatch = TestPlugin.compareWithOriginalResponse(payload, sampleRawApi.getResponse().getBody(), new HashMap<>());
double percentageMatch = TestPlugin.compareWithOriginalResponse(origPayload, sampleRawApi.getResponse().getBody(), new HashMap<>());
val = (int) percentageMatch;
} else if (filterActionRequest.getBodyOperand() != null && filterActionRequest.getBodyOperand().equalsIgnoreCase(BodyOperator.PERCENTAGE_MATCH_SCHEMA.toString())) {
RawApi sampleRawApi = filterActionRequest.getRawApi();
Expand Down

0 comments on commit 1328e95

Please sign in to comment.