From 6430712dad7ce27c4b0c89b40a1bec60f53b3690 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Wed, 1 Feb 2023 01:36:54 +0100 Subject: [PATCH] Warn in checker and downloader if advisories are delivered as none 'application/json' --- cmd/csaf_checker/processor.go | 7 +++++++ cmd/csaf_downloader/downloader.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/cmd/csaf_checker/processor.go b/cmd/csaf_checker/processor.go index e62c1ca..60b623a 100644 --- a/cmd/csaf_checker/processor.go +++ b/cmd/csaf_checker/processor.go @@ -467,6 +467,13 @@ func (p *processor) integrity( continue } + // Warn if we do not get JSON. + if ct := res.Header.Get("Content-Type"); ct != "application/json" { + lg(WarnType, + "The content type of %s should be 'application/json but is '%s'", + u, ct) + } + s256 := sha256.New() s512 := sha512.New() data.Reset() diff --git a/cmd/csaf_downloader/downloader.go b/cmd/csaf_downloader/downloader.go index 5f10b60..45f8a05 100644 --- a/cmd/csaf_downloader/downloader.go +++ b/cmd/csaf_downloader/downloader.go @@ -281,6 +281,13 @@ func (d *downloader) downloadFiles(label csaf.TLPLabel, files []csaf.AdvisoryFil continue } + // Warn if we do not get JSON. + if ct := resp.Header.Get("Content-Type"); ct != "application/json" { + log.Printf( + "WARN: The content type of %s should be 'application/json but is '%s'\n", + file.URL(), ct) + } + var ( writers []io.Writer s256, s512 hash.Hash