1aaa644007
* [wip] Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * distinct the package metadata functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove metadata type from package core model Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * incorporate review feedback for names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add RPM archive metadata and split parser helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * clarify the python package metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename the KB metadata type Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * break hackage and composer types by use case Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * linting fix Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix encoding and decoding for syft-json and cyclonedx Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema to 11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cyclonedx-xml snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update spdx-tv snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update syft-json snapshots Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * correct metadata type in stack yaml parser test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix bom-ref redactor for cyclonedx-xml Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests for legacy package metadata names Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * regenerate json schema v11 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix legacy HackageMetadataType reflect type value check Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * packagemetadata discovery should account for type shadowing Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump json schema version to v12 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update json schema to incorporate changes from main Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add syft-json legacy config option Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add tests around v11-v12 json decoding Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add docs for SYFT_JSON_LEGACY Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * rename structs to be compliant with new naming scheme Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> |
||
---|---|---|
.. | ||
README.md | ||
schema-1.0.0.json | ||
schema-1.0.1.json | ||
schema-1.0.2.json | ||
schema-1.0.3.json | ||
schema-1.0.4.json | ||
schema-1.0.5.json | ||
schema-1.1.0.json | ||
schema-2.0.0.json | ||
schema-2.0.1.json | ||
schema-2.0.2.json | ||
schema-3.0.0.json | ||
schema-3.0.1.json | ||
schema-3.1.0.json | ||
schema-3.1.1.json | ||
schema-3.2.1.json | ||
schema-3.2.2.json | ||
schema-3.2.3.json | ||
schema-3.2.4.json | ||
schema-3.3.0.json | ||
schema-3.3.1.json | ||
schema-3.3.2.json | ||
schema-4.0.0.json | ||
schema-4.1.0.json | ||
schema-5.0.0.json | ||
schema-5.0.1.json | ||
schema-5.1.0.json | ||
schema-6.0.0.json | ||
schema-6.1.0.json | ||
schema-6.2.0.json | ||
schema-7.0.0.json | ||
schema-7.0.1.json | ||
schema-7.1.0.json | ||
schema-7.1.1.json | ||
schema-7.1.2.json | ||
schema-7.1.3.json | ||
schema-7.1.4.json | ||
schema-7.1.5.json | ||
schema-7.1.6.json | ||
schema-8.0.0.json | ||
schema-8.0.1.json | ||
schema-9.0.0.json | ||
schema-9.0.1.json | ||
schema-9.0.2.json | ||
schema-10.0.0.json | ||
schema-10.0.1.json | ||
schema-10.0.2.json | ||
schema-11.0.0.json | ||
schema-11.0.1.json | ||
schema-12.0.0.json | ||
vnd.syft+json |
JSON Schema
This is the JSON schema for output from the JSON presenters (syft packages <img> -o json
and syft power-user <img>
). The required inputs for defining the JSON schema are as follows:
- the value of
internal.JSONSchemaVersion
that governs the schema filename - the
Document
struct definition withingithub.com/anchore/syft/syft/formats/syftjson/model/document.go
that governs the overall document shape - generated
AllTypes()
helper function within thesyft/internal/sourcemetadata
andsyft/internal/packagemetadata
packages
With regard to testing the JSON schema, integration test cases provided by the developer are used as examples to validate that JSON output from Syft is always valid relative to the schema/json/schema-$VERSION.json
file.
Versioning
Versioning the JSON schema must be done manually by changing the JSONSchemaVersion
constant within internal/constants.go
.
This schema is being versioned based off of the "SchemaVer" guidelines, which slightly diverges from Semantic Versioning to tailor for the purposes of data models.
Given a version number format MODEL.REVISION.ADDITION
:
MODEL
: increment when you make a breaking schema change which will prevent interaction with any historical dataREVISION
: increment when you make a schema change which may prevent interaction with some historical dataADDITION
: increment when you make a schema change that is compatible with all historical data
Adding a New pkg.*Metadata
Type
When adding a new pkg.*Metadata
that is assigned to the pkg.Package.Metadata
struct field you must add a test case to test/integration/catalog_packages_cases_test.go
that exercises the new package type with the new metadata.
Additionally it is important to generate a new JSON schema since the pkg.Package.Metadata
field is covered by the schema.
Generating a New Schema
Create the new schema by running make generate-json-schema
from the root of the repo:
- If there is not an existing schema for the given version, then the new schema file will be written to
schema/json/schema-$VERSION.json
- If there is an existing schema for the given version and the new schema matches the existing schema, no action is taken
- If there is an existing schema for the given version and the new schema does not match the existing schema, an error is shown indicating to increment the version appropriately (see the "Versioning" section)
Note: never delete a JSON schema and never change an existing JSON schema once it has been published in a release! Only add new schemas with a newly incremented version. All previous schema files must be stored in the schema/json/
directory.