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

Improve joining of url paths in some situations

* Use url.JoinPath to join URLs from a few places.
* Add util/joinpath.go from go 1.19, add the license in REUSE 3.0 compatible manner.

resolve #223

Co-authored-by: Bernhard Reiter <bernhard@intevation.de>
This commit is contained in:
Sascha L. Teichmann 2022-07-18 17:41:52 +02:00 committed by GitHub
parent 324de3abca
commit 9cba4eec30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 388 additions and 3 deletions

View file

@ -639,7 +639,13 @@ func (p *processor) processROLIEFeed(feed string) error {
func (p *processor) checkIndex(base string, mask whereType) error {
client := p.httpClient()
index := base + "/index.txt"
bu, err := url.Parse(base)
if err != nil {
return err
}
index := util.JoinURLPath(bu, "index.txt").String()
p.checkTLS(index)
p.badIndices.use()
@ -680,9 +686,16 @@ func (p *processor) checkIndex(base string, mask whereType) error {
// of the fields' values and if they are sorted properly. Then it passes the files to the
// "integrity" functions. It returns error if some test fails, otherwise nil.
func (p *processor) checkChanges(base string, mask whereType) error {
client := p.httpClient()
changes := base + "/changes.csv"
bu, err := url.Parse(base)
if err != nil {
return err
}
changes := util.JoinURLPath(bu, "changes.csv").String()
p.checkTLS(changes)
client := p.httpClient()
res, err := client.Get(changes)
p.badChanges.use()