-
Notifications
You must be signed in to change notification settings - Fork 150
[IAST] Small string cache bugfix #5064
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
17a98c3
Test implementation
daniel-romano-DD 79d8aa7
Input source taint filter
daniel-romano-DD f515f72
Update tracer/src/Datadog.Trace/Iast/TaintedObjects.cs
daniel-romano-DD 908871b
Restored null check
daniel-romano-DD f602fa9
Update tracer/src/Datadog.Trace/Iast/TaintedObjects.cs
daniel-romano-DD 1437493
Fix tabs
daniel-romano-DD df837b9
Add more tests
daniel-romano-DD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,4 +76,63 @@ public void GivenATaintedString_WhenGetSameValueDifferentReference_NullIsReturne | |
Assert.Equal(tainted1, taintedObjects.Get(tainted1).Value); | ||
Assert.Null(taintedObjects.Get(tainted2)); | ||
} | ||
|
||
[Fact] | ||
public void GivenInputStrings_WhenTainted_DigitsAreFiltered() | ||
{ | ||
TaintedObjects taintedObjects = new(); | ||
Source source = new Source(SourceType.RequestBody, "name", "value"); | ||
|
||
void TaintInput(bool mustBeTainted, string s) | ||
{ | ||
if (mustBeTainted) | ||
{ | ||
Assert.True(taintedObjects.TaintInputString(s, source), s + " should be tainted"); | ||
} | ||
else | ||
{ | ||
Assert.False(taintedObjects.TaintInputString(s, source), s + " should NOT be tainted"); | ||
} | ||
} | ||
|
||
TaintInput(false, string.Empty); | ||
|
||
TaintInput(false, "0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe add a couple of test cases with negative numbers and decimals - they will pass, but guards against future refactoring bugs 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
TaintInput(false, "1"); | ||
TaintInput(false, "2"); | ||
TaintInput(false, "3"); | ||
TaintInput(false, "4"); | ||
TaintInput(false, "5"); | ||
TaintInput(false, "6"); | ||
TaintInput(false, "7"); | ||
TaintInput(false, "8"); | ||
TaintInput(false, "9"); | ||
|
||
#if NET8_0_OR_GREATER | ||
bool largeCache = true; | ||
#else | ||
bool largeCache = false; | ||
|
||
#endif | ||
TaintInput(!largeCache, "10"); | ||
TaintInput(!largeCache, "100"); | ||
TaintInput(!largeCache, "200"); | ||
TaintInput(!largeCache, "299"); | ||
|
||
TaintInput(true, "300"); | ||
TaintInput(true, "500"); | ||
TaintInput(true, "1000"); | ||
|
||
TaintInput(true, "N"); | ||
TaintInput(true, "No"); | ||
TaintInput(true, "5N"); | ||
TaintInput(true, "5ot"); | ||
TaintInput(true, "50t"); | ||
TaintInput(true, "Not"); | ||
TaintInput(true, "Not Numeric"); | ||
|
||
TaintInput(true, "-1"); | ||
TaintInput(true, "-29"); | ||
TaintInput(true, "-35"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not longer checking if
stringToTaint
is null inIsFiltered
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String should not be null here (#nullable enable, but
IsFiltered
checks for null also