Skip to content
Notifications
Clear all

Comparison: writing rules in YAML vs the new experimental language

3 Posts
3 Users
0 Reactions
2 Views
(@cloud_ops_learner_3)
Reputable Member
Joined: 2 months ago
Posts: 147
Topic starter   [#19213]

I've been using Semgrep's YAML rules for a few months to catch common security misconfigs in our Terraform. Now I see there's an experimental rule language. Has anyone tried it?

I'm curious about the practical differences. Is the new language easier for writing complex logic? Does it integrate the same way into our existing CI/CD pipeline? I'm mainly worried about adding another toolchain or learning curve for the team.



   
Quote
(@crusty_pipeline_v2)
Estimable Member
Joined: 2 months ago
Posts: 94
 

I'm a platform lead at a fintech (~200 devs), we run Semgrep in CI across ~500 Terraform modules and Helm charts.

- **Learning curve**: YAML is minutes for anyone who's seen a linter rule. The new language is like writing Python without the stdlib, it took me a day to get productive.
- **Complex logic**: YAML gets messy fast if you need 3+ nested conditionals. The new language handles it cleanly. Example: checking for a specific tag format across nested Terraform blocks was 8 lines vs 40+ YAML with regexes.
- **CI integration**: Exactly the same. Both use `semgrep scan`. No new toolchain, just a different file extension.
- **Maintenance**: YAML is easier to grep and for junior team members to edit. The new language is better for reusable patterns; we turned 5 similar YAML rules into one function.

Pick YAML if your team's comfort and rule simplicity matter more. Use the new language if you have 10+ similar complex rules or need custom operators. Tell me if you're mostly writing one-off checks or have a pattern you repeat.


slow pipelines make me cranky


   
ReplyQuote
(@charlieg)
Estimable Member
Joined: 1 week ago
Posts: 93
 

You're over-indexing on junior developer comfort. If they can't learn a new syntax in a day, they shouldn't be writing rules. The maintainability argument is backwards - having five similar YAML rules is the problem, not the solution.

> The new language is better for reusable patterns

Exactly. That's the whole point. YAML forces you into copy-paste duplication, which is where most of our rule errors come from. A single function with clear parameters is always safer than five slightly different regex patterns.

The real question is why Semgrep bothered with YAML at all. It was a marketing compromise to get security teams onboard, and now we're stuck debating it. The experimental language should be the default.


cg


   
ReplyQuote