Skip to content

Commit 9436253

Browse files
authored
Revert "Support for CycloneDX schema version 1.4 (#108)"
This reverts commit 7fb6da9.
1 parent 7fb6da9 commit 9436253

File tree

100 files changed

+3735
-10510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3735
-10510
lines changed

.github/workflows/docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-documentation:
11+
name: "Build documentation"
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 30
14+
steps:
15+
- name: Checkout
16+
# see https://github.com/actions/checkout
17+
uses: actions/checkout@v2
18+
- name: Setup Python Environment
19+
# see https://github.com/actions/setup-python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9
23+
architecture: 'x64'
24+
- name: Install dependencies
25+
run: pip install -r doc/requirements.txt
26+
- name: Build documentation
27+
run: |
28+
pdoc --template-dir doc/templates --html cyclonedx
29+
- name: Deploy documentation
30+
uses: JamesIves/[email protected]
31+
with:
32+
branch: gh-pages
33+
folder: html/cyclonedx
34+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
name: Manual Pre Release Publish
1+
name: Manual Release Candidate
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
release_candidate_suffix:
7-
description: 'RC Suffix e.g. rc0, beta1, alpha2. Do not include a leading hyphen.'
6+
branch:
7+
description: 'Branch to produce Release Candidate from'
88
required: true
99
type: string
10+
rc_number:
11+
description: 'RC Number'
12+
default: 0
13+
required: true
14+
type: number
1015

1116
jobs:
12-
release_candidate:
17+
release:
1318
runs-on: ubuntu-latest
14-
concurrency: release_candidate
19+
concurrency: release
1520
steps:
1621
- name: Checkout code
1722
uses: actions/checkout@v2
@@ -26,13 +31,12 @@ jobs:
2631
poetry config virtualenvs.create false
2732
poetry install
2833
python -m pip install python-semantic-release
29-
- name: Apply Pre Release Version
34+
- name: Determine RC candidate version
3035
run: |
31-
RC_VERSION="$(semantic-release --noop --major print-version)-${{ github.event.inputs.release_candidate_suffix }}"
36+
RC_VERSION="$(python-semantic-release --noop --major print-version)rc${{ inputs.rc_number }})"
3237
echo "RC Version will be: ${RC_VERSION}"
33-
poetry version ${RC_VERSION}
34-
poetry build
35-
- name: Publish Pre Release 📦 to PyPI
36-
uses: pypa/gh-action-pypi-publish@master
37-
with:
38-
password: ${{ secrets.PYPI_TOKEN }}
38+
# - name: Python Semantic Release
39+
# uses: relekang/python-semantic-release@master
40+
# with:
41+
# github_token: ${{ secrets.GITHUB_TOKEN }}
42+
# pypi_token: ${{ secrets.PYPI_TOKEN }}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ html/
2626

2727
# mypy caches
2828
/.mypy_cache
29-
30-
# Exlude built docs
31-
docs/_build

.readthedocs.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

README.md

Lines changed: 194 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![shield_gh-workflow-test]][link_gh-workflow-test]
44
[![shield_pypi-version]][link_pypi]
5-
[![shield_conda-forge-version]][link_conda-forge]
65
[![shield_license]][license_file]
76
[![shield_website]][link_website]
87
[![shield_slack]][link_slack]
@@ -23,7 +22,199 @@ Additionally, you can use this module yourself in your application to programmat
2322

2423
CycloneDX is a lightweight BOM specification that is easily created, human-readable, and simple to parse.
2524

26-
View our documentation [here](https://cyclonedx-python-library.readthedocs.io/).
25+
## Installation
26+
27+
Install from pypi.org as you would any other Python module:
28+
29+
```shell
30+
pip install cyclonedx-python-lib
31+
```
32+
33+
## Architecture
34+
35+
This module break out into three key areas:
36+
37+
1. **Parser**: Use a parser that suits your needs to automatically gather information about your environment or
38+
application
39+
2. **Model**: Internal models used to unify data from different parsers
40+
3. **Output**: Choose and configure an output which allows you to define output format as well as the CycloneDX schema
41+
version
42+
43+
### Parsing
44+
45+
You can use one of the parsers to obtain information about your project or environment. Available parsers:
46+
47+
| Parser | Class / Import | Description |
48+
| ------- | ------ | ------ |
49+
| CondaListJsonParser | `from cyclonedx.parser.conda import CondaListJsonParser` | Parses input provided as a `str` that is output from `conda list --json` |
50+
| CondaListExplicitParser | `from cyclonedx.parser.conda import CondaListExplicitParser` | Parses input provided as a `str` that is output from `conda list --explicit` or `conda list --explicit --md5` |
51+
| Environment | `from cyclonedx.parser.environment import EnvironmentParser` | Looks at the packaged installed in your current Python environment. |
52+
| PipEnvParser | `from cyclonedx.parser.pipenv import PipEnvParser` | Parses `Pipfile.lock` content passed in as a string. |
53+
| PipEnvFileParser | `from cyclonedx.parser.pipenv import PipEnvFileParser` | Parses the `Pipfile.lock` file at the supplied path. |
54+
| PoetryParser | `from cyclonedx.parser.poetry import PoetryParser` | Parses `poetry.lock` content passed in as a string. |
55+
| PoetryFileParser | `from cyclonedx.parser.poetry import PoetryFileParser` | Parses the `poetry.lock` file at the supplied path. |
56+
| RequirementsParser | `from cyclonedx.parser.requirements import RequirementsParser` | Parses a multiline string that you provide that conforms to the `requirements.txt` [PEP-508] standard. |
57+
| RequirementsFileParser | `from cyclonedx.parser.requirements import RequirementsFileParser` | Parses a file that you provide the path to that conforms to the `requirements.txt` [PEP-508] standard. |
58+
59+
#### Example
60+
61+
```py
62+
from cyclonedx.parser.environment import EnvironmentParser
63+
64+
parser = EnvironmentParser()
65+
```
66+
67+
#### Notes on Requirements parsing
68+
69+
CycloneDX software bill-of-materials require pinned versions of requirements. If your `requirements.txt` does not have
70+
pinned versions, warnings will be recorded and the dependencies without pinned versions will be excluded from the
71+
generated CycloneDX. CycloneDX schemas (from version 1.0+) require a component to have a version when included in a
72+
CycloneDX bill of materials (according to schema).
73+
74+
If you need to use a `requirements.txt` in your project that does not have pinned versions an acceptable workaround
75+
might be to:
76+
77+
```shell
78+
pip install -r requirements.txt
79+
pip freeze > requirements-frozen.txt
80+
```
81+
82+
You can then feed in the frozen requirements from `requirements-frozen.txt` _or_ use the `Environment` parser one you
83+
have `pip install`ed your dependencies.
84+
85+
### Modelling
86+
87+
You can create a BOM Model from either a Parser instance or manually using the methods avaialbel directly on the `Bom` class.
88+
89+
The model also supports definition of vulnerabilities for output using the CycloneDX schema extension for
90+
[Vulnerability Disclosures](https://cyclonedx.org/use-cases/#vulnerability-disclosure) as of version 0.3.0.
91+
92+
**Note:** Known vulnerabilities associated with Components can be sourced from various data sources, but this library
93+
will not source them for you. Perhaps look at [Jake][jake] if you're interested in this.
94+
95+
#### Example from a Parser
96+
97+
```py
98+
from cyclonedx.model.bom import Bom
99+
from cyclonedx.parser.environment import EnvironmentParser
100+
101+
parser = EnvironmentParser()
102+
bom = Bom.from_parser(parser=parser)
103+
```
104+
105+
### Generating Output
106+
107+
Once you have an instance of a `Bom` you can produce output in either `JSON` or `XML` against any of the supporting CycloneDX schema versions as you require.
108+
109+
We provide two helper methods:
110+
111+
* Output to string (for you to do with as you require)
112+
* Output directly to a filename you provide
113+
114+
#### Example as JSON
115+
116+
```py
117+
from cyclonedx.output import get_instance, OutputFormat
118+
119+
outputter = get_instance(bom=bom, output_format=OutputFormat.JSON)
120+
outputter.output_as_string()
121+
```
122+
123+
#### Example as XML
124+
125+
```py
126+
from cyclonedx.output import get_instance, SchemaVersion
127+
128+
outputter = get_instance(bom=bom, schema_version=SchemaVersion.V1_2)
129+
outputter.output_to_file(filename='/tmp/sbom-v1.2.xml')
130+
```
131+
132+
## Library API Documentation
133+
134+
The Library API Documentation is available online at [https://cyclonedx.github.io/cyclonedx-python-lib/](https://cyclonedx.github.io/cyclonedx-python-lib/).
135+
136+
## Schema Support
137+
138+
This library is a work in progress and complete support for all parts of the CycloneDX schema will come in future releases.
139+
140+
Here is a summary of the parts of the schema supported by this library:
141+
142+
_Note: We refer throughout using XPath, but the same is true for both XML and JSON output formats._
143+
144+
<table width="100%">
145+
<thead>
146+
<tr>
147+
<th>XPath</th>
148+
<th>Support v1.3</th>
149+
<th>Support v1.2</th>
150+
<th>Support v1.1</th>
151+
<th>Support v1.0</th>
152+
<th>Notes</th>
153+
</tr>
154+
</thead>
155+
<tbody>
156+
<tr>
157+
<td><code>/bom</code></td>
158+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
159+
<td>
160+
This is the root element and is supported with all it's defined attributes.
161+
</td>
162+
</tr>
163+
<tr>
164+
<td><code>/bom/metadata</code></td>
165+
<td>Y</td><td>Y</td><td>N/A</td><td>N/A</td>
166+
<td>
167+
<code>timestamp</code> and <code>tools</code> are currently supported
168+
</td>
169+
</tr>
170+
<tr>
171+
<td><code>/bom/components</code></td>
172+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
173+
<td>&nbsp;</td>
174+
</tr>
175+
<tr>
176+
<th colspan="6"><strong><code>/bom/components/component</code></strong></th>
177+
</tr>
178+
<tr>
179+
<td><code>./author</code></td>
180+
<td>Y</td><td>Y</td><td>N/A</td><td>N/A</td>
181+
<td>&nbsp;</td>
182+
</tr>
183+
<tr>
184+
<td><code>./name</code></td>
185+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
186+
<td>&nbsp;</td>
187+
</tr>
188+
<tr>
189+
<td><code>./version</code></td>
190+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
191+
<td>&nbsp;</td>
192+
</tr>
193+
<tr>
194+
<td><code>./purl</code></td>
195+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
196+
<td>&nbsp;</td>
197+
</tr>
198+
<tr>
199+
<td><code>./externalReferences</code></td>
200+
<td>Y</td><td>Y</td><td>Y</td><td>N/A</td>
201+
<td>Not all Parsers have this information. It will be populated where there is information available.</td>
202+
</tr>
203+
<tr>
204+
<td><code>./hashes</code></td>
205+
<td>Y</td><td>Y</td><td>Y</td><td>Y</td>
206+
<td>
207+
These are supported when programmatically creating a <code>Bom</code> - these will not currently be
208+
automatically populated when using a <code>Parser</code>.
209+
</td>
210+
</tr>
211+
</tbody>
212+
</table>
213+
214+
### Notes on Schema Support
215+
216+
* N/A is where the CycloneDX standard does not include this
217+
* If the table above does not refer to an element, it is not currently supported
27218

28219
## Python Support
29220

@@ -53,16 +244,14 @@ See the [LICENSE][license_file] file for the full license.
53244
[contributing_file]: https://github.com/CycloneDX/cyclonedx-python-lib/blob/master/CONTRIBUTING.md
54245

55246
[shield_gh-workflow-test]: https://img.shields.io/github/workflow/status/CycloneDX/cyclonedx-python-lib/Python%20CI/main?logo=GitHub&logoColor=white "build"
56-
[shield_pypi-version]: https://img.shields.io/pypi/v/cyclonedx-python-lib?logo=pypi&logoColor=white&label=PyPI "PyPI"
57-
[shield_conda-forge-version]: https://img.shields.io/conda/vn/conda-forge/cyclonedx-python-lib?logo=anaconda&logoColor=white&label=conda-forge "conda-forge"
247+
[shield_pypi-version]: https://img.shields.io/pypi/v/cyclonedx-python-lib?logo=Python&logoColor=white&label=PyPI "PyPI"
58248
[shield_license]: https://img.shields.io/github/license/CycloneDX/cyclonedx-python-lib "license"
59249
[shield_website]: https://img.shields.io/badge/https://-cyclonedx.org-blue.svg "homepage"
60250
[shield_slack]: https://img.shields.io/badge/slack-join-blue?logo=Slack&logoColor=white "slack join"
61251
[shield_groups]: https://img.shields.io/badge/discussion-groups.io-blue.svg "groups discussion"
62252
[shield_twitter-follow]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter&logoColor=white "twitter follow"
63253
[link_gh-workflow-test]: https://github.com/CycloneDX/cyclonedx-python-lib/actions/workflows/poetry.yml?query=branch%3Amain
64254
[link_pypi]: https://pypi.org/project/cyclonedx-python-lib/
65-
[link_conda-forge]: https://anaconda.org/conda-forge/cyclonedx-python-lib
66255
[link_website]: https://cyclonedx.org/
67256
[link_slack]: https://cyclonedx.org/slack/invite
68257
[link_discussion]: https://groups.io/g/CycloneDX

0 commit comments

Comments
 (0)