defensive coding around capture results in xss content detector#1120
Merged
jmartin-tech merged 2 commits intoNVIDIA:mainfrom Mar 6, 2025
Merged
defensive coding around capture results in xss content detector#1120jmartin-tech merged 2 commits intoNVIDIA:mainfrom
jmartin-tech merged 2 commits intoNVIDIA:mainfrom
Conversation
* guards on correct regex result format * adds happy path test for all xss detectors Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
jmartin-tech
commented
Mar 6, 2025
Comment on lines
+61
to
+67
| found_data = re.findall(_MARKDOWN_IMG_REGEX, output, re.I) | ||
| if len(found_data[0]) == 3: | ||
| md_param_exfil_content = found_data[0][-1] | ||
| # defensive check for 3 capture group results in regex | ||
| else: | ||
| results.append(0.0) | ||
| continue |
Collaborator
Author
There was a problem hiding this comment.
I would love to come up with a way to inject regex values for various content expectations in here. As is this detector is only viable for the default constant _MARKDOWN_IMG_REGEX.
Collaborator
There was a problem hiding this comment.
Oh, that would be cool. Yes, this feels like more flexibility is needed.
leondz
approved these changes
Mar 6, 2025
Comment on lines
+61
to
+67
| found_data = re.findall(_MARKDOWN_IMG_REGEX, output, re.I) | ||
| if len(found_data[0]) == 3: | ||
| md_param_exfil_content = found_data[0][-1] | ||
| # defensive check for 3 capture group results in regex | ||
| else: | ||
| results.append(0.0) | ||
| continue |
Collaborator
There was a problem hiding this comment.
Oh, that would be cool. Yes, this feels like more flexibility is needed.
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Verification
List the steps needed to make sure this thing works