1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

No longer require optional distribution section in advisory to extract TLP label

This commit is contained in:
JanHoefelmeyer 2023-06-16 14:10:54 +02:00
parent 5614939562
commit 8d269ce106

View file

@ -684,7 +684,7 @@ func (p *processor) integrity(
// Extract the tlp level of the entry
if tlpa, err := p.expr.Eval(
`$.document.distribution`, doc); err != nil {
`$.document`, doc); err != nil {
p.badROLIEFeed.error(
"Extracting 'tlp level' from %s failed: %v", u, err)
} else {
@ -810,7 +810,9 @@ func (p *processor) integrity(
// extractTLP tries to extract a valid TLP label from an advisory
// Returns "UNLABELED" if it does not exist, the label otherwise
func extractTLP(tlpa any) csaf.TLPLabel {
if distribution, ok := tlpa.(map[string]any); ok {
if document, ok := tlpa.(map[string]any); ok {
if distri, ok := document["distribution"]; ok {
if distribution, ok := distri.(map[string]any); ok {
if tlp, ok := distribution["tlp"]; ok {
if label, ok := tlp.(map[string]any); ok {
if labelstring, ok := label["label"].(string); ok {
@ -819,6 +821,8 @@ func extractTLP(tlpa any) csaf.TLPLabel {
}
}
}
}
}
return csaf.TLPLabelUnlabeled
}