-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix SuspiciousContentChecker.Match to detect a pre-defined string when the text starts with it
#18693
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
Conversation
…hen the text starts with it
iSazonov
left a comment
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.
Since we take into account only ASCII chars and - I suggest adding more tests with using specific chars - ASCII non-letters, Unicode, surrogates in different positions in prefix, in word, in suffix.
Also now we check start position and I'd expect we check the transition for the 19th position too.
And maybe xUnit test would be more fast for the internal API (also exclude reflection - it is not good for public test) .
|
After chatting with @TravisEz13, my understanding is that this defense-and-depth feature is sort of broken (high chance of collision) and it was decided to not fix it. So, adding more tests for it doesn't seem worth the effort in my opinion. But I'm totally open to add some more tests. What do you mean by About xUnit test, I don't think it's necessary unless it turns out to be hard to test some specific characters. PowerShell has the |
Sorry, typo, 29th - max word size. So a test could check starting with 30th position.
We could reduce collisions with simple trick - take into account word length. |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
I have added the requested tests. But be noted that, those are just smoke tests, and are by no means intended for covering the |
|
LGTM. |
|
/backport to release/v7.3.2 |
PR Summary
Fix
SuspiciousContentChecker.Matchto detect a pre-defined string when the text starts with it.PR Context
The method
SuspiciousContentChecker.Matchhas a flaw: when the text starts with a string that is defined inLookupHash(uint h), it cannot detect the string.NOTE: The
SuspiciousContentChecker.Matchcheck is a defense-and-depth thing, so this bug is NOT a security vulnerability.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.