Skip to content

Commit 407842a

Browse files
authored
Merge pull request wazuh#29354 from wazuh/enhancement/29315-python-vulns-analysis-workflow
Add Python dependency vulnerability checks for non-default branches
2 parents 4a9cd0b + 00a43ca commit 407842a

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Python vulnerability checks'
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
jobs:
7+
pick-branches:
8+
name: Get branches to analyze
9+
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ steps.set-matrix.outputs.matrix }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Generate dynamic matrix
18+
id: set-matrix
19+
run: |
20+
VERSIONED_BRANCHES_REGEX="^main$|^[0-9]{1,3}\.[0-9]{2}\.[0-9]{1,2}$"
21+
22+
BRANCHES=$(git branch -r | awk '{print $1}' | sed 's|origin/||' | grep -E "$VERSIONED_BRANCHES_REGEX")
23+
24+
JSON_ARRAY=$(printf '%s\n' "$BRANCHES" | while read -r ref; do
25+
sha=$(git rev-parse "origin/$ref")
26+
jq -c -n --arg ref "$ref" --arg sha "$sha" '{ref: $ref, sha: $sha}'
27+
done | jq -c -s '{include: .}')
28+
29+
echo "matrix=$JSON_ARRAY" >> "$GITHUB_OUTPUT"
30+
echo Picked branches: $JSON_ARRAY
31+
32+
checking-py-vulns:
33+
needs: pick-branches
34+
name: Checking Python vulnerabilies
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix: ${{ fromJSON(needs.pick-branches.outputs.matrix) }}
38+
permissions:
39+
contents: read
40+
security-events: write
41+
actions: read
42+
steps:
43+
- name: Checkout the repo
44+
uses: actions/checkout@v4
45+
with:
46+
ref: ${{ matrix.ref }}
47+
fetch-depth: 0
48+
49+
- name: Run Trivy vulnerability scanner
50+
uses: aquasecurity/[email protected]
51+
with:
52+
scan-type: 'fs'
53+
scanners: 'vuln'
54+
format: 'sarif'
55+
output: 'trivy-results.sarif'
56+
57+
- name: Upload Trivy scan results to GitHub Security tab
58+
uses: github/codeql-action/upload-sarif@v3
59+
with:
60+
ref: refs/heads/${{ matrix.ref }}
61+
sha: ${{ matrix.sha }}
62+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)