mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Merge pull request #633 from gocsaf/check-prefix-url
Check if canonical url prefix is valid
This commit is contained in:
commit
4066704c1a
1 changed files with 9 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
|
@ -262,6 +263,14 @@ func loadConfig() (*config, error) {
|
|||
if cfg.CanonicalURLPrefix == "" {
|
||||
cfg.CanonicalURLPrefix = "https://" + os.Getenv("SERVER_NAME")
|
||||
}
|
||||
// Check if canonical url prefix is invalid
|
||||
parsedURL, err := url.ParseRequestURI(cfg.CanonicalURLPrefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if parsedURL.Scheme != "https" && parsedURL.Scheme != "http" {
|
||||
return nil, fmt.Errorf("invalid canonical URL: %q", cfg.CanonicalURLPrefix)
|
||||
}
|
||||
|
||||
if cfg.TLPs == nil {
|
||||
cfg.TLPs = []tlp{tlpCSAF, tlpWhite, tlpGreen, tlpAmber, tlpRed}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue