Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test: unblock the leak guard, pin reserved-name teardown at the reconciler

Jose Ramirez560d252097fc
diff --git a/packages/workflow-runtime-core/tests/unit/registry-image.test.ts b/packages/workflow-runtime-core/tests/unit/registry-image.test.ts
index 6ff7b1cc6..cbd6f714d 100644
--- a/packages/workflow-runtime-core/tests/unit/registry-image.test.ts
+++ b/packages/workflow-runtime-core/tests/unit/registry-image.test.ts
@@ -66,7 +66,13 @@ describe('isPlatformRegistryImage', () => {
it('does not match on a host suffix or a lookalike host', () => {
// A naive `endsWith`/`includes` would wrongly accept an attacker-controlled host.
- expect(isPlatformRegistryImage('evil-registry.evenfire.ai/x/y:1', REGISTRY_URL)).toBe(false)
+ // The prefix case uses a neutral domain (the infra-identifier CI guard allows only
+ // registry/registration/brain `.evenfire.ai` in the public tree); the property under
+ // test is unchanged — `'evil-registry.example.com'.endsWith('registry.example.com')`
+ // is true, so only an exact host comparison rejects it.
+ expect(
+ isPlatformRegistryImage('evil-registry.example.com/x/y:1', 'https://registry.example.com')
+ ).toBe(false)
expect(isPlatformRegistryImage('registry.evenfire.ai.evil.com/x/y:1', REGISTRY_URL)).toBe(false)
})
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index a4d0a0b62..1748c4b47 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.257",
+ "version": "0.1.258",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.257",
+ "version": "0.1.258",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index e225b0095..1a2ff461c 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.257",
+ "version": "0.1.258",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/reconciler/platformPullSecret.test.ts b/workflow-recipes/src/reconciler/platformPullSecret.test.ts
index 4b843d096..5e9c085e1 100644
--- a/workflow-recipes/src/reconciler/platformPullSecret.test.ts
+++ b/workflow-recipes/src/reconciler/platformPullSecret.test.ts
@@ -9,6 +9,14 @@
*
* These tests pin both halves: the injection happens for our images, and the credential
* stays unreachable to recipe-authored references.
+ *
+ * Layering note — these are BUILDER tests, not reconciler tests. The builders are the
+ * normalization layer (filter the declared names, then append ours exactly once). The
+ * authoritative gate for a recipe that declares the reserved name lives one level up, in
+ * the reconciler's ownership pass: a `denied` imagePullSecrets ref denies the whole
+ * WORKLOAD, which is then torn down rather than rendered. Cases below that feed the
+ * builders a `denied` access map are pinning the lower layer; see each one for how (or
+ * whether) production reaches it.
*/
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { EVENFIRE_REGISTRY_PULL_SECRET_NAME } from '@clerum/workflow-runtime-core'
@@ -87,10 +95,16 @@ describe('pod template — platform pull secret injection', () => {
])
})
- it('injects even though the #637 filter would DENY a recipe-declared reference', () => {
- // The credential is unlabeled to the ownership model, so a recipe naming it is denied.
- // Injection happens after that filter, so the workload still gets a working pull —
- // and exactly once.
+ it('normalizes a denied recipe-declared reference: stripped, then injected exactly once', () => {
+ // Defense-in-depth on the normalization layer — NOT the path a recipe author hits.
+ // A recipe that declares the reserved name is denied and TORN DOWN by the reconciler
+ // (collectSecretOwnership counts imagePullSecrets refs into deniedWorkloadIds, and the
+ // workload is never rendered), so this input does not reach the builder that way.
+ // It does reach it via the StatefulSet revocation re-render: teardownDeniedWorkload
+ // re-renders the StatefulSet with the denied access map to strip the credential, and
+ // that goes through this same shared buildPodTemplate. The property pinned here is
+ // that re-entry with a denied map still yields the injected name once, not zero or
+ // twice.
const access = new Map<string, SecretAccess>([
[EVENFIRE_REGISTRY_PULL_SECRET_NAME, { state: 'denied' }],
])
@@ -116,7 +130,13 @@ describe('McpServer delegation — platform pull secret injection', () => {
expect(mcpPullNames({ image: FOREIGN_IMAGE })).not.toContain(EVENFIRE_REGISTRY_PULL_SECRET_NAME)
})
- it('injects past a denied recipe-declared reference', () => {
+ it('normalizes a denied recipe-declared reference on the delegation path too', () => {
+ // Also defense-in-depth, and more strictly so than the pod-template case: a transport
+ // workload with a denied ref is filtered out in preDeployMcpServers before this builder
+ // is called, and the reconciler tears the workload down anyway. Kept because
+ // buildMcpServerManifest is the last checkpoint before HCC — which materializes
+ // spec.imagePullSecrets verbatim — so the filter-then-inject order must hold here
+ // independently of the caller that happens to guard it today.
const access = new Map<string, SecretAccess>([
[EVENFIRE_REGISTRY_PULL_SECRET_NAME, { state: 'denied' }],
])
diff --git a/workflow-recipes/src/reconciler/reconciler.test.ts b/workflow-recipes/src/reconciler/reconciler.test.ts
index 098710e33..72819b2fe 100644
--- a/workflow-recipes/src/reconciler/reconciler.test.ts
+++ b/workflow-recipes/src/reconciler/reconciler.test.ts
@@ -3,6 +3,7 @@ import * as k8s from '@kubernetes/client-node'
import { loadAll } from 'js-yaml'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
+import { EVENFIRE_REGISTRY_PULL_SECRET_NAME } from '@clerum/workflow-runtime-core'
import { loadConfig } from '../config'
import { CronJobDef, WorkflowRecipeCRD, WorkflowRecipeGfsIntentSpec, WorkloadDef } from '../types'
import { INHERITED_PARENT_RESOURCES_ANNOTATION } from '../workflow/childRecipeFactory'
@@ -4440,6 +4441,57 @@ describe('WorkflowRecipeReconciler', () => {
})
})
+ it('DENIES and tears down a workload that declares the reserved platform pull secret (Issue #637)', async () => {
+ // The orchestrator-level counterpart to the builder tests in platformPullSecret.test.ts.
+ // The platform credential is injected, never declared: control-api labels it
+ // `managed-by=control-api` only, which is *unlabeled* to the #637 ownership model. So a
+ // recipe that names it in imagePullSecrets does NOT get "the declared copy stripped and
+ // ours injected" — the whole WORKLOAD is denied here, in the reconciler, and torn down
+ // instead of rendered. This is the authoritative gate; the builders only normalize.
+ mockCoreApi.readNamespacedSecret.mockImplementation((args: { name: string }) =>
+ args.name === EVENFIRE_REGISTRY_PULL_SECRET_NAME
+ ? Promise.resolve({
+ metadata: {
+ resourceVersion: '1',
+ // Exactly what registryPullSecretService writes — provenance only, no
+ // owner-recipe/shared label (labelling it `shared` would open the envSecret
+ // exfiltration path, so it must stay denied).
+ labels: { 'clerum.io/managed-by': 'control-api' },
+ },
+ type: 'kubernetes.io/dockerconfigjson',
+ data: { '.dockerconfigjson': 'eA==' },
+ })
+ : Promise.resolve({ metadata: { resourceVersion: '1' } })
+ )
+
+ const recipe = makeRecipe({
+ spec: {
+ workloads: [
+ {
+ id: 'app',
+ type: 'deployment',
+ image: 'registry.evenfire.ai/acme/plugin:1.0',
+ port: 8080,
+ imagePullSecrets: [EVENFIRE_REGISTRY_PULL_SECRET_NAME],
+ },
+ ],
+ },
+ })
+
+ const r = await reconciler.reconcile(recipe)
+
+ const cond = (r.secretOwnershipConditions ?? []).find(
+ c => c.type === 'EnvSecretOwnershipDenied'
+ )
+ expect(cond?.status).toBe('True')
+ expect(cond?.message).toContain(EVENFIRE_REGISTRY_PULL_SECRET_NAME)
+ expect(r.workloadStatuses[0]).toMatchObject({ id: 'app', phase: 'failed', ready: false })
+
+ // Not rendered — and any prior instance torn down (revocation, not a silent strip).
+ expect(mockAppsApi.createNamespacedDeployment).not.toHaveBeenCalled()
+ expect(mockAppsApi.deleteNamespacedDeployment).toHaveBeenCalled()
+ })
+
it('surfaces EnvSecretOwnershipDenied from the WORKFLOW build path (Issue #637)', async () => {
const workflowReconcile = vi.fn().mockResolvedValue({
phase: 'deploying',