mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
fix incorrect usage of formatted string
output probably unchanged, but now `go vet` is happy that formatted strings are not misused
This commit is contained in:
parent
187d114631
commit
d1f33ab27d
3 changed files with 28 additions and 28 deletions
|
|
@ -536,7 +536,7 @@ func (p *processor) rolieFeedEntries(feed string) ([]csaf.AdvisoryFile, error) {
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
p.badProviderMetadata.error("%s: Validating against JSON schema failed:", feed)
|
p.badProviderMetadata.error("%s: Validating against JSON schema failed:", feed)
|
||||||
for _, msg := range errors {
|
for _, msg := range errors {
|
||||||
p.badProviderMetadata.error(strings.ReplaceAll(msg, `%`, `%%`))
|
p.badProviderMetadata.error("%s", strings.ReplaceAll(msg, `%`, `%%`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -736,7 +736,7 @@ func (p *processor) integrity(
|
||||||
|
|
||||||
switch date, fault := p.extractTime(doc, `initial_release_date`, u); {
|
switch date, fault := p.extractTime(doc, `initial_release_date`, u); {
|
||||||
case fault != "":
|
case fault != "":
|
||||||
p.badFolders.error(fault)
|
p.badFolders.error("%s", fault)
|
||||||
case folderYear == nil:
|
case folderYear == nil:
|
||||||
p.badFolders.error("No year folder found in %s", u)
|
p.badFolders.error("No year folder found in %s", u)
|
||||||
case date.UTC().Year() != *folderYear:
|
case date.UTC().Year() != *folderYear:
|
||||||
|
|
@ -744,7 +744,7 @@ func (p *processor) integrity(
|
||||||
}
|
}
|
||||||
current, fault := p.extractTime(doc, `current_release_date`, u)
|
current, fault := p.extractTime(doc, `current_release_date`, u)
|
||||||
if fault != "" {
|
if fault != "" {
|
||||||
p.badChanges.error(fault)
|
p.badChanges.error("%s", fault)
|
||||||
} else {
|
} else {
|
||||||
p.timesAdv[f.URL()] = current
|
p.timesAdv[f.URL()] = current
|
||||||
}
|
}
|
||||||
|
|
@ -814,7 +814,7 @@ func (p *processor) integrity(
|
||||||
msgType = InfoType
|
msgType = InfoType
|
||||||
}
|
}
|
||||||
for _, fetchError := range hashFetchErrors {
|
for _, fetchError := range hashFetchErrors {
|
||||||
p.badIntegrities.add(msgType, fetchError)
|
p.badIntegrities.add(msgType, "%s", fetchError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check signature
|
// Check signature
|
||||||
|
|
@ -1052,7 +1052,7 @@ func (p *processor) checkChanges(base string, mask whereType) error {
|
||||||
if p.cfg.Range != nil {
|
if p.cfg.Range != nil {
|
||||||
filtered = " (maybe filtered out by time interval)"
|
filtered = " (maybe filtered out by time interval)"
|
||||||
}
|
}
|
||||||
p.badChanges.warn("no entries in changes.csv found" + filtered)
|
p.badChanges.warn("%s", "no entries in changes.csv found"+filtered)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sort.SliceIsSorted(times, func(i, j int) bool {
|
if !sort.SliceIsSorted(times, func(i, j int) bool {
|
||||||
|
|
@ -1300,7 +1300,7 @@ func (p *processor) checkProviderMetadata(domain string) bool {
|
||||||
|
|
||||||
for i := range lpmd.Messages {
|
for i := range lpmd.Messages {
|
||||||
p.badProviderMetadata.warn(
|
p.badProviderMetadata.warn(
|
||||||
"Unexpected situation while loading provider-metadata.json: " +
|
"Unexpected situation while loading provider-metadata.json: %s",
|
||||||
lpmd.Messages[i].Message)
|
lpmd.Messages[i].Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1401,25 +1401,25 @@ func (p *processor) checkDNS(domain string) {
|
||||||
res, err := client.Get(path)
|
res, err := client.Get(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.badDNSPath.add(ErrorType,
|
p.badDNSPath.add(ErrorType,
|
||||||
fmt.Sprintf("Fetching %s failed: %v", path, err))
|
"Fetching %s failed: %v", path, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
p.badDNSPath.add(ErrorType, fmt.Sprintf("Fetching %s failed. Status code %d (%s)",
|
p.badDNSPath.add(ErrorType, "Fetching %s failed. Status code %d (%s)",
|
||||||
path, res.StatusCode, res.Status))
|
path, res.StatusCode, res.Status)
|
||||||
}
|
}
|
||||||
hash := sha256.New()
|
hash := sha256.New()
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
content, err := io.ReadAll(res.Body)
|
content, err := io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.badDNSPath.add(ErrorType,
|
p.badDNSPath.add(ErrorType,
|
||||||
fmt.Sprintf("Error while reading the response from %s", path))
|
"Error while reading the response from %s", path)
|
||||||
}
|
}
|
||||||
hash.Write(content)
|
hash.Write(content)
|
||||||
if !bytes.Equal(hash.Sum(nil), p.pmd256) {
|
if !bytes.Equal(hash.Sum(nil), p.pmd256) {
|
||||||
p.badDNSPath.add(ErrorType,
|
p.badDNSPath.add(ErrorType,
|
||||||
fmt.Sprintf("%s does not serve the same provider-metadata.json as previously found",
|
"%s does not serve the same provider-metadata.json as previously found",
|
||||||
path))
|
path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1433,12 +1433,12 @@ func (p *processor) checkWellknown(domain string) {
|
||||||
res, err := client.Get(path)
|
res, err := client.Get(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.badWellknownMetadata.add(ErrorType,
|
p.badWellknownMetadata.add(ErrorType,
|
||||||
fmt.Sprintf("Fetching %s failed: %v", path, err))
|
"Fetching %s failed: %v", path, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
p.badWellknownMetadata.add(ErrorType, fmt.Sprintf("Fetching %s failed. Status code %d (%s)",
|
p.badWellknownMetadata.add(ErrorType, "Fetching %s failed. Status code %d (%s)",
|
||||||
path, res.StatusCode, res.Status))
|
path, res.StatusCode, res.Status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1475,13 +1475,13 @@ func (p *processor) checkWellknownSecurityDNS(domain string) error {
|
||||||
// but found in the legacy location, and inform about finding it there (2).
|
// but found in the legacy location, and inform about finding it there (2).
|
||||||
switch warnings {
|
switch warnings {
|
||||||
case 0:
|
case 0:
|
||||||
p.badSecurity.add(InfoType, sDMessage)
|
p.badSecurity.add(InfoType, "%s", sDMessage)
|
||||||
case 1:
|
case 1:
|
||||||
p.badSecurity.add(ErrorType, sDMessage)
|
p.badSecurity.add(ErrorType, "%s", sDMessage)
|
||||||
p.badSecurity.add(ErrorType, sLMessage)
|
p.badSecurity.add(ErrorType, "%s", sLMessage)
|
||||||
case 2:
|
case 2:
|
||||||
p.badSecurity.add(WarnType, sDMessage)
|
p.badSecurity.add(WarnType, "%s", sDMessage)
|
||||||
p.badSecurity.add(InfoType, sLMessage)
|
p.badSecurity.add(InfoType, "%s", sLMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.checkDNS(domain)
|
p.checkDNS(domain)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ func TestUnmarshalText(t *testing.T) {
|
||||||
byteSlice := []byte{'3', 'h'}
|
byteSlice := []byte{'3', 'h'}
|
||||||
var emptySlice []byte
|
var emptySlice []byte
|
||||||
if testTimeRange.UnmarshalText(byteSlice) != nil {
|
if testTimeRange.UnmarshalText(byteSlice) != nil {
|
||||||
t.Errorf(testTimeRange.UnmarshalText(byteSlice).Error())
|
t.Error(testTimeRange.UnmarshalText(byteSlice).Error())
|
||||||
}
|
}
|
||||||
if testTimeRange.UnmarshalText(emptySlice) == nil {
|
if testTimeRange.UnmarshalText(emptySlice) == nil {
|
||||||
t.Errorf("Failure: UnmarshalText succeeded on invalid slice of bytes.")
|
t.Errorf("Failure: UnmarshalText succeeded on invalid slice of bytes.")
|
||||||
|
|
@ -104,10 +104,10 @@ func TestUnmarshalFlag(t *testing.T) {
|
||||||
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC))
|
||||||
if err := testTimeRange.UnmarshalFlag("3h"); err != nil {
|
if err := testTimeRange.UnmarshalFlag("3h"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05"); err != nil {
|
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05a"); err == nil {
|
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05a"); err == nil {
|
||||||
t.Errorf("Failure: Extracted time from invalid string")
|
t.Errorf("Failure: Extracted time from invalid string")
|
||||||
|
|
@ -119,7 +119,7 @@ func TestUnmarshalFlag(t *testing.T) {
|
||||||
t.Errorf("Failure: Extracted time from invalid string")
|
t.Errorf("Failure: Extracted time from invalid string")
|
||||||
}
|
}
|
||||||
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05, 2007-01-02T15:04:05"); err != nil {
|
if err := testTimeRange.UnmarshalFlag("2006-01-02T15:04:05, 2007-01-02T15:04:05"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ func TestParse(t *testing.T) {
|
||||||
cmd.Env = append(os.Environ(), "TEST_HELP=1")
|
cmd.Env = append(os.Environ(), "TEST_HELP=1")
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the version flag
|
// test the version flag
|
||||||
|
|
@ -104,7 +104,7 @@ func TestParse(t *testing.T) {
|
||||||
cmd.Env = append(os.Environ(), "TEST_VERSION=1")
|
cmd.Env = append(os.Environ(), "TEST_VERSION=1")
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ func TestLoadToml(t *testing.T) {
|
||||||
t.Errorf("Failure: Succeeded in parsing nonexistant parameter")
|
t.Errorf("Failure: Succeeded in parsing nonexistant parameter")
|
||||||
}
|
}
|
||||||
if err := loadTOML(&cfg, "data/config.toml"); err != nil {
|
if err := loadTOML(&cfg, "data/config.toml"); err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue