Skip to content

Commit

Permalink
Merge pull request #512 from csaf-poc/Download_without_tlp
Browse files Browse the repository at this point in the history
Downloader: Add tlp label to path if no custom directory is configured. Refactor accordingly
  • Loading branch information
JanHoefelmeyer authored Nov 21, 2023
2 parents 9e4a519 + 6f88701 commit 2fe836b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/csaf_downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,26 +621,28 @@ nextAdvisory:
continue
}

if err := d.eval.Extract(`$.document.tracking.initial_release_date`, dateExtract, false, doc); err != nil {
if err := d.eval.Extract(
`$.document.tracking.initial_release_date`, dateExtract, false, doc,
); err != nil {
slog.Warn("Cannot extract initial_release_date from advisory",
"url", file.URL())
initialReleaseDate = time.Now()
}
initialReleaseDate = initialReleaseDate.UTC()

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

// Do we have a configured destination folder?
if d.cfg.Folder != "" {
newDir = path.Join(newDir, d.cfg.Folder)
} else {
newDir = path.Join(newDir, strconv.Itoa(initialReleaseDate.Year()))
newDir = path.Join(newDir, lower, strconv.Itoa(initialReleaseDate.Year()))
}

if newDir != lastDir {
Expand Down

0 comments on commit 2fe836b

Please sign in to comment.