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

Use public models for config

This commit is contained in:
koplas 2024-07-09 12:04:44 +02:00
parent 6255456f61
commit 4a810f0692
No known key found for this signature in database
3 changed files with 7 additions and 9 deletions

View file

@ -233,7 +233,7 @@ func (cfg *config) GetDownloadConfig() (*downloader.Config, error) {
ClientPassphrase: cfg.ClientPassphrase, ClientPassphrase: cfg.ClientPassphrase,
Rate: cfg.Rate, Rate: cfg.Rate,
Worker: cfg.Worker, Worker: cfg.Worker,
Range: (*[2]time.Time)(cfg.Range), Range: cfg.Range,
IgnorePattern: cfg.ignorePattern, IgnorePattern: cfg.ignorePattern,
ExtraHeader: cfg.ExtraHeader, ExtraHeader: cfg.ExtraHeader,

View file

@ -11,10 +11,10 @@ package downloader
import ( import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"github.com/csaf-poc/csaf_distribution/v3/csaf/filter"
"github.com/csaf-poc/csaf_distribution/v3/csaf/models"
"log/slog" "log/slog"
"net/http" "net/http"
"regexp"
"time"
) )
// ValidationMode specifies the strict the validation is. // ValidationMode specifies the strict the validation is.
@ -36,8 +36,8 @@ type Config struct {
ClientPassphrase *string ClientPassphrase *string
Rate *float64 Rate *float64
Worker int Worker int
Range *[2]time.Time Range *models.TimeRange
IgnorePattern []*regexp.Regexp IgnorePattern filter.PatternMatcher
ExtraHeader http.Header ExtraHeader http.Header
RemoteValidator string RemoteValidator string

View file

@ -17,7 +17,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/csaf-poc/csaf_distribution/v3/csaf/models"
"hash" "hash"
"io" "io"
"log/slog" "log/slog"
@ -244,10 +243,9 @@ func (d *Downloader) download(ctx context.Context, domain string) error {
// Do we need time range based filtering? // Do we need time range based filtering?
if d.cfg.Range != nil { 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", d.cfg.Logger.Debug("Setting up filter to accept advisories within",
"timerange", timeRange) "timerange", d.cfg.Range)
afp.AgeAccept = timeRange.Contains afp.AgeAccept = d.cfg.Range.Contains
} }
return afp.Process(func(label csaf.TLPLabel, files []csaf.AdvisoryFile) error { return afp.Process(func(label csaf.TLPLabel, files []csaf.AdvisoryFile) error {