mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Merge pull request #352 from csaf-poc/fix_header
Fix header client. Simplify code.
This commit is contained in:
commit
6bceb7cc1b
6 changed files with 9 additions and 18 deletions
|
|
@ -916,7 +916,7 @@ func (p *processor) checkChanges(base string, mask whereType) error {
|
||||||
return p.integrity(files, base, mask, p.badChanges.add)
|
return p.integrity(files, base, mask, p.badChanges.add)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) processROLIEFeeds(domain string, feeds [][]csaf.Feed) error {
|
func (p *processor) processROLIEFeeds(feeds [][]csaf.Feed) error {
|
||||||
|
|
||||||
base, err := url.Parse(p.pmdURL)
|
base, err := url.Parse(p.pmdURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -953,7 +953,7 @@ func empty(arr []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) checkCSAFs(domain string) error {
|
func (p *processor) checkCSAFs(_ string) error {
|
||||||
// Check for ROLIE
|
// Check for ROLIE
|
||||||
rolie, err := p.expr.Eval("$.distributions[*].rolie.feeds", p.pmd)
|
rolie, err := p.expr.Eval("$.distributions[*].rolie.feeds", p.pmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -967,7 +967,7 @@ func (p *processor) checkCSAFs(domain string) error {
|
||||||
var feeds [][]csaf.Feed
|
var feeds [][]csaf.Feed
|
||||||
if err := util.ReMarshalJSON(&feeds, rolie); err != nil {
|
if err := util.ReMarshalJSON(&feeds, rolie); err != nil {
|
||||||
p.badProviderMetadata.error("ROLIE feeds are not compatible: %v.", err)
|
p.badProviderMetadata.error("ROLIE feeds are not compatible: %v.", err)
|
||||||
} else if err := p.processROLIEFeeds(domain, feeds); err != nil {
|
} else if err := p.processROLIEFeeds(feeds); err != nil {
|
||||||
if err != errContinue {
|
if err != errContinue {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -1299,7 +1299,7 @@ func (p *processor) checkWellknownSecurityDNS(domain string) error {
|
||||||
// the the remotely keys and compares the fingerprints.
|
// the the remotely keys and compares the fingerprints.
|
||||||
// As a result of these a respective error messages are passed to badPGP method
|
// As a result of these a respective error messages are passed to badPGP method
|
||||||
// in case of errors. It returns nil if all checks are passed.
|
// in case of errors. It returns nil if all checks are passed.
|
||||||
func (p *processor) checkPGPKeys(domain string) error {
|
func (p *processor) checkPGPKeys(_ string) error {
|
||||||
|
|
||||||
p.badPGPs.use()
|
p.badPGPs.use()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ func (c *controller) failed(rw http.ResponseWriter, tmpl string, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// index calls the "render" function and passes the "index.html" and c.cfg to it.
|
// index calls the "render" function and passes the "index.html" and c.cfg to it.
|
||||||
func (c *controller) index(rw http.ResponseWriter, r *http.Request) {
|
func (c *controller) index(rw http.ResponseWriter, _ *http.Request) {
|
||||||
c.render(rw, "index.html", map[string]any{
|
c.render(rw, "index.html", map[string]any{
|
||||||
"Config": c.cfg,
|
"Config": c.cfg,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,5 @@ func writeHashedFile(fname, name string, data []byte, armored string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Write signature.
|
// Write signature.
|
||||||
if err := os.WriteFile(fname+".asc", []byte(armored), 0644); err != nil {
|
return os.WriteFile(fname+".asc", []byte(armored), 0644)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,10 +298,7 @@ func (acp *AggregatorCSAFProvider) Validate() error {
|
||||||
if acp == nil {
|
if acp == nil {
|
||||||
return errors.New("aggregator.csaf_providers[] not allowed to be nil")
|
return errors.New("aggregator.csaf_providers[] not allowed to be nil")
|
||||||
}
|
}
|
||||||
if err := acp.Metadata.Validate(); err != nil {
|
return acp.Metadata.Validate()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates the current state of the Aggregator.
|
// Validate validates the current state of the Aggregator.
|
||||||
|
|
|
||||||
|
|
@ -163,10 +163,7 @@ func prepareCache(config string) (cache, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := b.Put(cacheVersionKey, cacheVersion); err != nil {
|
return b.Put(cacheVersionKey, cacheVersion)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b := tx.Bucket(validationsBucket)
|
b := tx.Bucket(validationsBucket)
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ func (hc *HeaderClient) Head(url string) (*http.Response, error) {
|
||||||
|
|
||||||
// Post implements the respective method of the [Client] interface.
|
// Post implements the respective method of the [Client] interface.
|
||||||
func (hc *HeaderClient) Post(url, contentType string, body io.Reader) (*http.Response, error) {
|
func (hc *HeaderClient) Post(url, contentType string, body io.Reader) (*http.Response, error) {
|
||||||
req, err := http.NewRequest(http.MethodPost, url, nil)
|
req, err := http.NewRequest(http.MethodPost, url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue