Semgrep
Developer-friendly SAST in DevOps Pipeline
About Me
Sam Benjamin Pragasam
Product Security Engineer @ Traceable
Love to Connect
https://www.linkedin.com/in/samsbp/
https://topmate.io/sam_benjamin_pragasam
Agenda
● What’s and why’s
● Evaluating SAST Tools
● How SAST works
● Continuous Testing with Semgrep
● Semgrep Rules & Patterns
● Alternatives
Manual secure code
review
Automated secure
code review
SAST
What? Why? Why not?
Evaluating SAST Tools
Where Semgrep Falls
How SAST Works?
Taint Propagation
What?
● Acronym “Static Application Security Testing”
● Automated secure code review
● Similar to linters but with focus in security
● Flexible and manageable via rules
Why?
● Quality Enabler
● Shift left - early feedback in pipeline which
increases fix rate
● Whitebox Testing - blindspot for blockbox
testing
● Increased Coverage
Why Not?
● False positives
● Lack of developer focused pipeline
● Scalability - Prioritizing Issues without
context
2021 Data
Evaluating SAST Tools
Broader Programming Language Support Capability for prioritization
Api Integration Low false positives
Jira Integration - vulnerability management Time taken to analyse the code
CI integration CLI capabilities
Less Cognitive load in pipeline Scan customizations such as sanitizers,
rulesets
IDE Integration Secret Detection
Where Semgrep Falls
Broader Programming Language Support Capability for prioritization
Api Integration Reduced false positives - taint mode and
sanitizers supported
Jira Integration - vulnerability managment Time taken to analayse the code
CI integration CLI capabilities
Less Cognitive load in pipeline Scan customizations such as sanitizers,
rulesets
IDE Integration Secret Detection
Source
Sink
How SAST works?
Taint Propagation
Continuous Testing
The Pipeline
Github CI with semgrep
Integration with defectDojo
The Pipeline
https://github.com/samsbp/semgrep-workflow
Pipeline - Github CI Action
https://github.com/samsbp/semgrep-workflow
Pipeline - Semgrep Autofix
Pipeline - Push Findings to DefectDojo
Pipeline - DefectDojo Findings UI
Rules
● Grep like patterns
● Autofix suggestion
● Generic Pattern Matching
● Taint Propagation
Pattern
● String matching
● Ellipsis Operator
● Metavariables
● statement blocks
● Equivalences
● Constants
Semgrep Patterns - Metavaraibles, block stmt, ellipsis
Semgrep Taint Propogation
Alternatives
This is not endorsement to any of the listed products. This is a collected list of SAST products in the market.
References
1. https://engineering.razorpay.com/building-a-sast-program-at-razorpays-scale-719887fe0aec
2. https://www.anshumanbhartiya.com/posts/sast-workflow
3. https://appsecmap.com/
4. https://www.defectdojo.org/
5. https://whimsical.com/
6. https://semgrep.dev/playground
7. https://github.com/samsbp/semgrep-workflow
8. https://www.contrastsecurity.com/hubfs/DocumentsPDF/2021-Application-Security-
Observability-Report_Executive-Summary_Final.pdf
9. https://docs.github.com/en/actions/using-workflows/reusing-workflows

Developer-friendly SAST in DevOps Pipeline.pptx