Skip to content

Commit 2502ce5

Browse files
[SP-2874] feat: add licenses sub-command, add support for ingesting CDX, add CDX input validation (#131)
* [SP-2874] feat: add licenses sub-command, add support for ingesting CDX, add CDX input validation * [SP-2874] feat: support CDX input file in crypto decoration commands * [SP-2874] chore: update dependency versions, refactor to reduce method complexity * [SP-2874] chore: use python 3.9 in all workflows * [SP-2874] chore: update protobuf * [SP-2874] chore: update all remaining protobufs * [SP-2874] chore: bump version * [SP-2874] chore: update changelog, documentation and dockerfile * [SP-2874] chore: update scanoss.json * [SP-2874] chore: update scanoss.json * [SP-2874] chore: update changelog and version * [SP-2991] fix: update to papi latest definitions * [SP-2874] chore: update version and changelog * [SP-2874] fix: adapt for new components request * [SP-2874] feat: add REST support for licenses endpoint * [SP-2874] chore: update workflow python version * [SP-2874] fix: scancode dockerfile execution * [SP-2874] chore: update pkg requirements * [SP-2874] chore: fix click version as workaround for scancode-toolkit-mini * [SP-2874] chore: add api key on github workflows * [SP-2874] chore: add api key on github workflows * add api key * env cleanup --------- Co-authored-by: eeisegn <[email protected]>
1 parent 84eee42 commit 2502ce5

26 files changed

+1988
-326
lines changed

.github/workflows/container-local-test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on:
55
workflow_dispatch:
66
push:
77
branches:
8-
- 'main'
8+
- "main"
99
pull_request:
1010
branches:
11-
- 'main'
11+
- "main"
1212

1313
env:
1414
IMAGE_BASE: scanoss/scanoss-py-base
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Python
2828
uses: actions/setup-python@v5
2929
with:
30-
python-version: '3.9.x'
30+
python-version: "3.9.x"
3131

3232
- name: Install Dependencies
3333
run: |
@@ -91,10 +91,11 @@ jobs:
9191
docker image ls -a
9292
docker run ${{ env.IMAGE_NAME }} version
9393
docker run ${{ env.IMAGE_NAME }} utils fast
94-
docker run -v "$(pwd)":"/scanoss" ${{ env.IMAGE_NAME }} scan -o results.json tests
94+
docker run -e SCANOSS_API_KEY="${{ secrets.SC_API_KEY }}" -v "$(pwd)":"/scanoss" ${{ env.IMAGE_NAME }} scan -o results.json tests
9595
id_count=$(cat results.json | grep '"id":' | wc -l)
9696
echo "ID Count: $id_count"
9797
if [[ $id_count -lt 1 ]]; then
9898
echo "Error: Scan test did not produce any results. Failing"
9999
exit 1
100100
fi
101+

.github/workflows/container-publish-ghcr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Python
3131
uses: actions/setup-python@v5
3232
with:
33-
python-version: "3.9.x"
33+
python-version: '3.9.x'
3434

3535
- name: Install Dependencies
3636
run: |
@@ -130,7 +130,7 @@ jobs:
130130
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
131131
docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} version
132132
docker run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} utils fast
133-
docker run -v "$(pwd)":"/scanoss" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} scan -o results.json tests
133+
docker run -e SCANOSS_API_KEY="${{ secrets.SC_API_KEY }}" -v "$(pwd)":"/scanoss" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} scan -o results.json tests
134134
id_count=$(cat results.json | grep '"id":' | wc -l)
135135
echo "ID Count: $id_count"
136136
if [[ $id_count -lt 1 ]]; then

.github/workflows/python-local-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
permissions:
1414
contents: read
1515

16+
env:
17+
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
18+
1619
jobs:
1720
build:
1821
runs-on: ubuntu-latest
@@ -71,6 +74,7 @@ jobs:
7174
echo "Error: Scan test did not produce any results. Failing"
7275
exit 1
7376
fi
77+
7478

7579
- name: Run Tests HPSM (fast winnowing)
7680
run: |
@@ -85,6 +89,7 @@ jobs:
8589
echo "Error: WFP test did not produce any results. Failing"
8690
exit 1
8791
fi
92+
8893

8994
- name: Run Unit Tests
9095
run: |

.github/workflows/python-publish-pypi.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
tags:
88
- "v*.*.*"
99

10+
env:
11+
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
12+
1013
jobs:
1114
deploy:
1215
runs-on: ubuntu-latest
@@ -16,7 +19,7 @@ jobs:
1619
- name: Set up Python
1720
uses: actions/setup-python@v5
1821
with:
19-
python-version: "3.9.x"
22+
python-version: '3.9.x'
2023

2124
- name: Install dependencies
2225
run: |
@@ -70,7 +73,7 @@ jobs:
7073
- name: Set up Python
7174
uses: actions/setup-python@v5
7275
with:
73-
python-version: "3.9.x"
76+
python-version: '3.9.x'
7477

7578
- name: Install Remote Package
7679
uses: nick-fields/retry@v3

.github/workflows/python-publish-testpypi.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on: [workflow_dispatch]
66
permissions:
77
contents: read
88

9+
env:
10+
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
11+
912
jobs:
1013
deploy:
1114
runs-on: ubuntu-latest
@@ -15,7 +18,7 @@ jobs:
1518
- name: Set up Python
1619
uses: actions/setup-python@v5
1720
with:
18-
python-version: "3.9.x"
21+
python-version: '3.9.x'
1922

2023
- name: Install Dependencies
2124
run: |
@@ -65,7 +68,7 @@ jobs:
6568
- name: Set up Python
6669
uses: actions/setup-python@v5
6770
with:
68-
python-version: "3.9.x"
71+
python-version: '3.9.x'
6972

7073
- name: Install Remote Package
7174
run: |

.github/workflows/version-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Python
2424
uses: actions/setup-python@v5
2525
with:
26-
python-version: "3.9.x"
26+
python-version: '3.9.x'
2727
- name: Determine Tag
2828
id: taggerVersion
2929
run: |

CHANGELOG.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [1.33.0] - 2025-09-19
13+
### Added
14+
- Add `licenses` sub-command to `component` command
15+
- Add support for ingesting CDX to all decoration commands
16+
- Add CDX input validation
17+
1218
## [1.32.0] - 2025-09-01
1319
### Added
1420
- Switched vulnerability and dependency APIs to use REST by default
@@ -176,7 +182,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
176182

177183
## [1.20.2] - 2025-02-26
178184
### Fixed
179-
- Fixed provenance command
185+
- Fixed provenance command
180186

181187
## [1.20.1] - 2025-02-18
182188
### Added
@@ -238,7 +244,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
238244
## [1.17.5] - 2024-11-12
239245
### Fixed
240246
- Fix dependencies scan result structure
241-
247+
242248
## [1.17.4] - 2024-11-08
243249
### Fixed
244250
- Fix backslashes in file paths on Windows
@@ -255,7 +261,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
255261
### Added
256262
- Added supplier to SPDX packages
257263
### Changed
258-
- Changed undeclared summary output
264+
- Changed undeclared summary output
259265

260266
## [1.17.1] - 2024-10-24
261267
### Fixed
@@ -288,7 +294,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
288294
### Added
289295
- Added support for Python3.12
290296
- Module `pkg_resources` has been replaced with `importlib_resources`
291-
- Added support for UTF-16 filenames
297+
- Added support for UTF-16 filenames
292298

293299
## [1.13.0] - 2024-06-05
294300
### Added
@@ -367,11 +373,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
367373
## [1.6.0] - 2023-06-16
368374
### Added
369375
- Added support for High Precision Snippet Matching (`--hpsm` or `-H`) while scanning
370-
- `scanoss-py scan --hpsm ...`
376+
- `scanoss-py scan --hpsm ...`
371377

372378
## [1.5.2] - 2023-06-13
373379
### Added
374-
- Added retry limit option (`--retry`) while scanning
380+
- Added retry limit option (`--retry`) while scanning
375381
- `--retry 0` will fail immediately
376382

377383
## [1.5.1] - 2023-04-21
@@ -660,4 +666,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
660666
[1.31.3]: https://github.com/scanoss/scanoss.py/compare/v1.31.2...v1.31.3
661667
[1.31.4]: https://github.com/scanoss/scanoss.py/compare/v1.31.3...v1.31.4
662668
[1.31.5]: https://github.com/scanoss/scanoss.py/compare/v1.31.4...v1.31.5
663-
[1.31.5]: https://github.com/scanoss/scanoss.py/compare/v1.31.5...v1.32.0
669+
[1.32.0]: https://github.com/scanoss/scanoss.py/compare/v1.31.5...v1.32.0
670+
[1.33.0]: https://github.com/scanoss/scanoss.py/compare/v1.32.0...v1.33.0

CLIENT_HELP.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,44 @@ The following command provides the capability to search the SCANOSS KB for compo
337337
scanoss-py comp prov -p "pkg:github/unoconv/unoconv" --origin
338338
```
339339

340+
#### Component Licenses
341+
The following command provides the capability to search the SCANOSS KB for licenses for Open Source components:
342+
```bash
343+
scanoss-py comp licenses -p "pkg:github/jquery/jquery" -p "pkg:npm/express"
344+
```
345+
It is possible to supply multiple PURLs by repeating the `-p pkg` option, or providing a purl input file `-i purl-input.json` ([for example](tests/data/purl-input.json)):
346+
```bash
347+
scanoss-py comp licenses -i purl-input.json -o component-licenses.json
348+
```
349+
350+
The licenses command also supports CycloneDX (CDX) input files. You can provide a CycloneDX SBOM file and retrieve license information for all components:
351+
```bash
352+
scanoss-py comp licenses -i cyclonedx-sbom.json -o component-licenses.json
353+
```
354+
355+
### CDX Input Support for Component Commands
356+
Several component commands now support CycloneDX (CDX) input files. This allows you to analyze components from existing SBOM files:
357+
358+
**Supported commands with CDX input:**
359+
- `comp vulns` - Analyze vulnerabilities from CDX file
360+
- `comp licenses` - Retrieve licenses from CDX file
361+
- `comp crypto` - Detect cryptographic algorithms from CDX file
362+
- `comp semgrep` - Find semgrep issues from CDX file
363+
364+
**Example using CDX input:**
365+
```bash
366+
# Analyze vulnerabilities from a CycloneDX SBOM
367+
scanoss-py comp vulns -i sbom.cdx.json -o vulnerabilities.json
368+
369+
# Get licenses for all components in a CycloneDX SBOM
370+
scanoss-py comp licenses -i sbom.cdx.json -o licenses.json
371+
372+
# Detect cryptographic usage from CDX
373+
scanoss-py comp crypto -i sbom.cdx.json -o crypto-findings.json
374+
```
375+
376+
The CDX input file is automatically validated to ensure it's a valid CycloneDX format before processing.
377+
340378
341379
### Results Commands
342380
The `results` command provides the capability to operate on scan results. For example:

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RUN pip3 install --no-cache-dir /install/scanoss-*-py3-none-any.whl
2929
RUN pip3 install --no-cache-dir scanoss_winnowing
3030
RUN pip3 install --no-cache-dir -r /install/requirements-dev.txt
3131
RUN pip3 install --no-cache-dir scancode-toolkit-mini
32+
RUN pip3 install --no-cache-dir click==8.2.1 # Temporary workaround for scancode-toolkit-mini (https://github.com/aboutcode-org/scancode-toolkit/issues/4573)
3233

3334
# Download compile and install typecode-libmagic from source (as there is not ARM wheel available)
3435
ADD https://github.com/nexB/typecode_libmagic_from_sources/archive/refs/tags/v5.39.210212.tar.gz /install/
@@ -66,7 +67,7 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh |
6667
# Setup working directory and user
6768
WORKDIR /scanoss
6869
# Run scancode once to setup any initial files, etc. so that it'll run faster later
69-
RUN scancode -p --only-findings --quiet --json /scanoss/scancode-dependencies.json /scanoss && rm -f /scanoss/scancode-dependencies.json
70+
RUN scancode --package --only-findings --quiet --json /scanoss/scancode-dependencies.json /scanoss && rm -f /scanoss/scancode-dependencies.json
7071

7172
# Image with no default entry point
7273
FROM no_entry_point AS jenkins

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ requests
22
crc32c>=2.2
33
binaryornot
44
progress
5-
grpcio>1.42.0
6-
protobuf>3.19.1
5+
grpcio>=1.73.1
6+
protobuf>=6.3.1
7+
protoc-gen-openapiv2
78
pypac
89
urllib3
910
pyOpenSSL
@@ -13,5 +14,4 @@ packageurl-python
1314
pathspec
1415
jsonschema
1516
crc
16-
protoc-gen-openapiv2
1717
cyclonedx-python-lib[validation]

0 commit comments

Comments
 (0)