Skip to content

Commit cfaf9b1

Browse files
Add Snyk security workflow to track multiple tags
1 parent 17dc2f7 commit cfaf9b1

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/release.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,22 @@ on:
2727
type: string
2828
default: "project-codeflare"
2929

30+
env:
31+
PR_BRANCH_NAME: snyk-tag-monitoring-${{ github.run_id }}
32+
3033
jobs:
3134
release:
3235
runs-on: ubuntu-latest
3336
permissions:
3437
contents: write
3538
id-token: write # This permission is required for trusted publishing
39+
pull-requests: write # This permission is required for creating PRs
3640
steps:
3741
- name: Checkout the repository
3842
uses: actions/checkout@v4
43+
with:
44+
submodules: recursive
45+
token: ${{ secrets.GH_CLI_TOKEN }}
3946
- name: Install Python
4047
uses: actions/setup-python@v5
4148
with:
@@ -81,3 +88,32 @@ jobs:
8188
env:
8289
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
8390
shell: bash
91+
92+
- name: Append tag to Snyk monitoring list
93+
run: |
94+
sed -i 's/list_of_released_tags=(/list_of_released_tags=("v${{ github.event.inputs.release-version }}", /' .github/workflows/snyk-security.yaml
95+
96+
- name: Commit and push changes
97+
run: |
98+
git config --global user.email "[email protected]"
99+
git config --global user.name "codeflare-machine-account"
100+
git checkout -b $PR_BRANCH_NAME
101+
git commit -am "Update snyk-security.yaml"
102+
git push --set-upstream origin "$PR_BRANCH_NAME"
103+
104+
- name: Create Pull Request
105+
run: |
106+
gh pr create \
107+
--title "$pr_title" \
108+
--body "$pr_body" \
109+
--head ${{ env.PR_BRANCH_NAME }} \
110+
--base main \
111+
--label "lgtm" \
112+
--label "approved"
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GH_CLI_TOKEN }}
115+
pr_title: "[CodeFlare-Machine] Append tag v${{ github.event.inputs.release-version }} to Snyk monitoring list"
116+
pr_body: |
117+
:rocket: This is an automated Pull Request generated by [release.yaml](https://github.com/project-codeflare/codeflare-sdk/blob/main/.github/workflows/release.yaml) workflow.
118+
119+
This PR appends to the list of tags that Snyk will be monitoring.

.github/workflows/snyk-security.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Snyk Security
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
snyk-scan:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
submodules: recursive
15+
16+
- name: Install Snyk CLI
17+
run: npm install -g snyk
18+
19+
- name: Snyk Monitor and Test multiple projects
20+
env:
21+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
22+
SNYK_ORG: ${{ secrets.SNYK_ORG }}
23+
run: |
24+
echo "Fetching tags"
25+
git fetch origin 'refs/tags/*:refs/tags/*'
26+
27+
echo "Authenticating with Snyk"
28+
snyk auth ${SNYK_TOKEN}
29+
30+
echo "Scanning project: codeflare-sdk/main"
31+
snyk monitor --all-projects --exclude=requirements.txt --org=${SNYK_ORG} --target-reference="main"
32+
33+
# This list is based off RHOAI Supported versions: https://access.redhat.com/support/policy/updates/rhoai-sm/lifecycle
34+
# Compared to the tags in the ImageStream annotations: https://github.com/red-hat-data-services/notebooks/blob/rhoai-2.8/manifests/base/jupyter-datascience-notebook-imagestream.yaml
35+
# Loop through the list of released tags and scan each project
36+
list_of_released_tags=("v0.22.0" "v0.21.1" "v0.19.1", "v0.16.4", "vv0.14.1")
37+
for project in "${list_of_released_tags[@]}"; do
38+
echo "Scanning project: codeflare-sdk/$project"
39+
git checkout $project
40+
snyk monitor --all-projects --exclude=requirements.txt --org=${SNYK_ORG} --target-reference="$(git describe --tags)"
41+
done

0 commit comments

Comments
 (0)