From c71a23580ddf940c67a61a56cee9d296163824ac Mon Sep 17 00:00:00 2001 From: koplas <54645365+koplas@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:04:44 +0200 Subject: [PATCH] Use public models for config --- cmd/csaf_downloader/config.go | 2 +- lib/downloader/config.go | 8 ++++---- lib/downloader/downloader.go | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/csaf_downloader/config.go b/cmd/csaf_downloader/config.go index e3c1bbc4..6a5978ac 100644 --- a/cmd/csaf_downloader/config.go +++ b/cmd/csaf_downloader/config.go @@ -233,7 +233,7 @@ func (cfg *config) GetDownloadConfig() (*downloader.Config, error) { ClientPassphrase: cfg.ClientPassphrase, Rate: cfg.Rate, Worker: cfg.Worker, - Range: (*[2]time.Time)(cfg.Range), + Range: cfg.Range, IgnorePattern: cfg.ignorePattern, ExtraHeader: cfg.ExtraHeader, diff --git a/lib/downloader/config.go b/lib/downloader/config.go index 60e07ad4..0a86166c 100644 --- a/lib/downloader/config.go +++ b/lib/downloader/config.go @@ -11,10 +11,10 @@ package downloader import ( "crypto/tls" "fmt" + "github.com/csaf-poc/csaf_distribution/v3/csaf/filter" + "github.com/csaf-poc/csaf_distribution/v3/csaf/models" "log/slog" "net/http" - "regexp" - "time" ) // ValidationMode specifies the strict the validation is. @@ -36,8 +36,8 @@ type Config struct { ClientPassphrase *string Rate *float64 Worker int - Range *[2]time.Time - IgnorePattern []*regexp.Regexp + Range *models.TimeRange + IgnorePattern filter.PatternMatcher ExtraHeader http.Header RemoteValidator string diff --git a/lib/downloader/downloader.go b/lib/downloader/downloader.go index f82625e8..dd4e6549 100644 --- a/lib/downloader/downloader.go +++ b/lib/downloader/downloader.go @@ -17,7 +17,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/csaf-poc/csaf_distribution/v3/csaf/models" "hash" "io" "log/slog" @@ -241,10 +240,9 @@ func (d *Downloader) download(ctx context.Context, domain string) error { // Do we need time range based filtering? if d.cfg.Range != nil { - timeRange := models.NewTimeInterval(d.cfg.Range[0], d.cfg.Range[1]) d.cfg.Logger.Debug("Setting up filter to accept advisories within", - "timerange", timeRange) - afp.AgeAccept = timeRange.Contains + "timerange", d.cfg.Range) + afp.AgeAccept = d.cfg.Range.Contains } return afp.Process(func(label csaf.TLPLabel, files []csaf.AdvisoryFile) error {