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

Merge pull request #649 from gocsaf/url-join
Some checks failed
generate-markdown / auto-update-readme (push) Has been cancelled
Go / build (push) Has been cancelled
Go / run_modver (push) Has been cancelled

Use JoinPath
This commit is contained in:
Christoph Klassen 2025-06-26 08:18:39 +02:00 committed by GitHub
commit c833c00f84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 42 additions and 17 deletions

View file

@ -18,6 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/gocsaf/csaf/v3/internal/misc"
"io"
"log"
"net/http"
@ -635,7 +636,6 @@ func (p *processor) integrity(
if err != nil {
return err
}
makeAbs := makeAbsolute(b)
client := p.httpClient()
var data bytes.Buffer
@ -646,9 +646,8 @@ func (p *processor) integrity(
lg(ErrorType, "Bad URL %s: %v", f, err)
continue
}
fp = makeAbs(fp)
u := b.ResolveReference(fp).String()
u := misc.JoinURL(b, fp).String()
// Should this URL be ignored?
if p.cfg.ignoreURL(u) {
@ -780,8 +779,7 @@ func (p *processor) integrity(
lg(ErrorType, "Bad URL %s: %v", x.url(), err)
continue
}
hu = makeAbs(hu)
hashFile := b.ResolveReference(hu).String()
hashFile := misc.JoinURL(b, hu).String()
p.checkTLS(hashFile)
if res, err = client.Get(hashFile); err != nil {
@ -830,8 +828,7 @@ func (p *processor) integrity(
lg(ErrorType, "Bad URL %s: %v", f.SignURL(), err)
continue
}
su = makeAbs(su)
sigFile := b.ResolveReference(su).String()
sigFile := misc.JoinURL(b, su).String()
p.checkTLS(sigFile)
p.badSignatures.use()
@ -1378,7 +1375,7 @@ func (p *processor) checkSecurityFolder(folder string) string {
return err.Error()
}
u = base.ResolveReference(up).String()
u = misc.JoinURL(base, up).String()
p.checkTLS(u)
if res, err = client.Get(u); err != nil {
return fmt.Sprintf("Cannot fetch %s from security.txt: %v", u, err)
@ -1530,6 +1527,7 @@ func (p *processor) checkPGPKeys(_ string) error {
if err != nil {
return err
}
base.Path = ""
for i := range keys {
key := &keys[i]
@ -1543,7 +1541,7 @@ func (p *processor) checkPGPKeys(_ string) error {
continue
}
u := base.ResolveReference(up).String()
u := misc.JoinURL(base, up).String()
p.checkTLS(u)
res, err := client.Get(u)