Skip to content

Commit c51d2c5

Browse files
authored
test semgrep ci (#9534)
* changes * changes * lint
1 parent 4721c5e commit c51d2c5

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

.github/workflows/semgrep.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
name: Semgrep
1+
name: semgrep ci
22

33
on:
4-
workflow_run:
5-
workflows: ["trigger-semgrep"]
6-
types:
7-
- completed
8-
4+
workflow_run:
5+
workflows: ["trigger-semgrep"]
6+
types:
7+
- completed
8+
99
env:
1010
CI: true
1111
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
1212

1313
concurrency:
14-
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
15-
cancel-in-progress: true
14+
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
15+
cancel-in-progress: true
1616

1717
permissions: {}
1818

1919
jobs:
2020
semgrep:
2121
permissions:
22-
contents: read
22+
contents: read
2323
name: semgrep/ci
2424
runs-on: ubuntu-latest
2525
container:
2626
image: semgrep/semgrep
2727
outputs:
28-
pr_number: ${{ steps.json.outputs.pr_number }}
29-
sha: ${{ steps.json.outputs.sha }}
28+
pr_number: ${{ steps.json.outputs.pr_number }}
29+
sha: ${{ steps.json.outputs.sha }}
3030
if: (github.actor != 'dependabot[bot]')
3131
steps:
3232
- name: Download artifact
@@ -38,12 +38,12 @@ jobs:
3838
- uses: gradio-app/github/actions/json-to-output@main
3939
id: json
4040
with:
41-
path: output.json
41+
path: output.json
4242
- uses: actions/checkout@v4
4343
with:
4444
repository: ${{ steps.json.outputs.source_repo }}
4545
ref: ${{ steps.json.outputs.sha }}
46-
- run: semgrep ci
46+
- run: semgrep ci --config .github/workflows/semgrep_rules.yaml
4747
env:
4848
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN2 }}
4949
update-status:
@@ -61,4 +61,4 @@ jobs:
6161
name: "Semgrep Results"
6262
pr: ${{ needs.semgrep.outputs.pr_number }}
6363
result: ${{ needs.semgrep.result == 'success' && 'success' || 'failure' }}
64-
type: all
64+
type: all

.github/workflows/semgrep_rules.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
rules:
2+
- id: detect-os-system-calls
3+
pattern: os.system(...)
4+
message: "Unsafe use of os.system(). Consider using subprocess.run() instead."
5+
languages: [python]
6+
severity: WARNING
7+
8+
- id: detect-sql-injection
9+
pattern: 'execute("SELECT * FROM " + $TABLE)'
10+
message: "Potential SQL injection detected. Use parameterized queries."
11+
languages: [python]
12+
severity: ERROR
13+
14+
- id: detect-eval-usage
15+
pattern: eval(...)
16+
message: "Use of eval() detected. This can be dangerous if used with untrusted input."
17+
languages: [python]
18+
severity: ERROR

0 commit comments

Comments
 (0)