Skip to content

Commit a2cc221

Browse files
authored
chore: Add OWASP Cache (#188)
1 parent 918e12c commit a2cc221

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/fosstars-report.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ jobs:
2222
distribution: "temurin"
2323
java-version: ${{ env.JAVA_VERSION }}
2424
cache: 'maven'
25+
- name: Restore CVE Database
26+
uses: actions/cache/restore@v4
27+
with:
28+
path: ${{ env.CVE_CACHE_DIR }}
29+
key: ${{ env.CVE_CACHE_KEY }}
30+
fail-on-cache-miss: true
2531

2632
- name: "Build SDK"
2733
run: |
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Update Vulnerability Database
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '42 03 * * MON-FRI' # 03:42 on weekdays, a somewhat random time to avoid producing load spikes on the GH actions infrastructure
7+
8+
env:
9+
CVE_CACHE_REF: refs/heads/main
10+
CVE_CACHE_KEY: cve-db
11+
CVE_CACHE_DIR: ~/.m2/repository/org/owasp/dependency-check-data
12+
13+
jobs:
14+
update-vulnerability-database:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ env.CVE_CACHE_REF }}
22+
- name: Restore Existing Cache
23+
uses: actions/cache/restore@v4
24+
with:
25+
path: ${{ env.CVE_CACHE_DIR }}
26+
key: ${{ env.CVE_CACHE_KEY }}
27+
28+
- name: Run Maven Plugin
29+
run: |
30+
mvn org.owasp:dependency-check-maven:10.0.4:update-only -DnvdMaxRetryCount=10 -DnvdApiDelay=15000 -DconnectionTimeout=60000
31+
env:
32+
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
33+
34+
- name: Delete Cache
35+
run: |
36+
CACHE_IDS=$(gh cache list --key "${{ env.CVE_CACHE_KEY }}" --ref "${{ env.CVE_CACHE_REF }}" --json id | jq -r '.[] | .id')
37+
for CACHE_ID in $CACHE_IDS; do
38+
echo "Deleting cache with ID: $CACHE_ID"
39+
gh cache delete "${CACHE_ID}"
40+
done
41+
env:
42+
GH_TOKEN: ${{ secrets.CLOUD_SDK_AT_SAP_ALL_ACCESS_PAT }}
43+
44+
- name: Cache CVE Database
45+
uses: actions/cache/save@v4
46+
with:
47+
path: ${{ env.CVE_CACHE_DIR }}
48+
key: ${{ env.CVE_CACHE_KEY }}
49+
50+
# - name: "Slack Notification"
51+
# if: failure()
52+
# uses: slackapi/[email protected]
53+
# with:
54+
# payload: |
55+
# {
56+
# "text": "⚠️ OWASP Update Failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
57+
# }
58+
# env:
59+
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
60+
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
61+
62+

0 commit comments

Comments
 (0)