Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in IAST evidence redaction #6099

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ private void addValuePart(
valueParts.add(new TaintedValuePart(adapter, source, chunk, false));
} else {
final int length = chunk.length();
final int matching = source.getValue().indexOf(chunk);
final String sourceValue = source.getValue();
final int matching = (sourceValue == null) ? 0 : sourceValue.indexOf(chunk);
final String pattern;
if (matching >= 0) {
// if matches append the matching part from the redacted value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,40 @@ suite:
]
}


- type: 'VULNERABILITIES'
description: 'Tainted range based redaction - with null source '
input: >
[
{
"type": "XSS",
"evidence": {
"value": "this could be a super long text, so we need to reduce it before send it to the backend. This redaction strategy applies to XSS vulnerability but can be extended to future ones",
"ranges": [
{ "start" : 123, "length" : 3, "source": { "origin": "http.request.body" } }
]
}
}
]
expected: >
{
"sources": [
{ "origin": "http.request.body" }
],
"vulnerabilities": [
{
"type": "XSS",
"evidence": {
"valueParts": [
{ "redacted": true },
{ "source": 0, "value": "XSS" },
{ "redacted": true }
]
}
}
]
}

- type: 'VULNERABILITIES'
description: 'Tainted range based redaction - multiple ranges'
input: >
Expand Down
Loading