-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
As of today, I noticed cyclonedx-go/testdata only provides valid-* sample test BOM files in XML and JSON. It provides no invalid-* files, and no protobuf files.
$ git clone https://github.com/CycloneDX/cyclonedx-go.git
$ cd cyclonedx-go/testdata
$ broot --cmd ":pt"
cyclonedx/cyclonedx-go/testdata
├──snapshots …
├──valid-annotation.json
├──valid-annotation.xml
├──valid-assembly.json
├──valid-assembly.xml
├──valid-bom.json
├──valid-bom.xml
├──valid-component-hashes.json
├──valid-component-hashes.xml
├──valid-component-omniborId.json
├──valid-component-omniborId.xml
├──valid-component-ref.json
├──valid-component-ref.xml
[...]And files are not sorted by CycloneDX specification version, which makes it
harder to list and to maintain.
But I noticed the github.com/CycloneDX/specification repository provides both
valid-* and invalid-* BOM sample files in XML, JSON and PROTOBUF formats.
These files are useful to tests implementation of the CycloneDX, such as
github.com/CycloneDX/cyclonedx-go.
$ git clone https://github.com/CycloneDX/specification.git
$ cd specification/tools/src/test/resources
$ broot --cmd ":pt" # https://dystroy.org/broot/documentation/usage/#export-a-tree
cyclonedx/specification/tools/src/test/resources
├──1.0
│ └──2 unlisted
├──1.1
│ ├──invalid-component-ref-1.1.xml
│ ├──invalid-component-type-1.1.xml
│ ├──invalid-empty-component-1.1.xml
│ ├──invalid-hash-alg-1.1.xml
│ ├──invalid-hash-md5-1.1.xml
│ ├──valid-bom-1.1.xml
│ └──23 unlisted
├──1.2
│ ├──invalid-bomformat-1.2.json
│ ├──invalid-component-ref-1.2.json
│ ├──invalid-component-ref-1.2.xml
│ ├──invalid-component-swid-1.2.json
│ ├──invalid-component-swid-1.2.xml
│ ├──valid-assembly-1.2.json
│ ├──valid-assembly-1.2.xml
│ └──82 unlisted
├──1.3
│ ├──invalid-bomformat-1.3.json
│ ├──invalid-component-ref-1.3.json
│ ├──invalid-component-ref-1.3.xml
│ ├──invalid-component-swid-1.3.json
│ ├──valid-assembly-1.3.json
│ ├──valid-assembly-1.3.xml
│ └──122 unlisted
├──1.4
│ ├──invalid-bomformat-1.4.json
│ ├──invalid-component-ref-1.4.json
│ ├──invalid-component-ref-1.4.xml
│ ├──invalid-component-swid-1.4.json
│ ├──valid-assembly-1.4.json
│ └──129 unlisted
├──1.5
│ ├──invalid-bomformat-1.5.json
│ ├──invalid-component-ref-1.5.json
│ ├──invalid-component-ref-1.5.xml
│ ├──invalid-component-swid-1.5.json
│ ├──valid-annotation-1.5.json
│ ├──valid-annotation-1.5.xml
│ ├──valid-annotation-1.5.textproto
│ └──149 unlisted
├──1.6
│ ├──invalid-bomformat-1.6.json
│ ├──invalid-component-ref-1.6.json
│ ├──invalid-component-ref-1.6.xml
│ ├──invalid-component-swid-1.6.json
│ ├──valid-component-hashes-1.6.json
│ ├──valid-component-hashes-1.6.xml
│ ├──valid-component-ref-1.6.textproto
│ └──178 unlisted
└──ext
├──invalid-depgraph-1.0.xml
├──valid-component-depgraph-1.0.xml
└──valid-depgraph-1.0.xmlI suggest using a git submodule to fetch tests files from the CycloneDX specification repository.
git clone https://github.com/CycloneDX/cyclonedx-go
cd cyclonedx-go
git submodule add -f https://github.com/CycloneDX/specification specificationThis would give access to the full list of valid-* and invalid-* BOMs files
in *.xml, *.json and *.textproto with no efforts.
This would be available at this path:
cyclonedx-go/specification/tools/src/test/resources.
And if there are tests files dedicated to one particular language (Go, python, or Java),
then either keep a folder for custom test files, or contribute to the tests files in the
CycloneDX/specification repo.
All CycloneDX Implementation Python, Golang, Java could do the same
The same principle could be applied to any CycloneDX implementation:
github.com/CycloneDX/cyclonedx-gogithub.com/CycloneDX/cyclonedx-core-javagithub.com/CycloneDX/cyclonedx-python-lib
┌────────────────────────────────────────────────────┐
│ github.com/CycloneDX/specification commit 59e7d88 │
│ └── tools/src/test/resources (local) │
└─────┬─────────────────┬───────────────────┬────────┘
│ │ │
fetch submodule fetch submodule fetch submodule
│ │ │
┌────────────────────────▼───────────────┐ │ │
│ github.com/CycloneDX/cyclonedx-go │ │ │
│ └── specification @59e7d88 (submodule) │ │ │
└────────────────────────────────────────┘ │ │
│ │
┌─────────────────────────▼────────────────┐ │
│ github.com/CycloneDX/cyclonedx-core-java │ │
│ └── specification @59e7d88 (submodule) │ │
└──────────────────────────────────────────┘ │
│
┌───────────────────────────────▼──────────┐
│github.com/CycloneDX/cyclonedx-python-lib │
│ └── specification @59e7d88 (submodule) │
└──────────────────────────────────────────┘
Use the git submodule for Schema Files as well?
Once the git submodules for CycloneDX/specification are available in both
cyclonedx-go, cyclonedx-core-java and cyclonedx-python-lib to fetch
test files, this could also be used for fetching schema files (JSON Schema,
XSD and protobuf).
This would prevent issues such as this one where I noticed CycloneDX schema
files are different from one CycloneDX implementation to another.
CycloneDX/specification#479 (comment)
Note: I start this discussion for the
cyclonedx-goproject. But we could
open the same discussion in others CycloneDX implementations (python and
java).
CC @jkowalleck & @nscuro who helped me figure out how to explain this idea 😄