From fa07768448d9e7d7754c53689c29f39d5ca7295a Mon Sep 17 00:00:00 2001 From: Anurag Rajawat Date: Wed, 21 Aug 2024 01:22:10 +0530 Subject: [PATCH] fix(adapter): Fix panic on scanning external addresses Signed-off-by: Anurag Rajawat --- pkg/adapter/nimbus-k8tls/Dockerfile | 2 +- pkg/adapter/nimbus-k8tls/builder/builder.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/adapter/nimbus-k8tls/Dockerfile b/pkg/adapter/nimbus-k8tls/Dockerfile index 53569ab1..1b079f67 100644 --- a/pkg/adapter/nimbus-k8tls/Dockerfile +++ b/pkg/adapter/nimbus-k8tls/Dockerfile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2023 Authors of Nimbus -FROM golang:1.22 as builder +FROM golang:1.22 AS builder ARG TARGETOS ARG TARGETARCH diff --git a/pkg/adapter/nimbus-k8tls/builder/builder.go b/pkg/adapter/nimbus-k8tls/builder/builder.go index a2912acf..cda292e4 100644 --- a/pkg/adapter/nimbus-k8tls/builder/builder.go +++ b/pkg/adapter/nimbus-k8tls/builder/builder.go @@ -184,7 +184,7 @@ func cronJobForAssessTls(ctx context.Context, schedule string, externalAddresses if len(externalAddresses) > 0 { cm := buildConfigMap(externalAddresses) - cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].VolumeMounts = append(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ + cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].VolumeMounts = append(cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].VolumeMounts, corev1.VolumeMount{ Name: cm.Name, ReadOnly: true, MountPath: "/var/k8tls/", @@ -200,10 +200,11 @@ func cronJobForAssessTls(ctx context.Context, schedule string, externalAddresses }, }) - cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command[0] = "./tlsscan" - cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command = append(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command, + cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].Command[0] = "./tlsscan" + cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].Command = append(cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].Command, "--infile", - cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].VolumeMounts[2].MountPath+"addresses", + cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].VolumeMounts[2].MountPath+"addresses", + "--compact-json", ) return cj, cm }