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

add config flag to use enumerate-only

This commit is contained in:
Kunz, Immanuel 2024-04-23 20:24:18 +02:00
parent 457d519990
commit 005e661479
4 changed files with 21 additions and 23 deletions

View file

@ -169,9 +169,10 @@ func (d *downloader) enumerate(domain string) error {
client := d.httpClient()
loader := csaf.NewProviderMetadataLoader(client)
lpmd := loader.Enumerate(domain)
docs := []any{}
for _, pmd := range lpmd {
if d.cfg.verbose() {
for i := range pmd.Messages {
@ -181,22 +182,16 @@ func (d *downloader) enumerate(domain string) error {
}
}
if !pmd.Valid() {
return fmt.Errorf("invalid provider-metadata.json found for '%s'", domain)
}
_, err := url.Parse(pmd.URL)
if err != nil {
return fmt.Errorf("invalid URL found '%s': %v", pmd.URL, err)
}
// print the results
fmt.Println("Found provider-metadata file under URL", pmd.URL)
doc, err := json.MarshalIndent(pmd.Document, "", " ")
if err != nil {
slog.Error("Couldn't marshal PMD document json")
}
fmt.Println(string(doc))
docs = append(docs, pmd.Document)
}
// print the results
doc, err := json.MarshalIndent(docs, "", " ")
if err != nil {
slog.Error("Couldn't marshal PMD document json")
}
fmt.Println(string(doc))
return nil
}