@@ -21,20 +21,80 @@ concurrency:
2121 cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
2222
2323jobs :
24+ # First job to discover all packages dynamically
25+ discover-packages :
26+ name : Discover Packages
27+ runs-on : ubuntu-latest
28+ outputs :
29+ matrix : ${{ steps.set-matrix.outputs.matrix }}
30+ steps :
31+ - if : github.actor == 'dependabot[bot]' || github.event_name == 'merge_group'
32+ run : exit 0
33+
34+ - uses : actions/checkout@v4
35+ with :
36+ ref : ${{ github.event.pull_request.head.sha || github.ref }}
2437
25- check :
38+ - name : Discover packages
39+ id : set-matrix
40+ run : |
41+ packages=$(find packages -maxdepth 1 -type d -name "auth0_*" | sed 's|^packages/||' | jq -R -s -c 'split("\n")[:-1]')
42+ echo "matrix={\"package\":$packages}" >> $GITHUB_OUTPUT
43+ echo "Found packages: $packages"
2644
27- name : Check for Vulnerabilities
45+ # Main security scanning job for each package
46+ security-scan :
47+ name : Security Scan (${{ matrix.package }})
2848 runs-on : ubuntu-latest
49+ needs : discover-packages
50+ if : needs.discover-packages.outputs.matrix != '{"package":[]}'
51+ strategy :
52+ fail-fast : false
53+ matrix : ${{ fromJson(needs.discover-packages.outputs.matrix) }}
2954
3055 steps :
3156 - if : github.actor == 'dependabot[bot]' || github.event_name == 'merge_group'
32- run : exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection.
57+ run : exit 0 # Skip unnecessary test runs for dependabot and merge queues
3358
3459 - uses : actions/checkout@v4
3560 with :
3661 ref : ${{ github.event.pull_request.head.sha || github.ref }}
3762
38- - uses : snyk/actions/python@b98d498629f1c368650224d6d212bf7dfa89e4bf # pin@0.4.0
63+ - name : Set up Python
64+ uses : actions/setup-python@v5
65+ with :
66+ python-version : ' 3.11'
67+
68+ - name : Prepare dependencies for Snyk scan
69+ working-directory : packages/${{ matrix.package }}
70+ run : |
71+ # Check if requirements.txt exists, if not, generate from Poetry
72+ if [ -f "requirements.txt" ]; then
73+ echo "Using existing requirements.txt for ${{ matrix.package }}"
74+ cp requirements.txt snyk-requirements.txt
75+ elif [ -f "pyproject.toml" ]; then
76+ echo "Generating requirements.txt from pyproject.toml for ${{ matrix.package }}"
77+ pip install poetry
78+ poetry export --format requirements.txt --output snyk-requirements.txt --without-hashes
79+ else
80+ echo "No dependency file found for ${{ matrix.package }}"
81+ exit 1
82+ fi
83+
84+ # Show what we're scanning
85+ echo "Dependencies to scan:"
86+ head -10 snyk-requirements.txt
87+
88+ - name : Run Snyk security scan
89+ uses : snyk/actions/python@b98d498629f1c368650224d6d212bf7dfa89e4bf # pin@0.4.0
3990 env :
40- SNYK_TOKEN : ${{ secrets.SNYK_TOKEN }}
91+ SNYK_TOKEN : ${{ secrets.SNYK_TOKEN }}
92+ with :
93+ args : --file=packages/${{ matrix.package }}/snyk-requirements.txt --package-manager=pip
94+
95+ - name : Upload Snyk results to GitHub Code Scanning
96+ uses : github/codeql-action/upload-sarif@v3
97+ if : always()
98+ with :
99+ sarif_file : snyk.sarif
100+ category : snyk-${{ matrix.package }}
0 commit comments