Skip to content

Commit

Permalink
Store invalid, unsafe advisories in special folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-l-teichmann committed Aug 25, 2023
1 parent 286cd1a commit d4da714
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/csaf_downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ type downloader struct {
mkdirMu sync.Mutex
}

// failedValidationDir is the name of the sub folder
// where advisories are stored that fail validation in
// unsafe mode.
const failedValidationDir = "failed_validation"

func newDownloader(cfg *config) (*downloader, error) {

var validator csaf.RemoteValidator
Expand Down Expand Up @@ -573,8 +578,13 @@ nextAdvisory:
}
initialReleaseDate = initialReleaseDate.UTC()

// Write advisory to file
newDir := path.Join(d.cfg.Directory, lower)
// Advisories that failed validation are store in a special folder.
var newDir string
if valStatus != validValidationStatus {
newDir = path.Join(d.cfg.Directory, failedValidationDir, lower)
} else {
newDir = path.Join(d.cfg.Directory, lower)
}

// Do we have a configured destination folder?
if d.cfg.Folder != "" {
Expand All @@ -591,6 +601,7 @@ nextAdvisory:
lastDir = newDir
}

// Write advisory to file
path := filepath.Join(lastDir, filename)

// Write data to disk.
Expand Down

0 comments on commit d4da714

Please sign in to comment.