feat(sast): vendored MIT semgrep packs and a guard against registry rules (#492) (#504)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Dashboard (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Docs (push) Successful in 1m13s
CI / Deploy Agent (push) Successful in 6m21s

Our ~35 own rules left whole languages without SAST findings. Three
permissively licensed community packs now run next to them, on the same
semgrep invocation (--metrics=off, local files only):

- GitLab sast-rules v2.10.1 (53bf5cf6): 148 rules for C#, Java,
  JavaScript/TypeScript, Python and one Go rule; only files whose header says
  "License: MIT (c) GitLab Inc.". Not vendored: c/ (every file GPL-2.0,
  generated from flawfinder), go/ apart from one file (Apache-2.0 gosec
  ports), scala/, rules/lgpl, rules/lgpl-cc (Commons Clause), rules/gitlab (EE).
- 0xdea semgrep-rules (dae50da6, MIT): 35 C/C++ rules.
- elttam semgrep-rules (24426856, MIT; its LICENSE carries the Semgrep
  template's copyright line): 34 rules for Java, Go and Struts/Spring XML.

Each pack lives in compliance-agent/rules/vendor/<source>/ with LICENSE,
NOTICE (provenance, what was left out and why) and UPSTREAM (pinned commit):
upstream/ holds the selected files unchanged with their tests, pack.yaml the
rules the agent runs, ids prefixed per source (gitlab-, 0xdea-, elttam-),
rules.json an index for the tests. scripts/vendor-semgrep-rules.py
regenerates all of it deterministically.

Provenance: every candidate rule was compared with the Semgrep registry
(semgrep/semgrep-rules, read only for the comparison). Eight GitLab Python/JS
rules with the same message or the same patterns are not vendored, nor are
elttam's Kubernetes rules (registry-derived). Also left out: elttam's
entrypoint enumerators, its ORM-leak hints, three files whose upstream
tests fail on semgrep 1.177 and a join-mode rule.

Noise budget: run over the nightly fixtures, the public samples and
FreeRTOS-Kernel, lwIP, OpenRA, eShopOnWeb, requests, express and
spring-petclinic. 15 rules that flood real code (0xdea missing-return 1514
hits, typos 989, interesting-api-calls 718, signed-unsigned-conversion 221,
suspicious-assert 176, format-string-bugs 61 ...; GitLab assert-used) are
dropped from the pack, each listed with its reason in NOTICE. CPU time of
the semgrep run roughly doubles on C-heavy trees (FreeRTOS-Kernel 70 s ->
136 s, lwIP 18 s -> 68 s), well inside the 10-minute stage timeout.

Ids stay bare (#473 logic covers the vendored ids, fingerprint() unchanged).
The control map gets one vendored semgrep binding per control, by CWE (by
rule id for the few elttam rules without one), with exactly the languages of
the rules behind it; a test checks every vendored rule maps to a control
that claims its languages.

Guard: semgrep_args() builds the one invocation; a test fails if any
--config is not a staged local pack, or is auto, p/, r/ or a URL, and
another scans the agent source, scripts, docker/, CI and Dockerfile.agent for
a registry config.

Nightly baselines with C, Python, C# or JS code change and need a bless run
after the image is deployed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit was merged in pull request #504.
This commit is contained in:
sharangandClaude Opus 5.5 committed 2026-10-06 12:22:50 +00:00
1 parent 9bf7aad5b1
commit d406741907
473 files changed
+50690 -116

No files matched your search

+214
View File
@@ -63,6 +63,33 @@
],
"check": "A committed executable or library must be built with the operating system's basic exploit mitigations on (ASLR/PIE, DEP/non-executable stack, RELRO); one without them is not secure by default. Defence-in-depth extras (CFG, SafeSEH, stack protector, FORTIFY, high-entropy ASLR) are reported but not bound here.",
"attach_only": true
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"csharp",
"generic",
"java",
"python"
],
"cwe": [
"CWE-942",
"CWE-732",
"CWE-1104",
"CWE-1327",
"CWE-554"
],
"rules": [
"elttam-default-properties-devmode",
"elttam-struts-xml-devmode",
"elttam-web-xml-devmode",
"elttam-struts-xml-action-dmi",
"elttam-struts-xml-dmi",
"elttam-taglib-action-dmi",
"elttam-struts-xml-always-select-full-namespace"
],
"check": "Vendored rules (GitLab, elttam): the shipped configuration must be secure by default; a development mode left on (Struts devMode or dynamic method invocation), permissive CORS, world-writable file permissions, a service bound to all interfaces or a missing input-validation framework violates it."
}
],
"note": null,
@@ -167,6 +194,22 @@
],
"rules": [],
"check": "Passwords must be stored with a slow, salted password hash (bcrypt, scrypt, Argon2id, PBKDF2); a fast or unsalted hash (MD5, SHA-1, SHA-256) of a password violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"csharp",
"java"
],
"cwe": [
"CWE-287",
"CWE-306",
"CWE-521",
"CWE-1390"
],
"rules": [],
"check": "Vendored rules (GitLab): access must require strong authentication; an anonymous LDAP bind, an empty database password, missing password complexity or SAML comment handling that lets a signature be bypassed violates it."
}
],
"note": null,
@@ -226,6 +269,19 @@
"cra-ai-8-csharp-hardcoded-credential"
],
"check": "No password, key or secret may be written into the source; a real credential assigned to a password- or key-like name violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"java"
],
"cwe": [
"CWE-259",
"CWE-798"
],
"rules": [],
"check": "Vendored rules (GitLab): no password or key may be written into the source; a real credential assigned in code violates it. A placeholder or an empty value does not."
}
],
"note": null,
@@ -312,6 +368,23 @@
"dotnet-config-insecure-cookies"
],
"check": "Session and authentication cookies must be Secure and HttpOnly; httpCookies without requireSSL or httpOnlyCookies violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"csharp",
"go",
"java"
],
"cwe": [
"CWE-352",
"CWE-614",
"CWE-1004",
"CWE-1275"
],
"rules": [],
"check": "Vendored rules (GitLab, elttam): session state must be protected; cookies without Secure, HttpOnly or a safe SameSite value, and state-changing handlers without CSRF protection violate it."
}
],
"note": null,
@@ -425,6 +498,26 @@
"cra-ai-13-csharp-ecb-mode"
],
"check": "Sensitive data must be protected with current algorithms; MD5, SHA-1, DES, 3DES, RC2 or ECB mode used for it violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"csharp",
"java",
"javascript",
"python"
],
"cwe": [
"CWE-208",
"CWE-326",
"CWE-327",
"CWE-780"
],
"rules": [
"elttam-gcm-static-iv"
],
"check": "Vendored rules (GitLab, elttam): sensitive data must be protected with current algorithms; DES, RC4, MD5, SHA-1, ECB, RSA without padding, short keys, a static GCM nonce or a timing-unsafe comparison of secrets violates it. A non-security use (a cache key, a checksum of public data) does not."
}
],
"note": null,
@@ -546,6 +639,25 @@
"dotnet-config-wcf-insecure-binding"
],
"check": "Network traffic must be encrypted; a WCF binding with security mode None or TransportCredentialOnly, or a basicHttpBinding without transport security, violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"csharp",
"go",
"java",
"python"
],
"cwe": [
"CWE-295",
"CWE-297",
"CWE-319",
"CWE-322",
"CWE-757"
],
"rules": [],
"check": "Vendored rules (GitLab): network traffic must use TLS 1.2 or newer with certificate and host checking; disabled verification, plain-text protocols (HTTP, FTP, SMTP, telnet) for sensitive data or an old protocol version violates it."
}
],
"note": null,
@@ -604,6 +716,26 @@
"secret-file-signing-key"
],
"check": "Keys must not be committed to the source: a private-key store (.pfx, .p12, .jks, .keystore) or strong-name key pair (.snk) in the repository violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"c",
"cpp",
"csharp",
"java",
"javascript",
"python",
"typescript"
],
"cwe": [
"CWE-321",
"CWE-330",
"CWE-338"
],
"rules": [],
"check": "Vendored rules (GitLab, 0xdea): keys, tokens and nonces need a cryptographically secure random generator; rand(), java.util.Random, Math.random or the random module for them violates it."
}
],
"note": null,
@@ -728,6 +860,88 @@
"cra-ai-20-csharp-path-traversal"
],
"check": "Input from outside must not reach SQL, the command line, a type-resolving deserializer, an XML parser with external entities, or a file path unchecked; such a flow in C# code violates it."
},
{
"tool": "semgrep",
"scan_type": "sast",
"languages": [
"c",
"cpp",
"csharp",
"generic",
"go",
"java",
"javascript",
"python",
"typescript"
],
"cwe": [
"CWE-15",
"CWE-20",
"CWE-22",
"CWE-77",
"CWE-78",
"CWE-79",
"CWE-88",
"CWE-89",
"CWE-90",
"CWE-91",
"CWE-94",
"CWE-95",
"CWE-113",
"CWE-116",
"CWE-125",
"CWE-131",
"CWE-134",
"CWE-155",
"CWE-158",
"CWE-170",
"CWE-180",
"CWE-182",
"CWE-185",
"CWE-190",
"CWE-193",
"CWE-200",
"CWE-209",
"CWE-242",
"CWE-252",
"CWE-362",
"CWE-364",
"CWE-367",
"CWE-377",
"CWE-415",
"CWE-416",
"CWE-467",
"CWE-502",
"CWE-552",
"CWE-562",
"CWE-590",
"CWE-601",
"CWE-611",
"CWE-643",
"CWE-676",
"CWE-683",
"CWE-686",
"CWE-696",
"CWE-697",
"CWE-704",
"CWE-762",
"CWE-770",
"CWE-787",
"CWE-806",
"CWE-839",
"CWE-917",
"CWE-918",
"CWE-1260",
"CWE-1333"
],
"rules": [
"elttam-potential-symlink-takeover-with-os-executable",
"elttam-sprintf-unescaped-control-characters",
"elttam-non-atomic-use-of-converted-uintptr",
"elttam-UnsafeHttpInvokerServiceExporter-XML"
],
"check": "Vendored rules (GitLab, 0xdea, elttam): untrusted input must not reach an interpreter, the file system, a deserialiser or a fixed-size buffer unchecked; injection (SQL, OS command, LDAP, XPath, XSS, template), path traversal, unsafe deserialisation, XXE, SSRF, open redirects, and memory errors (unbounded copies, off-by-one, use after free, double free, integer wraparound) violate it."
}
],
"note": null,