-
Notifications
You must be signed in to change notification settings - Fork 0
DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
222dfc3
to
d3b55a9
Compare
…crets as files via volumes instead of exposing them as environment variables in containers.
d3b55a9
to
d4efd4d
Compare
…ainer-must-not-consume-secrets-as-env-vars
@@ -15,4 +15,4 @@ type: application | |||
# This is the chart version. This version number should be incremented each time you make changes | |||
# to the chart and its templates, including the app version. | |||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | |||
version: 0.0.1 | |||
version: 0.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to bump version directly on the Chart.yaml file. it automatically bumped as part of release pipeline.
@@ -18,6 +18,7 @@ spec: | |||
secretName: {{ .name }}-secret | |||
{{- end }} | |||
serverHostname: {{ .serverHostname }} | |||
useSecretAsEnvVars: {{ .useSecretAsEnvVars | default true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider wrap it with if condition. because I might use newer version of lightrun-agents chart with an old values that not necessary has this field and I assume it will cause template error.
useSecretAsEnvVars: {{ .useSecretAsEnvVars | default true }} | |
{{- if .useSecretAsEnvVars }} | |
useSecretAsEnvVars: {{ .useSecretAsEnvVars }} | |
{{- end }} |
@@ -72,19 +70,21 @@ func (r *LightrunJavaAgentReconciler) patchDeployment(lightrunJavaAgent *agentv1 | |||
if err != nil { | |||
return err | |||
} | |||
deploymentApplyConfig.Spec.Template.Spec.WithSecurityContext( | |||
corev1ac.PodSecurityContext(). | |||
WithFSGroup(1000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithReadOnlyRootFilesystem(true). | ||
WithAllowPrivilegeEscalation(false). | ||
WithRunAsNonRoot(true). | ||
WithRunAsUser(1000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we had to change the entire securityContext?
before (old operator):
securityContext:
capabilities:
drop:
- ALL
runAsNonRoot: true
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
after (this operator):
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
In particular the drop capabilities and seccompProfile and hardcode the user id.
I assume it might not work on openshift clusters.
WithReadOnlyRootFilesystem(true). | ||
WithAllowPrivilegeEscalation(false). | ||
WithRunAsNonRoot(true). | ||
WithRunAsUser(1000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as my previous comment
@@ -335,7 +392,7 @@ func (r *LightrunJavaAgentReconciler) patchStatefulSetAppContainers(lightrunJava | |||
WithName(container.Name). | |||
WithImage(container.Image). | |||
WithVolumeMounts( | |||
corev1ac.VolumeMount().WithMountPath(lightrunJavaAgent.Spec.InitContainer.SharedVolumeMountPath).WithName(lightrunJavaAgent.Spec.InitContainer.SharedVolumeName), | |||
corev1ac.VolumeMount().WithName(lightrunJavaAgent.Spec.InitContainer.SharedVolumeName).WithMountPath(lightrunJavaAgent.Spec.InitContainer.SharedVolumeMountPath), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason for this change, you basically switch the position of WithName() and WithMountPath()
it creates inconsistency of the other function that patch deployment
corev1ac.VolumeMount().WithMountPath(lightrunJavaAgent.Spec.InitContainer.SharedVolumeMountPath).WithName(lightrunJavaAgent.Spec.InitContainer.SharedVolumeName), |
Please revert this line
|
||
COPY lightrun-init-agent/$FILE /tmp/$FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you removed the relative path? it probably won't work during building the image as part of release pipeline because of incorrect context
|
||
USER 1000 | ||
COPY lightrun-init-agent/update_config.sh /update_config.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as my previous comment
# Copy and set permissions for update_config.sh before switching user | ||
COPY update_config.sh /update_config.sh | ||
RUN chmod 750 /update_config.sh && \ | ||
chown 1000:1000 /update_config.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is relevant to all lines above that modify permissions. I do not think it will work in openshift, please see comment -
# In openshift UID will be dynamic per project, hence procide permissions to root group (defualt in k8s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments
No description provided.