rules:
- id: sandbox-code-injection
  message: >-
    Make sure that unverified user data can not reach `sandbox`.
  severity: WARNING
  languages: [javascript, typescript]
  metadata:
    owasp: 'A1: Injection'
    cwe: 'CWE-94: Improper Control of Generation of Code (Code Injection)'
    category: security
    technology:
    - sandbox
  patterns:
  - pattern-inside: |
      $SANDBOX = require('sandbox');
      ...
  - pattern-not-inside: |
      $CODE = "...";
      ...
  - pattern-either:
    - patterns:
      - pattern-inside: |
          $S = new $SANDBOX(...);
          ...
      - pattern: $S.run($CODE,...);
    - pattern: |
        new $SANDBOX(...).run($CODE,...);
  - pattern-not-inside: |
      $S = new $SANDBOX(...);
      ...
      $S.run("...",...);
  - pattern-not-inside: |-
      new $SANDBOX(...).run("...",...);
