@@ -2,13 +2,8 @@ name: VulnDB Workflow
22
33on :
44 workflow_dispatch :
5- inputs :
6- run_generate_snapshot :
7- description : " Run generate snapshot job"
8- required : false
9- default : " false"
105 schedule :
11- - cron : " 0 */6 * * *" # every hour
6+ - cron : " 0 */1 * * *"
127
138permissions :
149 contents : read
1914 POSTGRES_USER : devguard
2015 POSTGRES_HOST : localhost
2116 POSTGRES_PASSWORD : not_reachable_from_the_internet
22- DATE : $(date +%s)
2317
2418jobs :
2519 build :
@@ -28,14 +22,14 @@ jobs:
2822 FRONTEND_URL : " doesntmatter"
2923 services :
3024 postgres :
31- image : ghcr.io/l3montree-dev/devguard- postgresql:v0.5.3@sha256:a06c9e7c8ee334790cc66d52e89ff5ef05352ab264841d3d9f3659c046732251
25+ image : ghcr.io/l3montree-dev/devguard/ postgresql:v1.3.1
3226 env :
3327 POSTGRES_DB : ${{env.POSTGRES_DB}}
3428 POSTGRES_USER : ${{env.POSTGRES_USER}}
3529 POSTGRES_PASSWORD : ${{env.POSTGRES_PASSWORD}}
3630 ports :
3731 - 5432:5432
38- options : ' --health-cmd="pg_isready -U devguard" --health-interval=10s --health-timeout=5s --health-retries=5 '
32+ options : ' --health-cmd="pg_isready -U devguard" --health-interval=10s --health-timeout=5s --health-retries=5 --tmpfs /docker-entrypoint-initdb.d --tmpfs /run/postgresql '
3933 steps :
4034 - name : Install postgresql client
4135 run : |
@@ -56,39 +50,11 @@ jobs:
5650 uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - https://github.com/actions/setup-go/releases/tag/v5.5.0
5751 with :
5852 go-version : " 1.25"
59- - name : Build the database (this takes some time)
53+ - name : Export the vulnerability database archive
6054 run : |
61- # will fetch the latest build database from ghcr.io
62- go run ./cmd/devguard-cli/main.go vulndb sync
63-
64- - name : Dump the PostgreSQL database
65- if : ${{ github.event.inputs.run_generate_snapshot == 'true' }}
66- # skip:checkov:CKV_SECRET_6
67- run : |
68- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM affected_components) TO STDOUT WITH DELIMITER ',' CSV HEADER" > affected_components.csv
69- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM cve_affected_component) TO STDOUT WITH DELIMITER ',' CSV HEADER" > cve_affected_component.csv
70- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM cves) TO STDOUT WITH DELIMITER ',' CSV HEADER" > cves.csv
71- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM cwes) TO STDOUT WITH DELIMITER ',' CSV HEADER" > cwes.csv
72- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM exploits) TO STDOUT WITH DELIMITER ',' CSV HEADER" > exploits.csv
73- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM malicious_packages) TO STDOUT WITH DELIMITER ',' CSV HEADER" > malicious_packages.csv
74- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM malicious_affected_components) TO STDOUT WITH DELIMITER ',' CSV HEADER" > malicious_affected_components.csv
75- # PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM weaknesses) TO STDOUT WITH DELIMITER ',' CSV HEADER" > weaknesses.csv
76- PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -h localhost -U devguard devguard -c "COPY (SELECT * FROM cve_relationships) TO STDOUT WITH DELIMITER ',' CSV HEADER" > cve_relationships.csv
77- - name : Export the diff csv files (this does not take some time)
78- if : ${{ github.event.inputs.run_generate_snapshot == 'false' || github.event.inputs.run_generate_snapshot == '' }}
79- run : |
80- # writes the difference from the db before and after the sync into csv files
55+ # writes the database snapshot files and bundles them into a single tar.zst archive
8156 go run ./cmd/devguard-cli/main.go vulndb export
8257
83- - name : install zip
84- run : sudo apt-get install zip
85-
86- - name : Zip the CSV files
87- if : ${{ github.event.inputs.run_generate_snapshot == 'true' }}
88- run : zip vulndb.zip affected_components.csv cve_affected_component.csv cves.csv cwes.csv exploits.csv malicious_packages.csv malicious_affected_components.csv cve_relationships.csv
89- - name : Zip the CSV files
90- if : ${{ github.event.inputs.run_generate_snapshot == 'false' || github.event.inputs.run_generate_snapshot == '' }}
91- run : zip -r vulndb.zip diffs-tmp
9258 - name : Install Cosign
9359 uses : sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
9460 with :
@@ -97,10 +63,12 @@ jobs:
9763 - name : Write signing key to disk
9864 run : echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
9965
100- - name : Sign the database zip file
66+ - name : Sign the database archive
10167 env :
10268 COSIGN_PASSWORD : " "
103- run : cosign import-key-pair --key cosign.key && cosign sign-blob --yes --key import-cosign.key vulndb.zip > vulndb.zip.sig
69+ run : |
70+ cosign import-key-pair --key cosign.key
71+ cosign sign-blob --yes --key import-cosign.key vulndb.tar.zst > vulndb.tar.zst.sig
10472 - name : Login to GitHub Container Registry
10573 uses : docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
10674 with :
@@ -110,23 +78,11 @@ jobs:
11078 - name : Setup oras cli
11179 uses : oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1
11280
113- - name : set the date
114- run : echo "date="${{env.DATE}} >> "$GITHUB_ENV"
115-
116- - name : Push the database ZIP file to GitHub Container Registry (vulndb/v1)
117- if : ${{ github.event.inputs.run_generate_snapshot == 'false' || github.event.inputs.run_generate_snapshot == '' }}
118- run : |
119- oras push ghcr.io/l3montree-dev/devguard/vulndb/v1:$date vulndb.zip
120-
121- - name : Push the database ZIP file to GitHub Container Registry (snapshot)
122- if : ${{ github.event.inputs.run_generate_snapshot == 'true' }}
123- run : |
124- oras push ghcr.io/l3montree-dev/devguard/vulndb/v1:$date-snapshot vulndb.zip
125- - name : Push the signatures to the GitHub Container Registry
126- if : ${{ github.event.inputs.run_generate_snapshot == 'false' || github.event.inputs.run_generate_snapshot == '' }}
81+ - name : Push the database archive to GitHub Container Registry
12782 run : |
128- oras push ghcr.io/l3montree-dev/devguard/vulndb/v1:$date.sig vulndb.zip.sig
129- - name : Push the signatures to the GitHub Container Registry (snapshot)
130- if : ${{ github.event.inputs.run_generate_snapshot == 'true' }}
83+ oras push ghcr.io/l3montree-dev/devguard/vulndb/v2:latest \
84+ vulndb.tar.zst
85+ - name : Push the archive signature to the GitHub Container Registry
13186 run : |
132- oras push ghcr.io/l3montree-dev/devguard/vulndb/v1:$date-snapshot.sig vulndb.zip.sig
87+ oras push ghcr.io/l3montree-dev/devguard/vulndb/v2:latest.sig \
88+ vulndb.tar.zst.sig
0 commit comments