Skip to content

fix: read shortcut fields: documentDescribes and hasFiles#201

Merged
kzantow merged 2 commits intospdx:mainfrom
kzantow-anchore:fix/read-shortcut-fields
Mar 6, 2023
Merged

fix: read shortcut fields: documentDescribes and hasFiles#201
kzantow merged 2 commits intospdx:mainfrom
kzantow-anchore:fix/read-shortcut-fields

Conversation

@kzantow
Copy link
Copy Markdown
Collaborator

@kzantow kzantow commented Mar 4, 2023

The JSON schema has fields documentDescribes and hasFiles for packages. These are not part of the Go data model and are duplicates of using relationships. However, some tools are outputting these fields today and we need to be able to decode them. This PR adds support for decoding these fields and translating them into the appropriate relationships.

Fixes: #166
Fixes: #171

kzantow added 2 commits March 4, 2023 11:10
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Copy link
Copy Markdown
Collaborator

@lumjjb lumjjb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super cool implementation! lgtm

func (p *Package) UnmarshalJSON(b []byte) error {
type pkg Package
type extras struct {
HasFiles []common.DocElementID `json:"hasFiles"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh i see this trick to pass the hasFiles up to unexposed fields, this is very cool :)

@kzantow kzantow merged commit 3ccd09f into spdx:main Mar 6, 2023
@kzantow kzantow deleted the fix/read-shortcut-fields branch March 6, 2023 15:07
@puerco
Copy link
Copy Markdown
Contributor

puerco commented Mar 9, 2023

This is great! Thanks @kzantow 🎉

wlynch added a commit to wlynch/apko that referenced this pull request Dec 17, 2025
SPDX considers documentDescribes as a shortcut field - it is not present
in SPDX Go types (even though it will unmarshal them correctly).
However, if apko is presented an SBOM without a shortcut field, it will fail
to extract out the package details, even though the SBOM is considered valid by
SPDX standards.

This adds support to look for the equivalent details in the DESCRIBES
relationship.

See spdx/tools-golang#201 for more context.
wlynch added a commit to wlynch/apko that referenced this pull request Dec 17, 2025
SPDX considers documentDescribes as a shortcut field - it is not present
in SPDX Go types (even though it will unmarshal them correctly).
However, if apko is presented an SBOM without a shortcut field, it will fail
to extract out the package details, even though the SBOM is considered valid by
SPDX standards.

This adds support to look for the equivalent details in the DESCRIBES
relationship.

See spdx/tools-golang#201 for more context.
wlynch added a commit to wlynch/apko that referenced this pull request Dec 17, 2025
SPDX considers documentDescribes as a shortcut field - it is not present
in SPDX Go types (even though it will unmarshal them correctly).
However, if apko is presented an SBOM without a shortcut field, it will fail
to extract out the package details, even though the SBOM is considered valid by
SPDX standards.

This adds support to look for the equivalent details in the DESCRIBES
relationship.

See spdx/tools-golang#201 for more context.
wlynch added a commit to wlynch/apko that referenced this pull request Dec 17, 2025
SPDX considers documentDescribes as a shortcut field - it is not present
in SPDX Go types (even though it will unmarshal them correctly).
However, if apko is presented an SBOM without a shortcut field, it will fail
to extract out the package details, even though the SBOM is considered valid by
SPDX standards.

This adds support to look for the equivalent details in the DESCRIBES
relationship.

See spdx/tools-golang#201 for more context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON readers are missing hasFiles handling Update to add documentDescribes field to follow 2.2.2 spec

3 participants