Skip to content

Commit

Permalink
New ruleset: no-backticks-in-js-handlers.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon authored Jul 27, 2023
1 parent 35ad247 commit cddd636
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions assets/semgrep_rules/web/no-backticks-in-js-handlers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules:
- id: no-backtick-in-js-handlers
patterns:
- pattern-either:
- pattern-inside: $HANDLER="..."
- pattern-inside: $HANDLER='...'
- pattern-inside: $HANDLER=...
- pattern-regex: '`{{[^}]+}}`'
- metavariable-regex:
metavariable: $HANDLER
regex: on(abort|auxclick|beforeinput|beforematch|beforetoggle|cancel|canplay|canplaythrough|change|click|close|contextlost|contextmenu|contextrestored|copy|cuechange|cut|dblclick|drag|dragend|dragenter|dragleave|dragover|dragstart|drop|durationchange|emptied|ended|formdata|input|invalid|keydown|keypress|keyup|loadeddata|loadedmetadata|loadstart|mousedown|mouseenter|mouseleave|mousemove|mouseout|mouseover|mouseup|paste|pause|play|playing|progress|ratechange|reset|securitypolicyviolation|seeked|seeking|select|slotchange|stalled|submit|suspend|timeupdate|toggle|volumechange|waiting|webkitAnimationEnd|webkitAnimationIteration|webkitAnimationStart|webkitTransitionEnd|wheel)
message: |
Backtick in JS handler may cause XSS since they are typically not auto escaped in variables.
Consider using single or double apices, instead of backticks.
languages: [generic]
severity: WARNING

0 comments on commit cddd636

Please sign in to comment.