Fine-tuning Semgrep for Ruby Security: Pundit and SQL injection | sorted unsorted thoughts
In this blog post, we’ll go over the construction and tuning of a few Semgrep rules I created while looking at a Ruby on Rails application. Semgrep is a powerful code analysis tool, and while there are a fair number of community rules, the default rules don’t cover everything, and you get a lot more mileage when rules are customized to the codebase. The first rule focuses on detecting a common API misuse pattern that can make Ruby applications susceptible to SQL injection. This is a generic rule and can be used without modification on most Rails applications. The second rule ensures the correct use of Pundit authorization in a Rails application on specified models. This is more of a “rule template” than a complete rule, and needs a bit of customization based on the codebase being scanned. Before delving into the Pundit authorization check, let’s begin with the simpler rule tailored to identify potential SQL injection. This rule primarily targets the misuse of the sql_sanitize family of
In this blog post, we’ll go over the construction and tuning of a few Semgrep rules I created while looking at a Ruby on Rails application. Semgrep is a powerful code analysis tool, and while there are a fair number of community rules, the default rules don’t cover everything, and you get a lot more mileage when rules are customized to the codebase. The first rule focuses on detecting a common API misuse pattern that can make Ruby applications susceptible to SQL injection. This is a generic rule and can be used without modification on most Rails applications. The second rule ensures the correc
related reading
- Why We Don’t Trust the Database With Authentication – Sturdy Statisticsblog.sturdystatistics.com
- How Figma stays ahead of vulnerabilities with agentsfigma.com
- CodeQL zero to hero part 1: The fundamentals of static analysis for vulnerability researchgithub.blog
- Defining A Software Supply Chain Security Platform & Exploring New Techniques, Part 2softwareanalyst.substack.com
- To Thread or Not to Thread: An In-Depth Look at Ruby’s Execution Models - Shopifyshopify.engineering
- Tuning YARA-L Rules in Chronicle SIEM | by Chris Martin (@thatsiemguy) | Mediummedium.com
- Patterns for Defensive Programming in Rust | corrode Rust Consultingcorrode.dev
- Fixing the Dependency Confusion Vulnerability in 600+ Ruby Apps - Shopifyshopify.engineering
- From grep to SPLADE: A Journey Through Semantic Search - Elicitblog.elicit.com
- Solving regex crosswords with Z3 - Made of Bugsblog.nelhage.com
- Programming language evolution: with all that, we are still flyingzverok.github.io
- Why, after 6 years, I’m over GraphQLbessey.dev