Skip to content

Commit 23aa9b4

Browse files
wip: improved the bit of log formatting
Signed-off-by: Rahul Vishwakarma <[email protected]>
1 parent d72b936 commit 23aa9b4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
APP_NAME = k8s-custom-controller
22
DOCKER_USER = manzilrahul
3-
VERSION ?= 1.0.14
3+
VERSION ?= 1.0.15
44
IMAGE_NAME = $(DOCKER_USER)/$(APP_NAME)
55

66
# 🖼️ Logo banner

main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func scanImageWithTrivy(image string) (bool, string, error) {
205205
}
206206
// Check if vulnerabilities found
207207
vulns := []string{}
208+
log.Println("❗CVEs Found: ")
208209
if results, ok := result["Results"].([]interface{}); ok {
209210
for _, r := range results {
210211
rmap := r.(map[string]interface{})
@@ -213,7 +214,9 @@ func scanImageWithTrivy(image string) (bool, string, error) {
213214
vmap := v.(map[string]interface{})
214215
severity := vmap["Severity"].(string)
215216
if severity == "HIGH" || severity == "CRITICAL" {
216-
vulns = append(vulns, vmap["VulnerabilityID"].(string))
217+
msg := fmt.Sprintf(" - 🔥 %s\n", vmap["VulnerabilityID"].(string))
218+
//vulns = append(vulns, vmap["VulnerabilityID"].(string))
219+
vulns = append(vulns, msg)
217220
}
218221
}
219222
}
@@ -262,12 +265,19 @@ func ValidateDeployment(w http.ResponseWriter, r *http.Request) {
262265
images = append(images, c.Image)
263266
}
264267
for _, image := range images {
265-
log.Printf("started scanning for [ %s ]", image)
268+
log.Println("────────────────────────────────────────────────────")
269+
log.Printf("🛡️ Deployment Image Scanning Started : %s\n", image)
270+
if BYPASS_CVE_DENIED {
271+
log.Println("📦 BYPASS_CVE_DENIED: true/yes")
272+
} else {
273+
log.Println("📦 BYPASS_CVE_DENIED: default(false/no)")
274+
}
266275
ok, vulns, err := scanImageWithTrivy(image)
267276
if err != nil {
268277
log.Printf("Error scanning image %s: %v", image, err)
269278
continue
270279
}
280+
log.Println("────────────────────────────────────────────────────")
271281
if !ok {
272282
denied = true
273283
reasons = append(reasons, fmt.Sprintf("%s (CVE: %s)", image, vulns))

manifest/k8s-controller-webhook.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
spec:
6868
containers:
6969
- name: k8s-controller
70-
image: manzilrahul/k8s-custom-controller:1.0.14
70+
image: manzilrahul/k8s-custom-controller:1.0.15
7171
volumeMounts:
7272
- name: webhook-certs
7373
mountPath: /certs

0 commit comments

Comments
 (0)