Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4b054d1
Use different scriptlet JSP to test no-scriptlets rule
Sjord Aug 18, 2025
c7f3f18
Fix languages mixed
LewisArdern Mar 27, 2026
b340917
Merge pull request #3790 from semgrep/fix-mulilanmg
LewisArdern Mar 27, 2026
50cf5fd
Fix more
LewisArdern Mar 27, 2026
e602027
fix more rules
liukatkat Mar 27, 2026
e6abd84
fix rules again
liukatkat Mar 27, 2026
fc7be6a
Add GHA supply chain security rules (mutable-action-tag, pwn-request)…
kurt-r2c Mar 31, 2026
58d7163
ocaml rule for unsafe mutex use
dijkstracula Apr 1, 2026
5e164e2
Merge pull request #3794 from semgrep/fixy
LewisArdern Apr 2, 2026
634689f
fix(kotlin): exclude ephemeral port detection from unencrypted-socket…
0xDC0DE Apr 3, 2026
6b4f11f
Add secrets-inherit rule for GitHub Actions workflows (#3803)
pid1 Apr 6, 2026
a19e538
Add additional GitHub properties (#3760)
Piccirello Apr 7, 2026
4d801e2
Add missing GitHub Actions context variables to command injection rul…
ddworken Apr 7, 2026
9ce5c5d
Merge pull request #3801 from semgrep/nathan/ocaml_mutex
LewisArdern Apr 7, 2026
d10af80
update github-script-injection rule (#3806)
inkz Apr 7, 2026
1da84b3
update gha rules (#3807)
inkz Apr 8, 2026
96c3d0f
Allow multi-document YAML in all .test.yaml/.test.yml files (#3809)
0xDC0DE Apr 9, 2026
fdc7354
Package manager cooldown (#3805)
gbennett-squarespace Apr 15, 2026
9d73d08
fix(historical-version): use canonical semgrep/semgrep API path and f…
0xDC0DE Apr 27, 2026
b29bee1
Merge pull request #3676 from Sjord/no-scriptletes-test
kurt-r2c May 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repos:
- id: check-yaml
exclude: |
(?x)^(
# These are multi-document
yaml/github-actions/semgrep-configuration/semgrep-github-action-push-without-branches\.test\.yml|
yaml/kubernetes/security/.*\.test\.yaml
# Semgrep rule test files may use multi-document YAML
# to separate test cases
.*\.test\.ya?ml
)$
# Exception case - multi-document YAML OK - still check YAML
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -27,7 +27,7 @@ repos:
args: [--allow-multiple-documents]
files: |
(?x)^(
# These are multi-document
yaml/github-actions/semgrep-configuration/semgrep-github-action-push-without-branches\.test\.yml|
yaml/kubernetes/security/.*\.test\.yaml
# Semgrep rule test files may use multi-document YAML
# to separate test cases
.*\.test\.ya?ml
)$
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rules:
- id: anthropic-hardcoded-api-key-go
languages: [go]
severity: ERROR
message: >-
Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
category: security
subcategory: [vuln]
likelihood: HIGH
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/docs/initial-setup
patterns:
- pattern: option.WithAPIKey("$KEY")
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rules:
- id: anthropic-hardcoded-api-key-java
languages: [java]
severity: ERROR
message: >-
Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
category: security
subcategory: [vuln]
likelihood: HIGH
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/docs/initial-setup
patterns:
- pattern: $OBJ.apiKey("$KEY")
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rules:
- id: anthropic-hardcoded-api-key-javascript
languages: [javascript, typescript]
severity: ERROR
message: >-
Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
category: security
subcategory: [vuln]
likelihood: HIGH
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/docs/initial-setup
patterns:
- pattern: |
new Anthropic({apiKey: "$KEY", ...})
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rules:
- id: anthropic-hardcoded-api-key-python
languages: [python]
severity: ERROR
message: >-
Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
category: security
subcategory: [vuln]
likelihood: HIGH
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/docs/initial-setup
pattern-either:
- patterns:
- pattern: Anthropic(api_key="$KEY", ...)
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-
- patterns:
- pattern: AsyncAnthropic(api_key="$KEY", ...)
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rules:
- id: anthropic-hardcoded-api-key-ruby
languages: [ruby]
severity: ERROR
message: >-
Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
category: security
subcategory: [vuln]
likelihood: HIGH
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/docs/initial-setup
patterns:
- pattern: |
Anthropic::Client.new(api_key: "$KEY", ...)
- metavariable-regex:
metavariable: $KEY
regex: ^sk-ant-

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
rules:
- id: anthropic-missing-max-tokens-python
languages: [python]
severity: WARNING
message: >-
Anthropic messages.create() called without 'max_tokens' parameter. Setting
max_tokens prevents unexpectedly long or expensive responses.
metadata:
cwe: "CWE-770: Allocation of Resources Without Limits or Throttling"
category: security
subcategory: [audit]
likelihood: MEDIUM
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/api/messages
patterns:
- pattern: $CLIENT.messages.create(...)
- pattern-not: $CLIENT.messages.create(..., max_tokens=$MT, ...)

- id: anthropic-missing-max-tokens-javascript
languages: [javascript, typescript]
severity: WARNING
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
rules:
- id: anthropic-missing-max-tokens-python
languages: [python]
severity: WARNING
message: >-
Anthropic messages.create() called without 'max_tokens' parameter. Setting
max_tokens prevents unexpectedly long or expensive responses.
metadata:
cwe: "CWE-770: Allocation of Resources Without Limits or Throttling"
category: security
subcategory: [audit]
likelihood: MEDIUM
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/api/messages
patterns:
- pattern: $CLIENT.messages.create(...)
- pattern-not: $CLIENT.messages.create(..., max_tokens=$MT, ...)
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
rules:
- id: anthropic-missing-metadata-user-id-python
languages: [python]
severity: WARNING
message: >-
Anthropic messages.create() called without 'metadata' parameter. Pass a
metadata object with a hashed user_id to enable abuse tracking and policy
enforcement. See https://docs.anthropic.com/en/api/messages
metadata:
cwe: "CWE-778: Insufficient Logging"
category: security
subcategory: [audit]
likelihood: MEDIUM
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/api/messages
patterns:
- pattern: $CLIENT.messages.create(...)
- pattern-not: $CLIENT.messages.create(..., metadata=$META, ...)

- id: anthropic-missing-metadata-user-id-javascript
languages: [javascript, typescript]
severity: WARNING
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rules:
- id: anthropic-missing-metadata-user-id-python
languages: [python]
severity: WARNING
message: >-
Anthropic messages.create() called without 'metadata' parameter. Pass a
metadata object with a hashed user_id to enable abuse tracking and policy
enforcement. See https://docs.anthropic.com/en/api/messages
metadata:
cwe: "CWE-778: Insufficient Logging"
category: security
subcategory: [audit]
likelihood: MEDIUM
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/api/messages
patterns:
- pattern: $CLIENT.messages.create(...)
- pattern-not: $CLIENT.messages.create(..., metadata=$META, ...)
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
rules:
- id: anthropic-missing-refusal-check-python
languages: [python]
severity: WARNING
message: >-
Anthropic response content accessed without checking stop_reason. Check
response.stop_reason to handle cases where the model stops unexpectedly
(e.g., due to max_tokens or content filtering).
metadata:
cwe: "CWE-1188: Initialization with an Insecure Default"
category: security
subcategory: [audit]
likelihood: MEDIUM
impact: MEDIUM
confidence: HIGH
technology: [anthropic]
references:
- https://docs.anthropic.com/en/api/messages
patterns:
- pattern: $RESP.content
- pattern-inside: |
$RESP = $CLIENT.messages.create(...)
...
- pattern-not-inside: |
if $RESP.stop_reason == "end_turn":
...
- pattern-not-inside: |
if $RESP.stop_reason != ...:
...
else:
...

- id: anthropic-missing-refusal-check-javascript
languages: [javascript, typescript]
severity: WARNING
Expand Down
Loading
Loading