Skip to content
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

fix(golang): permissive regex rule for validation purposes #457

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

elsapet
Copy link
Collaborator

@elsapet elsapet commented Jul 4, 2024

Description

Ideally the go_lang_permissive_regex_validation rule would only trigger when the permissive regular expression is being used for validation-specific purposes. Unlike some frameworks (Ruby-on-Rails, PHP Symfony), with golang, we cannot determine how a particular regular expression is being used. For this reason, the rule was triggering on the compilation of permissive regex, rather than its use. However, this meant that we were seeing some confusing false positives with this rule -- for example, with Replace (where there is no real security issue).

To address this, we modify the rule so that it triggers only when a permissive regular expression is used with Match methods, as this is more likely to be a validation case. We hope that this will reduce the rate of false positives while still proving useful in alerting users to actual security issues.

Checklist

If this is your first time contributing please sign the CLA

  • My rule has adequate metadata to explain its use.

@elsapet elsapet requested review from gotbadger and didroe July 4, 2024 07:57
@elsapet elsapet merged commit f4ac2b1 into main Jul 4, 2024
27 checks passed
@elsapet elsapet deleted the fix/golang-regex-validation-rule branch July 4, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants