Repository navigation
Fix SuspiciousContentChecker.Match to detect a pre-defined string when the text starts with it - #18693
Conversation
…hen the text starts with it
Ilya (iSazonov)
left a comment
There was a problem hiding this comment.
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 Travis Plunk (@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 |
…hen the text starts with it (PowerShell#18693)
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.