Skip to content

Commit af5e10c

Browse files
committed
added CVE scan on Sundays after daily build, cleanup some stuff
1 parent 40841c8 commit af5e10c

File tree

7 files changed

+97
-20
lines changed

7 files changed

+97
-20
lines changed

.github/workflows/daily_build.yml

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Create Daily Build'
2-
# concurrency:
3-
# group: ${{ github.workflow }}-${{ github.ref_name }}
4-
# cancel-in-progress: true
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref_name }}
4+
cancel-in-progress: true
55

66
on:
77
repository_dispatch:
@@ -14,7 +14,6 @@ on:
1414
description: "Date to build packages for (YYYYMMDD)"
1515
required: false
1616

17-
1817
jobs:
1918
DailyBuildVariables:
2019
runs-on: ["self-hosted"]
@@ -56,7 +55,7 @@ jobs:
5655
payload="{\"date\": ${build_date}}"
5756
fi
5857
echo "Received payload: $payload"
59-
read mage_version memgraph_version memgraph_commit build_date < <(python3 daily_build_vars.py "$payload")
58+
read mage_version memgraph_version memgraph_commit build_date < <(python3 scripts/daily_build_vars.py "$payload")
6059
echo "mage_version=${mage_version}" >> $GITHUB_OUTPUT
6160
echo "memgraph_version=${memgraph_version}" >> $GITHUB_OUTPUT
6261
echo "memgraph_commit=${memgraph_commit}" >> $GITHUB_OUTPUT
@@ -143,7 +142,7 @@ jobs:
143142
run: |
144143
echo "TEST_RESULT: $TEST_RESULT"
145144
echo "Package Date: $CURRENT_BUILD_DATE"
146-
echo "BUILD_TEST_RESULTS=$(python3 aggregate_build_tests.py)" >> $GITHUB_ENV
145+
echo "BUILD_TEST_RESULTS=$(python3 scripts/aggregate_build_tests.py)" >> $GITHUB_ENV
147146
148147
- name: Trigger Daily Builds Page Update
149148
env:
@@ -157,4 +156,65 @@ jobs:
157156
-H "Authorization: token $GITHUB_TOKEN" \
158157
https://api.github.com/repos/memgraph/daily-builds/dispatches \
159158
-d "$payload"
160-
159+
160+
SetupCVEScan:
161+
name: Setup CVE Scan
162+
runs-on: ubuntu-latest
163+
needs: [DailyBuildVariables, DailyBuildArtifact]
164+
outputs:
165+
amd_url: ${{ steps.image_urls.outputs.AMD_URL }}
166+
arm_url: ${{ steps.image_urls.outputs.ARM_URL }}
167+
run_scan: ${{ steps.sunday.outputs.RUN_SCAN }}
168+
steps:
169+
- name: Checkout repository and submodules
170+
uses: actions/checkout@v4
171+
with:
172+
fetch-depth: 0
173+
submodules: recursive
174+
token: ${{ secrets.GITHUB_TOKEN }}
175+
176+
- name: Is today Sunday? 🤔
177+
id: sunday
178+
run: |
179+
day="$(date -u +%A)"
180+
if [[ "$day" == "Sunday" ]]; then
181+
echo "RUN_SCAN=true" >> $GITHUB_OUTPUT
182+
else
183+
echo "RUN_SCAN=false" >> $GITHUB_OUTPUT
184+
fi
185+
186+
187+
- name: Fetch URLS
188+
id: image_urls
189+
env:
190+
CURRENT_BUILD_DATE: ${{ needs.DailyBuildVariables.outputs.build_date }}
191+
run: |
192+
arm_url="$(python3 scripts/get_cve_image_url 'arm64')"
193+
amd_url="$(python3 scripts/get_cve_image_url 'amd64')"
194+
195+
echo "arm64 URL: $arm_url"
196+
echo "amd64 URL: $amd_url"
197+
198+
echo "ARM_URL=$arm_url" >> $GITHUB_OUTPUT
199+
echo "AMD_URL=$amd_url" >> $GITHUB_OUTPUT
200+
201+
RunCVEScan:
202+
name: Run CVE Scan
203+
needs: [SetupCVEScan]
204+
if: ${{ needs.SetupCVEScan.outputs.run_scan == 'true' }}
205+
strategy:
206+
fail-fast: false
207+
matrix:
208+
include:
209+
- arch: arm64
210+
image_url: needs.SetupCVEScan.outputs.arm_url
211+
- arch: amd64
212+
image_url: needs.SetupCVEScan.outputs.amd_url
213+
uses: ./.github/workflows/reusable_cve_scan.yml
214+
with:
215+
arch: ${{ matrix.arch }}
216+
image_url: ${{ matrix.image_url }}
217+
run_trivy: true
218+
run_grype: true
219+
run_cbt: true
220+
secrets: inherit

.github/workflows/reusable_smoke_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ jobs:
4242

4343
- name: Determine Input Types
4444
run: |
45-
read next_type next_image < <(python3 smoke-release-testing/workflow_image_setup.py "${{ inputs.next_version }}" "${{ inputs.arch }}" "${{ inputs.malloc }}")
45+
read next_type next_image < <(python3 scripts/workflow_image_setup.py "${{ inputs.next_version }}" "${{ inputs.arch }}" "${{ inputs.malloc }}")
4646
echo "NEXT_IMAGE=${next_image}" >> $GITHUB_ENV
4747
echo "NEXT_TYPE=${next_type}" >> $GITHUB_ENV
48-
read last_type last_image < <(python3 smoke-release-testing/workflow_image_setup.py "${{ inputs.last_version }}" "${{ inputs.arch }}" "${{ inputs.malloc }}")
48+
read last_type last_image < <(python3 scripts/workflow_image_setup.py "${{ inputs.last_version }}" "${{ inputs.arch }}" "${{ inputs.malloc }}")
4949
echo "LAST_IMAGE=${last_image}" >> $GITHUB_ENV
5050
echo "LAST_TYPE=${last_type}" >> $GITHUB_ENV
5151

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Compute variables using Python script
6767
id: compute
6868
run: |
69-
read mage_version memgraph_version memgraph_commit build_date < <(python3 daily_build_vars.py)
69+
read mage_version memgraph_version memgraph_commit build_date < <(python3 scripts/daily_build_vars.py)
7070
echo "mage_version=${mage_version}" >> $GITHUB_OUTPUT
7171
echo "memgraph_version=${memgraph_version}" >> $GITHUB_OUTPUT
7272
echo "memgraph_commit=${memgraph_commit}" >> $GITHUB_OUTPUT
File renamed without changes.
File renamed without changes.

scripts/get_cve_image_url.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from aggregate_build_tests import list_daily_release_packages
2+
import os
3+
import argparse
4+
5+
6+
def main() -> None:
7+
"""
8+
return the relevant image URL to be scanned for CVEs
9+
"""
10+
date = int(os.getenv("CURRENT_BUILD_DATE"))
11+
12+
parser = argparse.ArgumentParser()
13+
parser.add_argument("arch", type=str)
14+
args = parser.parse_args()
15+
16+
# translate to dict key
17+
key, arch = ("Docker (arm64)", "arm64") if args.arch == "arm64" else ("Docker (x86_64)", "x86_64")
18+
19+
packages = list_daily_release_packages(date)
20+
url = packages[key][arch]
21+
22+
print(url)
23+
24+
25+
if __name__ == "__main__":
26+
main()

smoke-release-testing/workflow_image_setup.py renamed to scripts/workflow_image_setup.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
import sys
2-
import os
31
import re
42
import argparse
5-
# add mage root dir to python path to find other functions
6-
# TODO(matt): refactor workflow helper scripts like this into subdirectory
7-
sys.path.append(
8-
os.path.dirname(
9-
os.path.dirname(__file__)
10-
)
11-
)
12-
from aggregate_build_tests import list_daily_release_packages # noqa: E402
3+
from aggregate_build_tests import list_daily_release_packages
134

145
# Compile regex patterns
156
URL_PATTERN = re.compile(

0 commit comments

Comments
 (0)