Beispiel #1
0
func (fetcher *NVDMetadataFetcher) AddMetadata(vulnerability *updater.VulnerabilityWithLock) error {
	fetcher.lock.Lock()
	defer fetcher.lock.Unlock()

	if nvdMetadata, ok := fetcher.metadata[vulnerability.Name]; ok {
		vulnerability.Lock.Lock()

		// Create Metadata map if necessary and assign the NVD metadata.
		if vulnerability.Metadata == nil {
			vulnerability.Metadata = make(map[string]interface{})
		}
		vulnerability.Metadata[metadataKey] = nvdMetadata

		// Set the Severity using the CVSSv2 Score if none is set yet.
		if vulnerability.Severity == "" || vulnerability.Severity == types.Unknown {
			vulnerability.Severity = scoreToPriority(nvdMetadata.CVSSv2.Score)
		}

		vulnerability.Lock.Unlock()
	}

	return nil
}
Beispiel #2
0
func (fetcher *NVDMetadataFetcher) AddMetadata(vulnerability *updater.VulnerabilityWithLock) error {
	fetcher.lock.Lock()
	defer fetcher.lock.Unlock()

	if nvdMetadata, ok := fetcher.metadata[vulnerability.Name]; ok {
		vulnerability.Lock.Lock()
		defer vulnerability.Lock.Unlock()

		// Create Metadata map if necessary.
		if vulnerability.Metadata == nil {
			vulnerability.Metadata = make(map[string]interface{})
		}

		vulnerability.Metadata[metadataKey] = nvdMetadata
	}

	return nil
}