Skip to content

Commit 8b7d852

Browse files
pengzhoumlPeng Zhou
andauthored
MLE-24592: Fix security issues raised by Polaris (#110)
Co-authored-by: Peng Zhou <[email protected]>
1 parent e0b1344 commit 8b7d852

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

config/default/manager_auth_proxy_patch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ spec:
1717
capabilities:
1818
drop:
1919
- "ALL"
20+
readOnlyRootFilesystem: true
2021
runAsNonRoot: true
2122
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
2223
args:

config/default/manager_config_patch.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ spec:
1515
capabilities:
1616
drop:
1717
- "ALL"
18+
readOnlyRootFilesystem: true
1819
runAsNonRoot: true

config/manager/manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ spec:
7979
capabilities:
8080
drop:
8181
- "ALL"
82+
readOnlyRootFilesystem: true
8283
runAsNonRoot: true
8384
livenessProbe:
8485
httpGet:

pkg/k8sutil/haProxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ func calculateHash(data map[string]string) string {
434434

435435
// Iterate over the sorted keys and write key-value pairs to the hash
436436
for _, k := range keys {
437-
hash.Write([]byte(k))
438-
hash.Write([]byte(data[k]))
437+
_, _ = hash.Write([]byte(k))
438+
_, _ = hash.Write([]byte(data[k]))
439439
}
440440

441441
// Get the final hash and convert to hexadecimal string

pkg/k8sutil/marklogicServer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,13 @@ func (cc *ClusterContext) ReconsileMarklogicCluster() (reconcile.Result, error)
187187
err = cc.Client.Create(ctx, markLogicGroupDef)
188188
if err != nil {
189189
logger.Error(err, "Failed to create markLogicCluster")
190+
return result.Error(err).Output()
190191
}
191192

192193
logger.Info("Created new MarkLogic Server resource")
193-
_, _ = result.Done().Output()
194194
} else {
195195
logger.Error(err, "Failed to get MarkLogicGroup resource")
196+
return result.Error(err).Output()
196197
}
197198
} else {
198199
patchDiff, err := patch.DefaultPatchMaker.Calculate(currentMlg, markLogicGroupDef,

pkg/k8sutil/statefulset.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,12 @@ func generatePVCTemplate(persistence *marklogicv1.Persistence) corev1.Persistent
543543
pvcTemplate := corev1.PersistentVolumeClaim{}
544544
pvcTemplate.CreationTimestamp = metav1.Time{}
545545
pvcTemplate.ObjectMeta.Name = "datadir"
546-
if persistence != nil && persistence.StorageClassName != "" {
546+
547+
if persistence == nil {
548+
return pvcTemplate
549+
}
550+
551+
if persistence.StorageClassName != "" {
547552
pvcTemplate.Spec.StorageClassName = &persistence.StorageClassName
548553
}
549554
pvcTemplate.Spec.AccessModes = persistence.AccessModes
@@ -557,8 +562,12 @@ func generatePVCTemplate(persistence *marklogicv1.Persistence) corev1.Persistent
557562
func getEnvironmentVariables(containerParams containerParameters) []corev1.EnvVar {
558563
envVars := []corev1.EnvVar{}
559564
groupName := "Default"
560-
if containerParams.GroupConfig != nil && containerParams.GroupConfig.Name != "" {
561-
groupName = containerParams.GroupConfig.Name
565+
enableXdqpSsl := false
566+
if containerParams.GroupConfig != nil {
567+
if containerParams.GroupConfig.Name != "" {
568+
groupName = containerParams.GroupConfig.Name
569+
}
570+
enableXdqpSsl = containerParams.GroupConfig.EnableXdqpSsl
562571
}
563572
envVars = append(envVars, corev1.EnvVar{
564573
Name: "MARKLOGIC_ADMIN_USERNAME_FILE",
@@ -580,7 +589,7 @@ func getEnvironmentVariables(containerParams containerParameters) []corev1.EnvVa
580589
Value: groupName,
581590
}, corev1.EnvVar{
582591
Name: "XDQP_SSL_ENABLED",
583-
Value: strconv.FormatBool(containerParams.GroupConfig.EnableXdqpSsl),
592+
Value: strconv.FormatBool(enableXdqpSsl),
584593
}, corev1.EnvVar{
585594
Name: "MARKLOGIC_CLUSTER_TYPE",
586595
Value: "bootstrap",

0 commit comments

Comments
 (0)