rules:
- id: incomplete-sanitization
  patterns:
  - pattern: |
      $STR.replace(($CHAR: string), ...)
  - metavariable-regex:
      metavariable: $CHAR
      regex: ^[\"\']([\'\"\<\>\*\|\{\}\[\]\%\$]{1}|\\n|\\r|\\t|\\&)[\"\']$
  message: >-
    `$STR.replace` method will only replace the first occurence when used with a string argument ($CHAR).
    If this method is used for escaping of dangerous data then there is a possibility for a bypass.
    Try to use sanitization library instead or use a Regex with a global flag.
  metadata:
    cwe: 'CWE-116: Improper Encoding or Escaping of Output'
    category: security
    technology:
    - javascript
  languages: [js, ts]
  severity: WARNING
