fix(crypto_usage): eliminate weak-password-hash false positives for non-credential variables - #161
google-labs-jules[bot] wants to merge 1 commit into
Conversation
…e positives for non-credential variables * Improved the regex `_PW` in `crypto_usage.py` by applying a negative lookahead, which ignores case-insensitive suffixes like "token", "hash", "salt", etc., when they immediately follow "password" strings. This eliminates false positives for benign variables such as `passwordResetToken` or `password_hash`. * Wrote 6 permanent regression tests inside `CryptoUsageFalsePositiveTests` in `tests/test_pentest_regressions.py` to assert that zero false positive findings are generated for such snippets. * Ensured zero existing tests broke and no true positive detections were lost. * Passed metrics consistency check and updated `CHANGELOG.md` accordingly.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Held for human review. touches src/websec_validator/extractors/crypto_usage.py (protected path) CI is green; the merge gate stops here on scope, not on test results. Merge it yourself if the change is what you want. |
Fixes false positives generated by
crypto_usage.pyforweak-password-hashwhen analyzing benignpassword-prefixed variables.The previous
_PWregex was matching any variable prefixed with terms likepassword, regardless of whether it functioned as an actual credential or a benign entity like aToken,Hash,Salt,AttemptCount, etc. This commit updates the_PWregex string to include a case-insensitive negative lookahead(?![a-zA-Z0-9_]*?(?:[Tt]oken|[Hh]ash|[Ss]alt|[Aa]ttempt|[Rr]eset|[Cc]ount|[Uu]ri|[Uu]rl|[Ii]d\b|[Ff]ile))that skips non-credential variables, preventing false positives from generating high-severity vulnerability logs.Risk is low. The patch is precisely scoped to variables, contains extensive case-insensitive checking, and will not cause false negatives for existing true positives since strings containing spaces and operators stop matching properly. 6 regression tests were written to confirm no findings are thrown for such variables. All tests run locally passing perfectly, and
CHANGELOG.mdis updated.PR created automatically by Jules for task 11102383511466467547 started by @raccioly