Skip to content

defensive coding around capture results in xss content detector#1120

Merged
jmartin-tech merged 2 commits intoNVIDIA:mainfrom
jmartin-tech:fix/xss-content-detector
Mar 6, 2025
Merged

defensive coding around capture results in xss content detector#1120
jmartin-tech merged 2 commits intoNVIDIA:mainfrom
jmartin-tech:fix/xss-content-detector

Conversation

@jmartin-tech
Copy link
Collaborator

  • guards on correct regex result format
  • adds happy path test for all xss detectors

Verification

List the steps needed to make sure this thing works

  • Verify new tests pass automation

* 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>
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that would be cool. Yes, this feels like more flexibility is needed.

Copy link
Collaborator

@leondz leondz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that would be cool. Yes, this feels like more flexibility is needed.

@jmartin-tech jmartin-tech merged commit 8c43585 into NVIDIA:main Mar 6, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2025
@jmartin-tech jmartin-tech deleted the fix/xss-content-detector branch October 28, 2025 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants