Skip to content

Commit 426d259

Browse files
add zizmor to run periodically (#36)
* add zizmor to run periodically * add correct permissions * use env * also include external repository input * use github-script to upload sarif results * fully fetch the repository * update git command * specify branch to checkout * change tool name * quote value * scan LGTM repos * change fetch-depth * remove pr trigger
1 parent e9d57d9 commit 426d259

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Periodic Zizmor
2+
3+
permissions: {}
4+
5+
on:
6+
schedule:
7+
# Set to run once a day at 10:00 UTC
8+
- cron: "0 10 * * *"
9+
10+
jobs:
11+
zizmor:
12+
name: Run zizmor
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
id-token: write
17+
strategy:
18+
matrix:
19+
repository:
20+
- owner: grafana
21+
repo: grafana
22+
ref: main
23+
- owner: grafana
24+
repo: loki
25+
ref: main
26+
- owner: grafana
27+
repo: tempo
28+
ref: main
29+
- owner: grafana
30+
repo: mimir
31+
ref: main
32+
env:
33+
ZIZMOR_VERSION: 1.6.0
34+
MIN_SEVERITY: high
35+
MIN_CONFIDENCE: low
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
with:
41+
persist-credentials: false
42+
43+
- name: Get GitHub App Secrets
44+
uses: grafana/shared-workflows/actions/[email protected]
45+
with:
46+
common_secrets: |
47+
ZIZMOR_APP_ID=zizmor:app-id
48+
ZIZMOR_PRIVATE_KEY=zizmor:private-key
49+
50+
- name: Authenticate App With GitHub
51+
uses: actions/create-github-app-token@v2
52+
id: get-token
53+
with:
54+
app-id: ${{ env.ZIZMOR_APP_ID }}
55+
private-key: ${{ env.ZIZMOR_PRIVATE_KEY }}
56+
owner: ${{ matrix.repository.owner }}
57+
repositories: |
58+
${{ matrix.repository.repo }}
59+
60+
- name: Checkout Target
61+
uses: actions/checkout@v4
62+
with:
63+
repository: ${{ matrix.repository.owner }}/${{ matrix.repository.repo }}
64+
token: ${{ steps.get-token.outputs.token }}
65+
path: target
66+
ref: ${{ matrix.repository.ref }}
67+
68+
- name: Setup UV
69+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
70+
with:
71+
enable-cache: true
72+
activate-environment: true
73+
cache-suffix: ${{ env.ZIZMOR_VERSION }}
74+
cache-dependency-glob: ""
75+
76+
- name: Run zizmor
77+
env:
78+
ZIZMOR_CACHE_DIR: ${{ runner.temp }}/.cache/zizmor
79+
REPOSITORY: ${{ matrix.repository.owner }}/${{ matrix.repository.repo }}
80+
GH_TOKEN: ${{ steps.get-token.outputs.token }}
81+
shell: sh
82+
run: >-
83+
uvx zizmor@"${ZIZMOR_VERSION}"
84+
--format sarif
85+
--min-severity "${MIN_SEVERITY}"
86+
--min-confidence "${MIN_CONFIDENCE}"
87+
--config .github/zizmor.yml
88+
./target
89+
> results.sarif
90+
91+
- name: Repository Info
92+
id: repo-info
93+
working-directory: ./target
94+
run: |
95+
SHA=$(git rev-parse HEAD)
96+
echo "sha=${SHA}" >> $GITHUB_OUTPUT
97+
98+
- name: Prepare SARIF results
99+
id: prepare-sarif
100+
run: |
101+
RESULTS=$(gzip -c results.sarif | base64 -w 0)
102+
echo "results=${RESULTS}" >> $GITHUB_OUTPUT
103+
104+
- name: Upload SARIF results
105+
uses: actions/github-script@v7
106+
env:
107+
OWNER: ${{ matrix.repository.owner }}
108+
REPO: ${{ matrix.repository.repo }}
109+
SHA: ${{ steps.repo-info.outputs.sha }}
110+
REF: refs/heads/${{ matrix.repository.ref }}
111+
SARIF_RESULTS: ${{ steps.prepare-sarif.outputs.results }}
112+
with:
113+
github-token: ${{ steps.get-token.outputs.token }}
114+
script: |
115+
const { OWNER, REPO, SHA, REF, SARIF_RESULTS } = process.env;
116+
117+
const response = await github.rest.codeScanning.uploadSarif({
118+
owner: OWNER,
119+
repo: REPO,
120+
commit_sha: SHA,
121+
ref: REF,
122+
sarif: SARIF_RESULTS,
123+
tool_name: "zizmor-centralized",
124+
});
125+
126+
console.log(response.status);

.github/zizmor.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
rules:
2+
unpinned-uses:
3+
config:
4+
policies:
5+
"*": hash-pin
6+
actions/*: any
7+
github/*: any
8+
grafana/*: any
9+
forbidden-uses:
10+
config:
11+
deny:
12+
# Policy-banned by our security team due to CVE-2025-30066 & CVE-2025-30154.
13+
# https://www.cisa.gov/news-events/alerts/2025/03/18/supply-chain-compromise-third-party-tj-actionschanged-files-cve-2025-30066-and-reviewdogaction
14+
# https://nvd.nist.gov/vuln/detail/cve-2025-30066
15+
# https://nvd.nist.gov/vuln/detail/cve-2025-30154
16+
- reviewdog/*

0 commit comments

Comments
 (0)