rules:
- id: incomplete-sanitization
  message: >-
    `$STR.replace` method will only replace the first occurrence 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
    owasp:
    - A03:2021 - Injection
    - A05:2025 - Injection
    subcategory:
    - audit
    likelihood: LOW
    impact: LOW
    confidence: LOW
    references:
    - https://owasp.org/Top10/A03_2021-Injection
  languages:
  - javascript
  - typescript
  severity: WARNING
  patterns:
  - pattern: |
      $STR.replace(($CHAR: string), ...)
  - metavariable-regex:
      metavariable: $CHAR
      regex: ^[\"\']([\'\"\<\>\*\|\{\}\[\]\%\$]{1}|\\n|\\r|\\t|\\&)[\"\']$
