github.1git.de/docker/cli@v26.1.3+incompatible/e2e/testutils/plugins/basic.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "net" 6 "net/http" 7 "os" 8 "path/filepath" 9 "time" 10 ) 11 12 // set by the compile flags to get around content sha being the same 13 var ( 14 UNIQUEME string 15 ) 16 17 func main() { 18 p, err := filepath.Abs(filepath.Join("run", "docker", "plugins")) 19 if err != nil { 20 panic(err) 21 } 22 if err := os.MkdirAll(p, 0o755); err != nil { 23 panic(err) 24 } 25 l, err := net.Listen("unix", filepath.Join(p, "basic.sock")) 26 if err != nil { 27 panic(err) 28 } 29 30 mux := http.NewServeMux() 31 server := http.Server{ 32 Addr: l.Addr().String(), 33 Handler: http.NewServeMux(), 34 ReadHeaderTimeout: 2 * time.Second, // G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server 35 } 36 mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { 37 w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1.1+json") 38 fmt.Println(w, `{"Implements": ["dummy"]}`) 39 }) 40 server.Serve(l) 41 }