1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

Add an option to downloader to store advisories into a given folder.

This commit is contained in:
Sascha L. Teichmann 2023-07-31 17:19:38 +02:00
parent 1d9969162f
commit 383b0ca77b
3 changed files with 14 additions and 1 deletions

View file

@ -29,6 +29,7 @@ type config struct {
Rate *float64 `long:"rate" short:"r" description:"The average upper limit of https operations per second (defaults to unlimited)" toml:"rate"`
Worker int `long:"worker" short:"w" description:"NUMber of concurrent downloads" value-name:"NUM" toml:"worker"`
Range *models.TimeRange `long:"timerange" short:"t" description:"RANGE of time from which advisories to download" value-name:"RANGE" toml:"timerange"`
Folder string `long:"folder" short:"f" description:"Download into a given FOLDER" value-name:"FOLDER" toml:"folder"`
ExtraHeader http.Header `long:"header" short:"H" description:"One or more extra HTTP header fields" toml:"header"`

View file

@ -474,8 +474,15 @@ nextAdvisory:
initialReleaseDate = initialReleaseDate.UTC()
// Write advisory to file
newDir := path.Join(d.directory, lower)
// 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(d.directory, lower, strconv.Itoa(initialReleaseDate.Year()))
if newDir != lastDir {
if err := d.mkdirAll(newDir, 0755); err != nil {
errorCh <- err

View file

@ -15,6 +15,7 @@ Application Options:
-r, --rate= The average upper limit of https operations per second (defaults to unlimited)
-w, --worker=NUM NUMber of concurrent downloads (default: 2)
-t, --timerange=RANGE RANGE of time from which advisories to download
-f, --folder=FOLDER Download into a given FOLDER
-H, --header= One or more extra HTTP header fields
--validator=URL URL to validate documents remotely
--validatorcache=FILE FILE to cache remote validations
@ -86,3 +87,7 @@ into a given intervall. There are three possible notations:
spans an interval from 1st January 2019 to the 1st January of 2024.
All interval boundaries are inclusive.
if the `folder` option is given the advisories are stored in this folder.
If it is omitted (by default) the advisories are stored in folder name by the
year they are from.