mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Check if canonical url prefix is valid
This commit is contained in:
parent
2f599ab017
commit
91b5b4543e
1 changed files with 9 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -262,6 +263,14 @@ func loadConfig() (*config, error) {
|
||||||
if cfg.CanonicalURLPrefix == "" {
|
if cfg.CanonicalURLPrefix == "" {
|
||||||
cfg.CanonicalURLPrefix = "https://" + os.Getenv("SERVER_NAME")
|
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 {
|
if cfg.TLPs == nil {
|
||||||
cfg.TLPs = []tlp{tlpCSAF, tlpWhite, tlpGreen, tlpAmber, tlpRed}
|
cfg.TLPs = []tlp{tlpCSAF, tlpWhite, tlpGreen, tlpAmber, tlpRed}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue