8000 Add IAST propagation to String valueOf by Mariovido · Pull Request #8013 · DataDog/dd-trace-java · GitHub
[go: up one dir, main page]

Skip to content

Add IAST propagation to String valueOf #8013

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

Merged
merged 8 commits into from
Nov 27, 2024
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
Prev Previous commit
Next Next commit
Add support for special objects
  • Loading branch information
Mariovido committed Nov 26, 2024
commit 4669bea5879f3f95b31a36a59b1c15ceb7f67c54
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,17 @@ public void onStringValueOf(Object param, @Nonnull String result) {
return;
}

taintedObjects.taint(result, rangesParam);
// Special objects like InputStream...
if (rangesParam[0].getLength() == Integer.MAX_VALUE) {
final Source source = rangesParam[0].getSource();
final Range[] ranges =
Ranges.forCharSequence(
result, new Source(source.getOrigin(), source.getName(), source.getValue()));

taintedObjects.taint(result, ranges);
} else {
taintedObjects.taint(result, rangesParam);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1324,11 +1324,17 @@ class StringModuleTest extends IastModuleImplTestBase {
sbf("==>my_input<==") | "==>my_input<=="
}

void 'test valueOf with taintable object and make sure IastRequestContext is called'() {
void 'test valueOf with taintable and special objects object and make sure IastRequestContext is called'() {
given:
final taintedObjects = ctx.getTaintedObjects()
final source = taintedSource(null)
final param = taintable(taintedObjects, source)
final source = taintedSource()
final param
if (taintable) {
param = taintable(taintedObjects, source)
} else {
param = new ObjectInputStream()
taintObject(taintedObjects, param, source)
}
def result = String.valueOf(param)

when:
Expand All @@ -1338,6 +1344,9 @@ class StringModuleTest extends IastModuleImplTestBase {
then:
1 * tracer.activeSpan() >> span
taintFormat(result, taintedObject.getRanges()) == "==>" + param.toString() + "<=="

where:
taintable << [true, false]
}

private static Date date(final String pattern, final String value) {
Expand Down
Loading
0