Skip to content

Commit eddb861

Browse files
authored
chore: Update snyk monitor scan to use Grafana's GH action (#5561)
# What this PR does Changes the Snyk Monitoring to use Grafana's [Action](https://github.com/grafana/security-github-actions) The current setup prevents Snyk from running on forks and blocks contributions because of the `id-token: write` permission
1 parent 79a46b0 commit eddb861

File tree

2 files changed

+14
-51
lines changed

2 files changed

+14
-51
lines changed

.github/workflows/on-pull-requests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ jobs:
1818
linting-and-tests:
1919
name: Linting and tests
2020
uses: ./.github/workflows/linting-and-tests.yml
21-
22-
snyk-security-scan:
23-
name: Snyk security scan
24-
uses: ./.github/workflows/snyk-security-scan.yml
25-
secrets: inherit
Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,17 @@
1-
name: Snyk security scan
2-
1+
name: Snyk Monitor Scanning
32
on:
4-
workflow_call:
3+
release:
4+
types: [published]
5+
push:
6+
branches:
7+
- 'main'
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
512

613
jobs:
7-
snyk-security-scan:
8-
name: Snyk security scan
9-
runs-on: ubuntu-latest
10-
# see this PR regarding the permissions needed for this workflow
11-
# https://github.com/snyk/actions/pull/79
12-
permissions:
13-
# required for all workflows
14-
security-events: write
15-
# only required for workflows in private repositories
16-
actions: read
17-
contents: read
18-
# required for Vault secrets
19-
id-token: write
20-
steps:
21-
- uses: actions/checkout@v4
22-
- name: Setup Python
23-
uses: ./.github/actions/setup-python
24-
- name: Install frontend dependencies
25-
uses: ./.github/actions/install-frontend-dependencies
26-
- name: Get Vault secrets
27-
uses: grafana/shared-workflows/actions/get-vault-secrets@b7d33d6a98dc9cf332674c6cdebe92b8bcb05670 #v0.3.0
28-
with:
29-
common_secrets: |
30-
SNYK_TOKEN=snyk_scan_github_action:token
31-
- name: Install Snyk
32-
uses: snyk/actions/setup@b98d498629f1c368650224d6d212bf7dfa89e4bf #v0.4.0
33-
# NOTE: on the snyk monitor and snyk test commands, we are excluding the dev and tools directories
34-
# because we can't install the requirements.txt files of these directories alongside the main engine
35-
# requirements.txt (some conflicting dep versions). If we realllly wanted to test these, we should do it
36-
# as a seperate job and setup a separate Python env w/ just the deps of those projects. Since these projects
37-
# are really just dev/internal scripts we don't really need to worry about them for now
38-
- name: snyk monitor
39-
# https://docs.snyk.io/snyk-cli/commands/monitor
40-
run: snyk monitor --all-projects --severity-threshold=high --exclude=dev,tools
41-
- name: snyk test
42-
# https://docs.snyk.io/snyk-cli/commands/test
43-
# yamllint disable rule:line-length
44-
run: snyk test --all-projects --severity-threshold=high --exclude=dev,tools --fail-on=all --show-vulnerable-paths=all
45-
# yamllint enable rule:line-length
46-
# TODO: setup snyk container monitor & snyk container test
47-
# will require building the docker image and storing it in the local docker registry..
48-
# will need to refactor .github/workflows/build-engine-docker-image-and-publish-to-dockerhub.yml
49-
# to be a composable action instead of a workflow
14+
snyk-scan-ci:
15+
uses: 'grafana/security-github-actions/.github/workflows/snyk_monitor.yml@main'
16+
secrets:
17+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

0 commit comments

Comments
 (0)