diff --git a/cmd/csaf_provider/main.go b/cmd/csaf_provider/main.go index 53adbc3..fbe3dd7 100644 --- a/cmd/csaf_provider/main.go +++ b/cmd/csaf_provider/main.go @@ -13,6 +13,7 @@ import ( "log" "net/http" "net/http/cgi" + "os" "github.com/csaf-poc/csaf_distribution/util" "github.com/jessevdk/go-flags" @@ -22,6 +23,16 @@ type options struct { Version bool `long:"version" description:"Display version of the binary"` } +const cgiRequired = "The csaf_provider is a cgi binary and is designed to be served via a web server." + +func ensureCGI() { + if _, ok := os.LookupEnv("REQUEST_METHOD"); !ok { + fmt.Println(cgiRequired) + fmt.Println("Version: " + util.SemVersion) + os.Exit(1) + } +} + func main() { var opts options parser := flags.NewParser(&opts, flags.Default) @@ -31,6 +42,8 @@ func main() { return } + ensureCGI() + cfg, err := loadConfig() if err != nil { cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {