| 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 | } |