Skip to content

Commit a75d172

Browse files
support for FINOS license scanning
1 parent 7cddce1 commit a75d172

File tree

4 files changed

+66
-76
lines changed

4 files changed

+66
-76
lines changed

.github/workflows/cve-scanning.yml

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,40 @@
1-
name: CVE Scanning for Maven
1+
name: CVE Scanning for Python
22

33
on:
4-
workflow_dispatch:
4+
schedule:
5+
- cron: '0 8,18 * * 1-5'
56
push:
6-
branches:
7-
- master
87
paths:
9-
- 'pom.xml'
10-
- 'allow-list.xml'
11-
- '.github/workflows/cve-scanning.yml'
12-
pull_request:
13-
paths:
14-
- 'pom.xml'
15-
- 'allow-list.xml'
16-
- '.github/workflows/cve-scanning.yml'
8+
- 'pyproject.toml'
9+
- 'safety-policy.yml'
10+
- '.github/workflows/cve-scanning-python.yml'
1711

18-
jobs:
19-
depcheck:
12+
env:
13+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
2014

15+
jobs:
16+
scan:
17+
name: Build and test App
2118
runs-on: ubuntu-latest
22-
2319
steps:
24-
- uses: actions/checkout@v3
25-
- uses: ./.github/actions/maven-build
26-
with:
27-
run-tests: false
28-
- name: CVE scanning
29-
uses: dependency-check/[email protected]
30-
env:
31-
JAVA_HOME: /opt/jdk
32-
with:
33-
project: 'Rune Python Runtime'
34-
path: '.'
35-
format: 'HTML'
36-
out: 'reports'
37-
args: >
38-
--suppression allow-list.xml
39-
--failOnCVSS 7
40-
- name: Upload results
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: CVE Scan Report ${{ strategy.job-index }}
44-
path: ${{github.workspace}}/reports
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.11"
24+
- uses: abatilo/actions-poetry@437d4fa27baf74d89b789ba2d8cae97dd2365feb
25+
with:
26+
poetry-version: "1.2.2"
27+
- name: Install safety
28+
run: pip3 install safety
29+
- name: Build app
30+
run: poetry build
31+
working-directory: python
32+
- name: Rune Python Runtime
33+
run: |
34+
poetry install
35+
working-directory: python
36+
- name: Scan CVEs
37+
run: poetry export --without-hashes -f requirements.txt | safety check --full-report --stdin --policy-file safety-policy.yml
38+
# Without poetry, use this command instead
39+
# run: safety check -r requirements.txt --full-report --policy-file safety-policy.yml
40+
working-directory: python
Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,29 @@
1-
name: License Scanning for Maven
1+
name: License Scanning for Python
22

33
on:
4-
workflow_dispatch:
4+
schedule:
5+
- cron: '0 8,18 * * 1-5'
56
push:
6-
branches:
7-
- master
87
paths:
9-
- 'pom.xml'
10-
- '.github/workflows/license-scanning.yml'
11-
pull_request:
12-
paths:
13-
- 'pom.xml'
14-
- '.github/workflows/license-scanning.yml'
8+
- requirements.txt
9+
- 'pyproject.toml'
10+
- '.github/workflows/license-scanning-python.yml'
1511

1612
env:
17-
ALLOW_LICENSES: "'The Apache Software License, Version 2.0' and licenses/license/name!='BSD' and licenses/license/name!='BSD-style license' and licenses/license/name!='Apache License, Version 2.0'"
18-
REPORT_PATH: "target/generated-resources/licenses.xml"
13+
ALLOW_LICENSES: "MIT License;Apache Software License;BSD License"
14+
# IGNORE_PACKAGES: ""
1915

2016
jobs:
2117
scan:
18+
name: Scan for licenses
2219
runs-on: ubuntu-latest
23-
strategy:
24-
matrix:
25-
module-folder: ["./", "./examples", "./rosetta-source"]
2620
steps:
27-
- uses: actions/checkout@v3
28-
- name: Install XQ
29-
run: pip install xq
30-
- uses: ./.github/actions/maven-build
31-
with:
32-
run-tests: false
33-
- name: License XML report
34-
run: mvn org.codehaus.mojo:license-maven-plugin:2.0.0:download-licenses
35-
- name: Validate XML report
36-
run: |
37-
LICENSE_REPORT=`xq "//dependency[licenses/license/name!=${{ env.ALLOW_LICENSES }}]" ./${{ env.REPORT_PATH }}`
38-
LINES_FOUND=`echo $LICENSE_REPORT | wc -l`
39-
echo "License issues found ..."
40-
if [ $LINES_FOUND -gt 1 ]; then echo $LICENSE_REPORT ; exit -1; fi
41-
working-directory: ${{ matrix.module-folder }}
42-
- name: Upload license reports
43-
uses: actions/upload-artifact@v4
44-
with:
45-
name: license-reports-${{ strategy.job-index }}
46-
path: '**/dependencies.html'
47-
- name: Upload license XML reports
48-
uses: actions/upload-artifact@v4
49-
with:
50-
name: license-xml-report-${{ strategy.job-index }}
51-
path: '**/${{ env.REPORT_PATH }}'
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.11"
25+
- name: Install pip-licenses
26+
run: pip3 install pip-licenses
27+
- name: Scan for licenses
28+
run: pip-licenses --allow-only="${{ env.ALLOW_LICENSES }}" # --ignore-packages="${{ env.IGNORE_PACKAGES }}"
29+
working-directory: python

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build
2+
setuptools
3+
setuptools_scm
4+
wheel
5+
pytest-runner

safety-policy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
security:
2+
ignore-cvss-severity-below: 6
3+
ignore-cvss-unknown-severity: False
4+
ignore-vulnerabilities:
5+
25853: # Example vulnerability ID
6+
reason: Testing CVE suppression
7+
# expires: '2023-12-31'
8+
52365:
9+
reason: Testing CVE suppression
10+
58758:
11+
reason: Testing CVE suppression

0 commit comments

Comments
 (0)