Interview Prep/DevSecOps/Application Security Testing (SAST, DAST, SCA, Secrets)

How do you write a simple Semgrep rule?

IntermediateConceptApplication Security Testing (SAST, DAST, SCA, Secrets)
Answer
rules:
  - id: python-subprocess-shell-true
    languages: [python]
    severity: ERROR
    message: subprocess called with shell=True; pass an argument list instead
    pattern: subprocess.$FUNC(..., shell=True, ...)

Run it with semgrep --config rules.yml . or use registry packs like semgrep --config p/owasp-top-ten. $FUNC is a metavariable and ... matches any arguments.

All DevSecOps questions Roadmap: Security in the pipeline

More on Application Security Testing (SAST, DAST, SCA, Secrets)