fix: Resolving several identified vulnerabilities

This commit is contained in:
Ravikiran Kondapaneni 2025-07-30 01:35:28 -07:00
parent 76f9cea516
commit bc35a17f24
8 changed files with 238 additions and 178 deletions

View file

@ -3,13 +3,14 @@ package mocks
import (
"encoding/json"
"fmt"
"github.com/onsi/ginkgo"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/onsi/ginkgo"
t "github.com/containrrr/watchtower/pkg/types"
"github.com/docker/docker/api/types"
@ -260,14 +261,18 @@ func RemoveImageHandler(imagesWithParents map[string][]string) http.HandlerFunc
func(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(r.URL.Path, `/`)
image := parts[len(parts)-1]
if parents, found := imagesWithParents[image]; found {
items := []types.ImageDeleteResponseItem{
// Create a struct type that matches what Docker API returns for image removal
type imageDeleteResponseItem struct {
Untagged string `json:"Untagged,omitempty"`
Deleted string `json:"Deleted,omitempty"`
}
items := []imageDeleteResponseItem{
{Untagged: image},
{Deleted: image},
}
for _, parent := range parents {
items = append(items, types.ImageDeleteResponseItem{Deleted: parent})
items = append(items, imageDeleteResponseItem{Deleted: parent})
}
ghttp.RespondWithJSONEncoded(http.StatusOK, items)(w, r)
} else {