diff options
Diffstat (limited to 'tvloader/parser2v2/util.go')
-rw-r--r-- | tvloader/parser2v2/util.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tvloader/parser2v2/util.go b/tvloader/parser2v2/util.go index 691fe4e..6676846 100644 --- a/tvloader/parser2v2/util.go +++ b/tvloader/parser2v2/util.go @@ -73,6 +73,23 @@ func extractDocElementID(value string) (spdx.DocElementID, error) { return spdx.DocElementID{DocumentRefID: docRefID, ElementRefID: spdx.ElementID(eltRefID)}, nil } +// used to extract SPDXRef values from an SPDX Identifier, OR "special" strings +// from a specified set of permitted values. The primary use case for this is +// the right-hand side of Relationships, where beginning in SPDX 2.2 the values +// "NONE" and "NOASSERTION" are permitted. If the value does not match one of +// the specified permitted values, it will fall back to the ordinary +// DocElementID extractor. +func extractDocElementSpecial(value string, permittedSpecial []string) (spdx.DocElementID, error) { + // check value against special set first + for _, sp := range permittedSpecial { + if sp == value { + return spdx.DocElementID{SpecialID: sp}, nil + } + } + // not found, fall back to regular search + return extractDocElementID(value) +} + // used to extract SPDXRef values only from an SPDX Identifier which can point // to this document only. Use extractDocElementID for parsing IDs that can // refer either to this document or a different one. |