1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

Check if the file name is valid

This commit is contained in:
Sascha L. Teichmann 2023-01-30 08:29:54 +01:00
parent 6a60e8d8ce
commit a8493c0dd2

View file

@ -14,6 +14,7 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"path/filepath"
"github.com/csaf-poc/csaf_distribution/csaf" "github.com/csaf-poc/csaf_distribution/csaf"
"github.com/csaf-poc/csaf_distribution/util" "github.com/csaf-poc/csaf_distribution/util"
@ -68,6 +69,10 @@ func run(opts *options, files []string) error {
} }
for _, file := range files { for _, file := range files {
// Check if the file name is valid.
if !util.ConfirmingFileName(filepath.Base(file)) {
fmt.Printf("%q is not a valid advisory name.\n", file)
}
doc, err := loadJSONFromFile(file) doc, err := loadJSONFromFile(file)
if err != nil { if err != nil {
log.Printf("error: loading %q as JSON failed: %v\n", file, err) log.Printf("error: loading %q as JSON failed: %v\n", file, err)