diff --git a/go/core/internal/controller/translator/agent/manifest_builder.go b/go/core/internal/controller/translator/agent/manifest_builder.go index a342cc3c6..615eed930 100644 --- a/go/core/internal/controller/translator/agent/manifest_builder.go +++ b/go/core/internal/controller/translator/agent/manifest_builder.go @@ -303,7 +303,7 @@ func buildPodRuntime( volumeMounts = append(volumeMounts, manifestCtx.deployment.VolumeMounts...) needCodeExecIsolation := cfg != nil && cfg.GetExecuteCode() - initContainers, skillsInitCM, err := buildSkillsRuntime(manifestCtx, &sharedEnv, &volumes, &volumeMounts, &needCodeExecIsolation) + initContainers, skillsInitCM, err := buildSkillsRuntime(manifestCtx, &sharedEnv, &volumes, &volumeMounts) if err != nil { return nil, err } @@ -399,7 +399,6 @@ func buildSkillsRuntime( sharedEnv *[]corev1.EnvVar, volumes *[]corev1.Volume, volumeMounts *[]corev1.VolumeMount, - needCodeExecIsolation *bool, ) ([]corev1.Container, *corev1.ConfigMap, error) { spec := manifestCtx.agent.GetAgentSpec() if spec.Skills == nil { @@ -412,7 +411,6 @@ func buildSkillsRuntime( return nil, nil, nil } - *needCodeExecIsolation = true *sharedEnv = append(*sharedEnv, corev1.EnvVar{ Name: env.KagentSkillsFolder.Name(), Value: "/skills", @@ -445,7 +443,7 @@ func buildSkillsRuntime( spec.Skills.GitAuthSecretRef, skills, spec.Skills.InsecureSkipVerify, - manifestCtx.deployment.SecurityContext, + buildContainerSecurityContext(manifestCtx.deployment.SecurityContext, false), initEnv, getDefaultResources(initResources), spec.Skills.ImagePullSecrets, @@ -488,12 +486,28 @@ func buildContainerSecurityContext( } if !needCodeExecIsolation { - return nil + return restrictedSecurityContext() } return &corev1.SecurityContext{Privileged: new(true)} } +// restrictedSecurityContext satisfies the Pod Security Standards "restricted" +// profile, so agents are admitted on clusters enforcing it without a +// per-agent securityContext override. +func restrictedSecurityContext() *corev1.SecurityContext { + return &corev1.SecurityContext{ + AllowPrivilegeEscalation: new(false), + RunAsNonRoot: new(true), + Capabilities: &corev1.Capabilities{ + Drop: []corev1.Capability{"ALL"}, + }, + SeccompProfile: &corev1.SeccompProfile{ + Type: corev1.SeccompProfileTypeRuntimeDefault, + }, + } +} + func buildPodTemplate( manifestCtx manifestContext, runtimeInputs *podRuntimeInputs, diff --git a/go/core/internal/controller/translator/agent/security_context_test.go b/go/core/internal/controller/translator/agent/security_context_test.go index ae7149ea1..8a810fd7b 100644 --- a/go/core/internal/controller/translator/agent/security_context_test.go +++ b/go/core/internal/controller/translator/agent/security_context_test.go @@ -195,9 +195,11 @@ func TestSecurityContext_OnlyPodSecurityContext(t *testing.T) { assert.Equal(t, int64(2000), *podSecurityContext.RunAsUser) assert.Equal(t, int64(2000), *podSecurityContext.RunAsGroup) - // Container security context should be nil if not specified + // Container security context defaults to the restricted-PSS profile when + // not specified; the pod-level settings are preserved alongside. containerSecurityContext := podTemplate.Spec.Containers[0].SecurityContext - assert.Nil(t, containerSecurityContext, "Container securityContext should be nil when not specified") + require.NotNil(t, containerSecurityContext) + assertRestrictedSecurityContext(t, containerSecurityContext) } func TestSecurityContext_OnlyContainerSecurityContext(t *testing.T) { @@ -278,7 +280,11 @@ func TestSecurityContext_OnlyContainerSecurityContext(t *testing.T) { // TestSecurityContext_SkillsDefaultPrivilegedSandbox verifies that when skills are // configured and the user has NOT set any securityContext (i.e., no PSS restriction), // the controller sets Privileged=true so that srt/bubblewrap can fully sandbox the BashTool. -func TestSecurityContext_SkillsDefaultPrivilegedSandbox(t *testing.T) { +// TestSecurityContext_SkillsDefaultNotPrivileged verifies that skills alone do +// not trigger Privileged=true: skills loading needs no elevated privileges, and +// only an explicit executeCodeBlocks opt-in requests the srt sandbox. Without a +// user-provided securityContext the containers get the restricted-PSS defaults. +func TestSecurityContext_SkillsDefaultNotPrivileged(t *testing.T) { ctx := context.Background() agent := &v1alpha2.Agent{ @@ -339,11 +345,120 @@ func TestSecurityContext_SkillsDefaultPrivilegedSandbox(t *testing.T) { podTemplate := &deployment.Spec.Template containerSecurityContext := podTemplate.Spec.Containers[0].SecurityContext - require.NotNil(t, containerSecurityContext, "SecurityContext should be created for sandbox") - // Without an explicit AllowPrivilegeEscalation=false constraint, skills trigger Privileged=true - // so that srt/bubblewrap can use kernel namespaces for full BashTool sandboxing. - require.NotNil(t, containerSecurityContext.Privileged, "Privileged should be set when no securityContext restriction") - assert.True(t, *containerSecurityContext.Privileged, "Privileged should be true for skills without PSS restrictions") + require.NotNil(t, containerSecurityContext) + assert.Nil(t, containerSecurityContext.Privileged, "skills alone must not trigger Privileged") + assertRestrictedSecurityContext(t, containerSecurityContext) + + require.NotEmpty(t, podTemplate.Spec.InitContainers, "skills agent must have the skills-init container") + initSecurityContext := podTemplate.Spec.InitContainers[0].SecurityContext + require.NotNil(t, initSecurityContext, "skills-init must get the restricted defaults too") + assert.Nil(t, initSecurityContext.Privileged) + assertRestrictedSecurityContext(t, initSecurityContext) +} + +func assertRestrictedSecurityContext(t *testing.T, securityContext *corev1.SecurityContext) { + t.Helper() + require.NotNil(t, securityContext.AllowPrivilegeEscalation) + assert.False(t, *securityContext.AllowPrivilegeEscalation) + require.NotNil(t, securityContext.RunAsNonRoot) + assert.True(t, *securityContext.RunAsNonRoot) + require.NotNil(t, securityContext.Capabilities) + assert.Equal(t, []corev1.Capability{"ALL"}, securityContext.Capabilities.Drop) + require.NotNil(t, securityContext.SeccompProfile) + assert.Equal(t, corev1.SeccompProfileTypeRuntimeDefault, securityContext.SeccompProfile.Type) +} + +// TestSecurityContext_ExecuteCodeBlocksKeepsPrivileged verifies that the +// explicit executeCodeBlocks opt-in still requests the privileged srt sandbox +// when the user did not restrict the securityContext. +func TestSecurityContext_ExecuteCodeBlocksKeepsPrivileged(t *testing.T) { + ctx := context.Background() + + executeCode := true + agent := &v1alpha2.Agent{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-agent", + Namespace: "test", + }, + Spec: v1alpha2.AgentSpec{ + Type: v1alpha2.AgentType_Declarative, + Declarative: &v1alpha2.DeclarativeAgentSpec{ + SystemMessage: "Test agent", + ModelConfig: "test-model", + ExecuteCodeBlocks: &executeCode, + }, + }, + } + + deployment := translateToDeployment(ctx, t, agent) + containerSecurityContext := deployment.Spec.Template.Spec.Containers[0].SecurityContext + require.NotNil(t, containerSecurityContext) + require.NotNil(t, containerSecurityContext.Privileged) + assert.True(t, *containerSecurityContext.Privileged, "executeCodeBlocks is the explicit sandbox opt-in") +} + +// TestSecurityContext_DefaultIsRestricted verifies that a plain agent (no +// skills, no code execution, no user securityContext) renders restricted-PSS +// compliant container security contexts. +func TestSecurityContext_DefaultIsRestricted(t *testing.T) { + ctx := context.Background() + + agent := &v1alpha2.Agent{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-agent", + Namespace: "test", + }, + Spec: v1alpha2.AgentSpec{ + Type: v1alpha2.AgentType_Declarative, + Declarative: &v1alpha2.DeclarativeAgentSpec{ + SystemMessage: "Test agent", + ModelConfig: "test-model", + }, + }, + } + + deployment := translateToDeployment(ctx, t, agent) + containerSecurityContext := deployment.Spec.Template.Spec.Containers[0].SecurityContext + require.NotNil(t, containerSecurityContext, "default securityContext must be rendered") + assert.Nil(t, containerSecurityContext.Privileged) + assertRestrictedSecurityContext(t, containerSecurityContext) +} + +func translateToDeployment(ctx context.Context, t *testing.T, agent *v1alpha2.Agent) *appsv1.Deployment { + t.Helper() + + modelConfig := &v1alpha2.ModelConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-model", + Namespace: "test", + }, + Spec: v1alpha2.ModelConfigSpec{ + Provider: "OpenAI", + Model: "gpt-4o", + }, + } + + scheme := schemev1.Scheme + require.NoError(t, v1alpha2.AddToScheme(scheme)) + + kubeClient := fake.NewClientBuilder(). + WithScheme(scheme). + WithObjects(agent, modelConfig). + Build() + + translatorInstance := translator.NewAdkApiTranslator(kubeClient, + types.NamespacedName{Namespace: "test", Name: "test-model"}, nil, "", nil) + + result, err := translator.TranslateAgent(ctx, translatorInstance, agent) + require.NoError(t, err) + + for _, obj := range result.Manifest { + if dep, ok := obj.(*appsv1.Deployment); ok { + return dep + } + } + t.Fatal("no Deployment in translated manifest") + return nil } // TestSecurityContext_SkillsPSSRestricted verifies that when a user explicitly sets diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_a2a_config.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_a2a_config.json index 55de74479..8310f8d60 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_a2a_config.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_a2a_config.json @@ -214,6 +214,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_allowed_headers.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_allowed_headers.json index 2d4778ab4..1247fe4b7 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_allowed_headers.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_allowed_headers.json @@ -224,6 +224,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_context_config.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_context_config.json index 50ad2fb36..3ed2abb8f 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_context_config.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_context_config.json @@ -235,6 +235,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_cross_namespace_tools.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_cross_namespace_tools.json index d1b1089ea..382bb0457 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_cross_namespace_tools.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_cross_namespace_tools.json @@ -230,6 +230,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_custom_sa.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_custom_sa.json index 118d63001..90b51a198 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_custom_sa.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_custom_sa.json @@ -183,6 +183,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_default_sa.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_default_sa.json index c4827d5bd..b9858b74c 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_default_sa.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_default_sa.json @@ -183,6 +183,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_embedding_provider.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_embedding_provider.json index c70478b36..b76605e7c 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_embedding_provider.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_embedding_provider.json @@ -230,6 +230,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_extra_containers.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_extra_containers.json index 67d7706ea..c00b5f0e0 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_extra_containers.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_extra_containers.json @@ -208,6 +208,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_git_skills.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_git_skills.json index 3b5f62049..3ea1cac87 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_git_skills.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_git_skills.json @@ -244,7 +244,16 @@ } }, "securityContext": { - "privileged": true + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } }, "volumeMounts": [ { @@ -277,6 +286,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/skills", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_http_toolserver.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_http_toolserver.json index 416f187be..8ba999d04 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_http_toolserver.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_http_toolserver.json @@ -223,6 +223,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_mcp_service.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_mcp_service.json index e0ae81e35..05f38d265 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_mcp_service.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_mcp_service.json @@ -219,6 +219,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_memory.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_memory.json index d9158ad17..e4bd60cf6 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_memory.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_memory.json @@ -219,6 +219,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_nested_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_nested_agent.json index 7068685bf..00d9f229c 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_nested_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_nested_agent.json @@ -217,6 +217,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_passthrough.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_passthrough.json index b5810b616..61b32ecff 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_passthrough.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_passthrough.json @@ -201,6 +201,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_prompt_template.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_prompt_template.json index 112c806af..a8c79d90c 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_prompt_template.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_prompt_template.json @@ -221,6 +221,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy.json index 6e6ca083c..8b0c6b7e3 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy.json @@ -230,6 +230,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_external_remotemcp.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_external_remotemcp.json index 7497960fc..fc0b716c3 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_external_remotemcp.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_external_remotemcp.json @@ -219,6 +219,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver.json index cb635cd25..ede190a12 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver.json @@ -222,6 +222,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver_custom_timeout.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver_custom_timeout.json index 515396315..8f4df8cf4 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver_custom_timeout.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_mcpserver_custom_timeout.json @@ -222,6 +222,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_service.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_service.json index ead7d57df..bc491d6b8 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_service.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_proxy_service.json @@ -221,6 +221,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_require_approval.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_require_approval.json index 3bf6e76e5..eb071061d 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_require_approval.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_require_approval.json @@ -225,6 +225,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_scheduling_attributes.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_scheduling_attributes.json index 5a36a40f2..aa3edbf9e 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_scheduling_attributes.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_scheduling_attributes.json @@ -234,6 +234,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_skills.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_skills.json index 2495c8cf6..00725833d 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_skills.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_skills.json @@ -244,7 +244,16 @@ } }, "securityContext": { - "privileged": true + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } }, "volumeMounts": [ { @@ -277,6 +286,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/skills", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_streaming.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_streaming.json index a3ad31fd8..e06c09327 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_streaming.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_streaming.json @@ -215,6 +215,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_configmap.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_configmap.json index 4b6b628ed..8844494e5 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_configmap.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_configmap.json @@ -208,6 +208,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_secret.json b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_secret.json index 1b8ab3d4b..a145fad88 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_secret.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/agent_with_system_message_from_secret.json @@ -208,6 +208,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/anthropic_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/anthropic_agent.json index 26fa3d726..be1f7391e 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/anthropic_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/anthropic_agent.json @@ -211,6 +211,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/basic_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/basic_agent.json index c24c0dcd9..06b7f1753 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/basic_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/basic_agent.json @@ -215,6 +215,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/bedrock_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/bedrock_agent.json index 582ae31ec..cf0152038 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/bedrock_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/bedrock_agent.json @@ -221,6 +221,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/byo_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/byo_agent.json index e1f03e859..e6484b8c2 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/byo_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/byo_agent.json @@ -186,6 +186,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/ollama_agent.json b/go/core/internal/controller/translator/agent/testdata/outputs/ollama_agent.json index 8e5e841d8..70aa59ba1 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/ollama_agent.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/ollama_agent.json @@ -210,6 +210,18 @@ "memory": "384Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-custom-ca.json b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-custom-ca.json index 3bb6b4a5b..fdc9fab7f 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-custom-ca.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-custom-ca.json @@ -213,6 +213,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-disabled-verify.json b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-disabled-verify.json index c465f7f5a..411458ec5 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-disabled-verify.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-disabled-verify.json @@ -212,6 +212,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-system-cas-disabled.json b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-system-cas-disabled.json index b52115141..f7fb8293c 100644 --- a/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-system-cas-disabled.json +++ b/go/core/internal/controller/translator/agent/testdata/outputs/tls-with-system-cas-disabled.json @@ -213,6 +213,18 @@ "memory": "684Mi" } }, + "securityContext": { + "allowPrivilegeEscalation": false, + "capabilities": { + "drop": [ + "ALL" + ] + }, + "runAsNonRoot": true, + "seccompProfile": { + "type": "RuntimeDefault" + } + }, "volumeMounts": [ { "mountPath": "/config", diff --git a/python/Dockerfile.full b/python/Dockerfile.full index 2d6c53695..deb74a938 100644 --- a/python/Dockerfile.full +++ b/python/Dockerfile.full @@ -70,7 +70,8 @@ RUN --mount=type=cache,target=/root/.npm \ ENV PATH="/opt/sandbox-runtime/node_modules/.bin:$PATH" -USER python +# Numeric USER so kubelet can verify runAsNonRoot without an explicit runAsUser. +USER 1001:1001 WORKDIR /.kagent ### STAGE 3: final (install project)