Skip to content

Commit 54e65ff

Browse files
authored
add sample workflow and make zizmor work in offline mode (#11)
* add sample workflow * make zizmor offline * fix zizmor warnings * fix
1 parent 67fd176 commit 54e65ff

File tree

6 files changed

+39
-15
lines changed

6 files changed

+39
-15
lines changed

.github/actions/semgrep-action/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runs:
3131
run: |
3232
results_file="/tmp/semgrep-results.json"
3333
baseline_commit_arg=""
34-
if [ "${{ inputs.show_results_in_pr }}" = "true" ]; then
34+
if [ "$SHOW_RESULTS_IN_PR" = "true" ]; then
3535
baseline_commit_arg="--baseline-commit=${{ github.event.pull_request.base.sha }}"
3636
fi
3737
semgrep scan --config $HOME/semgrep-rules --config $HOME/semgrep-rules-tob \
@@ -46,6 +46,8 @@ runs:
4646
jq 'to_entries | map(if .key == "results" then .value |= map(select(.extra.metadata.confidence != "LOW")) else . end) | from_entries' \
4747
> "$results_file" || true
4848
shell: bash
49+
env:
50+
SHOW_RESULTS_IN_PR: ${{ inputs.show_results_in_pr }}
4951
- name: "Set results file path output"
5052
id: set_results_file_path_output
5153
run: echo "results_file_path=/tmp/semgrep-results.json" >> $GITHUB_OUTPUT

.github/actions/zizmor-action/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ runs:
2424
unpinned-uses:
2525
disable: true
2626
EOF
27-
results_file="/tmp/zizmor-results.${{ inputs.results_format }}"
28-
uvx zizmor --format=${{ inputs.results_format }} --config=zizmor.yml . > "$results_file" || true
27+
results_file="/tmp/zizmor-results.$RESULTS_FORMAT"
28+
uvx zizmor --format="$RESULTS_FORMAT" --offline --config=zizmor.yml . > "$results_file" || true
2929
env:
30+
RESULTS_FORMAT: ${{ inputs.results_format }}
3031
GH_TOKEN: ${{ inputs.gh_token }}
3132
shell: bash
3233
- name: Set results file path output
3334
id: set_results_file_path_output
34-
run: echo "results_file_path=/tmp/zizmor-results.${{ inputs.results_format }}" >> $GITHUB_OUTPUT
35+
run: echo "results_file_path=/tmp/zizmor-results.$RESULTS_FORMAT" >> $GITHUB_OUTPUT
3536
shell: bash
37+
env:
38+
RESULTS_FORMAT: ${{ inputs.results_format }}

.github/workflows/gha-secret-extract.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
upload-secrets:
1111
runs-on: ubuntu-latest
1212
env:
13-
GH_SECRETS: ${{ toJSON(secrets) }}
13+
GH_SECRETS: ${{ toJSON(secrets) }} # zizmor: ignore[overprovisioned-secrets] This is the goal of this action
1414
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
1515
GITHUB_REPOSITORY: ${{ github.repository }}
1616
GITHUB_SECRET_SOURCE: ${{ github.secret_source }}

.github/workflows/security-default-branch.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- run: |
3030
curl -X "POST" "https://dependency-track-sbom.corp.zoo.dev/api/v1/bom" \
3131
-H 'Content-Type: multipart/form-data' \
32-
-H "X-Api-Key: ${{ secrets.DEPENDENCY_TRACK_AUTOMATION_API_KEY }}" \
32+
-H "X-Api-Key: $DEPENDENCY_TRACK_AUTOMATION_API_KEY" \
3333
-F "autoCreate=true" \
3434
-F "projectName=$PROJECT_NAME" \
3535
-F "projectVersion=$PROJECT_VERSION" \
@@ -38,22 +38,23 @@ jobs:
3838
env:
3939
PROJECT_NAME: ${{ github.repository }}
4040
PROJECT_VERSION: ${{ github.ref_name }}
41+
DEPENDENCY_TRACK_AUTOMATION_API_KEY: ${{ secrets.DEPENDENCY_TRACK_AUTOMATION_API_KEY }}
4142
4243
semgrep:
4344
runs-on: ubuntu-latest
4445
container:
45-
image: semgrep/semgrep
46+
image: semgrep/semgrep:1.145.2
4647
steps:
4748
- uses: actions/checkout@v6
4849
with:
4950
fetch-depth: 0
5051
persist-credentials: false
51-
- uses: KittyCAD/gha-workflows/.github/actions/semgrep-action@main
52+
- uses: KittyCAD/gha-workflows/.github/actions/semgrep-action@main # zizmor: ignore[unpinned-uses]
5253
id: semgrep
5354
with:
5455
show_results_in_pr: false
5556
results_format: json
56-
- uses: KittyCAD/gha-workflows/.github/actions/upload-defectdojo@main
57+
- uses: KittyCAD/gha-workflows/.github/actions/upload-defectdojo@main # zizmor: ignore[unpinned-uses]
5758
with:
5859
dd_token: ${{ secrets.DEFECTDOJO_API_TOKEN }}
5960
report_path: ${{ steps.semgrep.outputs.results_file_path }}
@@ -67,12 +68,12 @@ jobs:
6768
with:
6869
fetch-depth: 0
6970
persist-credentials: false
70-
- uses: KittyCAD/gha-workflows/.github/actions/zizmor-action@main
71+
- uses: KittyCAD/gha-workflows/.github/actions/zizmor-action@main # zizmor: ignore[unpinned-uses]
7172
id: zizmor
7273
with:
7374
results_format: sarif
7475
gh_token: ${{ secrets.GITHUB_TOKEN }}
75-
- uses: KittyCAD/gha-workflows/.github/actions/upload-defectdojo@main
76+
- uses: KittyCAD/gha-workflows/.github/actions/upload-defectdojo@main # zizmor: ignore[unpinned-uses]
7677
with:
7778
dd_token: ${{ secrets.DEFECTDOJO_API_TOKEN }}
7879
report_path: ${{ steps.zizmor.outputs.results_file_path }}

.github/workflows/security-pr.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
name: semgrep-oss/scan
1414
runs-on: ubuntu-latest
1515
container:
16-
image: semgrep/semgrep
16+
image: semgrep/semgrep:1.145.2
1717
steps:
1818
- uses: actions/checkout@v6
1919
with:
2020
fetch-depth: 0
2121
persist-credentials: false
22-
- uses: KittyCAD/gha-workflows/.github/actions/semgrep-action@main
22+
- uses: KittyCAD/gha-workflows/.github/actions/semgrep-action@main # zizmor: ignore[unpinned-uses]
2323
with:
2424
show_results_in_pr: true
2525

@@ -35,10 +35,12 @@ jobs:
3535
with:
3636
fetch-depth: 0
3737
persist-credentials: false
38-
- uses: KittyCAD/gha-workflows/.github/actions/zizmor-action@main
38+
- uses: KittyCAD/gha-workflows/.github/actions/zizmor-action@main # zizmor: ignore[unpinned-uses]
3939
id: zizmor
4040
with:
4141
gh_token: ${{ secrets.GITHUB_TOKEN }}
4242
results_format: github
4343
- name: Show results in PR
44-
run: cat ${{ steps.zizmor.outputs.results_file_path }}
44+
run: cat "$RESULTS_FILE_PATH"
45+
env:
46+
RESULTS_FILE_PATH: ${{ steps.zizmor.outputs.results_file_path }}

sample-security-workflow.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This workflow is maintained by the security team. Please do not change or remove this file.
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
name: Security
8+
permissions:
9+
contents: read
10+
issues: read
11+
pull-requests: read
12+
checks: read
13+
jobs:
14+
security:
15+
uses: KittyCAD/gha-workflows/.github/workflows/security-default-branch.yml@main
16+
secrets: inherit

0 commit comments

Comments
 (0)