Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yitzhaktal
Copy link

No description provided.

@yitzhaktal yitzhaktal force-pushed the DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars branch 23 times, most recently from 222dfc3 to d3b55a9 Compare June 1, 2025 09:32
…crets as files via volumes instead of exposing them as environment variables in containers.
@yitzhaktal yitzhaktal force-pushed the DEVOPS-2694-security-lightrun-installer-container-must-not-consume-secrets-as-env-vars branch from d3b55a9 to d4efd4d Compare June 1, 2025 09:35
@yitzhaktal yitzhaktal requested review from imeliran and moshiko-s June 1, 2025 09:37
@@ -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
Copy link
Contributor

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 }}
Copy link
Contributor

@imeliran imeliran Jun 5, 2025

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.

Suggested change
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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this? it means we are overwriting customer's fsGroup on the pod level. if this is really needed why need to find an alternative way:
image

WithReadOnlyRootFilesystem(true).
WithAllowPrivilegeEscalation(false).
WithRunAsNonRoot(true).
WithRunAsUser(1000),
Copy link
Contributor

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),
Copy link
Contributor

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),
Copy link
Contributor

@imeliran imeliran Jun 5, 2025

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
Copy link
Contributor

@imeliran imeliran Jun 5, 2025

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
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor

@imeliran imeliran left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants