syft/schema/json
2022-03-09 14:51:43 -05:00
..
generate.go Add additional PHP metadata (#753) 2022-01-19 11:42:16 -05:00
README.md update json schema with optional poweruser data shape 2021-03-22 10:56:16 -04:00
schema-1.0.0.json Add enterprise upload capability (#285) 2020-12-09 22:20:53 -05:00
schema-1.0.1.json Split dpk source into name and version (#297) 2020-12-18 14:08:19 -05:00
schema-1.0.2.json Mark package relations by file ownership (#329) 2021-02-25 13:47:13 -05:00
schema-1.0.3.json update json schema with optional poweruser data shape 2021-03-22 10:56:16 -04:00
schema-1.0.4.json allow file metadata digests to be optional + add link destination 2021-03-29 12:07:42 -04:00
schema-1.0.5.json Add secrets search capability (#367) 2021-04-01 21:34:15 +00:00
schema-1.1.0.json use the standard file.Digest for apk checksums 2021-04-19 16:42:17 -04:00
schema-2.0.0.json Migrate SPDX-JSON relationships to SBOM model (#634) 2021-11-23 14:54:17 -05:00
schema-2.0.1.json Add cataloging of macho multi-architecture binaries (#657) 2021-12-08 16:25:24 -05:00
schema-2.0.2.json Bump syft JSON schema and add v2.0.2 (#716) 2021-12-22 13:55:34 -05:00
schema-3.0.0.json Replace distro type (#742) 2022-01-12 12:13:42 -05:00
schema-3.0.1.json Add additional PHP metadata (#753) 2022-01-19 11:42:16 -05:00
schema-3.1.0.json RPM Epoch should be optional in the json schema (#880) 2022-03-09 14:51:43 -05:00
vnd.syft+json document current draft for iana submission (#618) 2021-11-10 11:28:47 -05:00

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 within internal/presenters/poweruser/json_document.go that governs the overall document shape
  • the artifactMetadataContainer struct definition within schema/json/generate.go that governs the allowable shapes of pkg.Package.Metadata

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 data
  • REVISION: increment when you make a schema change which may prevent interaction with some historical data
  • ADDITION: 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 it is important that a few things are done:

  • a new integration test case is added to test/integration/pkg_cases_test.go that exercises the new package type with the new metadata
  • the new metadata struct is added to the artifactMetadataContainer struct within schema/json/generate.go

Generating a New Schema

Create the new schema by running cd schema/json && go run generate.go (note you must be in the schema/json dir while running this):

  • 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.