Skip to content

Commit 292b03a

Browse files
authored
Setup testing for our custom sermver rules (#13)
* Add a test case for our new test. * First try and GitHub Action * Make a dedicated testing directory to make it clear what are tests and what are rules. * quote all strings in the yaml files * run ratchet on action_scanning.yml
1 parent d74aa3f commit 292b03a

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
### Required actions to scan GitHub action workflows for security issues.
2-
name: Scan GitHub Action workflows files for security issues
2+
name: 'Scan GitHub Action workflows files for security issues'
33

44
on:
55
pull_request: {}
66

77
permissions:
8-
contents: read
9-
security-events: write
10-
actions: read
8+
contents: 'read'
9+
security-events: 'write'
10+
actions: 'read'
1111

1212
jobs:
1313
semgrep:
14-
name: semgrep-oss/scan
15-
runs-on: ubuntu-latest
14+
name: 'semgrep-oss/scan'
15+
runs-on: 'ubuntu-latest'
1616

1717
container:
18-
image: semgrep/semgrep
18+
image: 'index.docker.io/semgrep/semgrep@sha256:85782eaf09692e6dfb684cd3bad87ef315775814b01f76b4d15582e4ca7c1c89' # ratchet:semgrep/semgrep
1919

2020
# Skip any PR created by dependabot to avoid permission issues:
2121
if: (github.actor != 'dependabot[bot]')
2222

2323
steps:
24-
- name: Checkout Code
25-
uses: actions/checkout@v4
26-
27-
- name: Checkout Workflow Config
28-
uses: actions/checkout@v4
24+
- name: 'Checkout Code'
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
26+
27+
- name: 'Checkout Workflow Config'
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
2929
env:
3030
GH_REPO_OWNER: ${{ github.repository_owner }}
3131
with:
3232
repository: 'google/github-team'
3333
path: action_scanning
34-
35-
- name: Run Actions semgrep scan
36-
run: semgrep scan --sarif --config action_scanning/semgrep-rules/actions >> semgrep-results-actions.sarif
37-
38-
- name: Save Actions SARIF results as artifact
39-
uses: actions/upload-artifact@v4
34+
35+
- name: 'Run Actions semgrep scan'
36+
run: 'semgrep scan --sarif --config action_scanning/semgrep-rules/actions >> semgrep-results-actions.sarif'
37+
38+
- name: 'Save Actions SARIF results as artifact'
39+
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
4040
with:
41-
name: semgrep-scan-results-actions
42-
path: semgrep-results-actions.sarif
43-
44-
- name: Upload Actions SARIF result to the GitHub Security Dashboard
45-
uses: github/codeql-action/upload-sarif@v3
41+
name: 'semgrep-scan-results-actions'
42+
path: 'semgrep-results-actions.sarif'
43+
44+
- name: 'Upload Actions SARIF result to the GitHub Security Dashboard'
45+
uses: 'github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841' # ratchet:github/codeql-action/upload-sarif@v3
4646
with:
47-
sarif_file: semgrep-results-actions.sarif
47+
sarif_file: 'semgrep-results-actions.sarif'
4848
if: always()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Ensure that our local testing always passes
2+
name: Run semver tests
3+
4+
on:
5+
pull_request: {}
6+
7+
permissions:
8+
contents: read
9+
actions: read
10+
11+
jobs:
12+
semgrep-tests:
13+
name: Run semgrep tests
14+
runs-on: ubuntu-latest
15+
16+
container:
17+
image: semgrep/semgrep
18+
19+
# Skip any PR created by dependabot to avoid permission issues:
20+
if: (github.actor != 'dependabot[bot]')
21+
22+
steps:
23+
- name: Checkout Code
24+
uses: actions/checkout@v4
25+
26+
- name: Run Actions semgrep scan
27+
run: semgrep --test --config semgrep-rules semgrep-tests

semgrep-rules/actions/pull_request_target_needs_exception.yml renamed to semgrep-rules/actions/pull_request_target_needs_exception.yaml

File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
on:
2+
# ruleid: pull-request-target-needs-exception
3+
pull_request_target:

0 commit comments

Comments
 (0)