Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): reject LibreSSL before fixture key generation
Alfredo Lopezaed67365e723
diff --git a/deploy/overlays/minikube/patches/hcc-policy-resync.yaml b/deploy/overlays/minikube/patches/hcc-policy-resync.yamlindex 9dfde7192..ca4329ef0 100644--- a/deploy/overlays/minikube/patches/hcc-policy-resync.yaml+++ b/deploy/overlays/minikube/patches/hcc-policy-resync.yaml@@ -1,4 +1,7 @@# Keep the existing periodic repair active in the owned development lane.+# This applies to every HCC using this Minikube overlay, including sibling tests.+# A reused profile may reach a periodic tick during a test; gates must account for it.+# PR A temporarily uses 60s to exercise repair and restores this 3600s value.# The shared base remains unchanged; PR A does not change GKE cadence.apiVersion: apps/v1kind: Deploymentdiff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 56d1ed569..56f67dc1e 100644--- a/host-context-controller/package-lock.json+++ b/host-context-controller/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-host-context-controller",- "version": "0.1.318",+ "version": "0.1.319","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.318",+ "version": "0.1.319","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex e4729c558..96780e37e 100644--- a/host-context-controller/package.json+++ b/host-context-controller/package.json@@ -1,6 +1,6 @@{"name": "clerum-host-context-controller",- "version": "0.1.318",+ "version": "0.1.319","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.tsindex 698bf3834..5d4e3fc7a 100644--- a/host-context-controller/src/k8sClient.test.ts+++ b/host-context-controller/src/k8sClient.test.ts@@ -5848,7 +5848,7 @@ describe('McpServerWatcher startup', () => {errorSpy.mockRestore()})- it('retains repair and invalidates authority after a post-revocation additive failure', async () => {+ it('retains pending repair and schedules retry after a post-revocation additive failure', async () => {vi.useFakeTimers()const additiveFailure = new AggregateError([new Error('Context policy API unavailable')],@@ -5861,7 +5861,6 @@ describe('McpServerWatcher startup', () => {options?: { onAuthoritativeRevocationComplete?: () => void }) => {options?.onAuthoritativeRevocationComplete?.()- mocks.hasCertifiedSafetyInventory.mockReturnValue(false)throw additiveFailure})@@ -5873,10 +5872,11 @@ describe('McpServerWatcher startup', () => {vi.spyOn(watcher as any, 'startGlobalFileSystemWatch').mockResolvedValue(undefined)vi.spyOn(watcher as any, 'startCommunicationChannelWatch').mockResolvedValue(undefined)+ expect((watcher as any).networkPolicyRepairPending).toBe(false)await watcher.start()await vi.advanceTimersByTimeAsync(0)- expect(watcher.isReadinessInventoryAuthoritative()).toBe(false)+ expect((watcher as any).networkPolicyRepairPending).toBe(true)expect(errorSpy).toHaveBeenCalledWith('[K8s] Initial NetworkPolicy post-certification additive reconciliation failed:',{ err: additiveFailure }@@ -5886,6 +5886,10 @@ describe('McpServerWatcher startup', () => {{ err: additiveFailure })expect((watcher as any).initialConvergenceRetryTimers.has('NetworkPolicy')).toBe(true)+ await vi.advanceTimersByTimeAsync(5000)+ expect(mocks.netPolFullReconcile).toHaveBeenCalledTimes(2)+ expect((watcher as any).networkPolicyRepairPending).toBe(false)+ expect((watcher as any).initialConvergenceRetryTimers.has('NetworkPolicy')).toBe(false)await watcher.stop()errorSpy.mockRestore()@@ -12106,7 +12110,7 @@ describe('McpServerWatcher NetworkPolicy periodic resync (#478)', () => {it('M5: unset/0 interval warns, registers no timer, and still runs startup once', async () => {vi.useFakeTimers()mockConfig.netPolResyncIntervalSec = 0- const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})+ const warnSpy = vi.spyOn(hccLogger, 'warn').mockImplementation(() => {})const watcher = await startWatcherForNetPolResync()expect(mocks.netPolFullReconcile).toHaveBeenCalledTimes(1)expect(diff --git a/host-context-controller/src/k8sClient.ts b/host-context-controller/src/k8sClient.tsindex e180352f1..f8b966068 100644--- a/host-context-controller/src/k8sClient.ts+++ b/host-context-controller/src/k8sClient.ts@@ -2951,9 +2951,11 @@ export class McpServerWatcher implements McpServerProvider {cause: 'periodic-resync',})}, netPolResyncSec * 1000)- console.log(`[K8s] NetworkPolicy periodic resync enabled (every ${netPolResyncSec}s)`)+ hccLogger.info('[K8s] NetworkPolicy periodic resync enabled', {+ intervalSeconds: netPolResyncSec,+ })} else {- console.warn(+ hccLogger.warn('[K8s] NetworkPolicy periodic resync disabled; dropped watch events will not self-heal stale NetworkPolicy allows through controller-driven convergence until another Context or McpServer event triggers reconciliation.')}@@ -4698,10 +4700,10 @@ export class McpServerWatcher implements McpServerProvider {)}} catch (error) {- console.error(- `[K8s] NetworkPolicy reconciliation failed for context ${context.name}:`,- error- )+ hccLogger.error('[K8s] NetworkPolicy reconciliation failed for context', {+ contextName: context.name,+ err: error,+ })void this.runInitialNetworkPolicyConvergence({ cause: 'context-reconcile-failure' })return}diff --git a/scripts/e2e/_lib/hcc-watch-pr-a.sh b/scripts/e2e/_lib/hcc-watch-pr-a.shindex 3a9b5cd95..0b24d121b 100755--- a/scripts/e2e/_lib/hcc-watch-pr-a.sh+++ b/scripts/e2e/_lib/hcc-watch-pr-a.sh@@ -356,6 +356,7 @@ hcc_pr_a_preflight() {command -v "$command_name" >/dev/null || die "PR A requires installed ${command_name}"done[ "$(node -p 'process.versions.node.split(".")[0]')" = 24 ] || die 'PR A requires Node 24'+ node "$HCC_PR_A_LIB/hcc-watch-tls.mjs" || die 'PR A requires OpenSSL on PATH; LibreSSL is unsupported'openssl req -help 2>&1 | grep -q -- '-addext' || die 'PR A requires openssl req -addext'HCC_PR_A_CONFIG_SNAPSHOT="$(mktemp "${TMPDIR:-/tmp}/hcc-pr-a-public-config.XXXXXX")"chmod 600 "$HCC_PR_A_CONFIG_SNAPSHOT"diff --git a/scripts/e2e/_lib/hcc-watch-tls.mjs b/scripts/e2e/_lib/hcc-watch-tls.mjsindex 5fba6a413..487ee9f57 100644--- a/scripts/e2e/_lib/hcc-watch-tls.mjs+++ b/scripts/e2e/_lib/hcc-watch-tls.mjs@@ -3,12 +3,23 @@ import { spawnSync } from 'node:child_process'import { createPrivateKey, X509Certificate } from 'node:crypto'import { isIP } from 'node:net'+export function requireFixtureOpenSsl() {+ const version = spawnSync('openssl', ['version'], {+ encoding: 'utf8', timeout: 5000, maxBuffer: 4096, shell: false,+ })+ // LibreSSL treats -keyout - as a literal file, violating the memory-only fixture.+ if (version.status !== 0 || !/^OpenSSL /.test(version.stdout ?? '')) {+ throw new Error('fixture_openssl_required: put OpenSSL on PATH; LibreSSL is unsupported')+ }+}+export function createFixtureTls(hostname) {const ip = typeof hostname === 'string' && isIP(hostname)if (!ip && (typeof hostname !== 'string' ||!/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(hostname))) {throw new Error('invalid_fixture_hostname')}+ requireFixtureOpenSsl()// Direct argv avoids a shell and Node's socket-backed stdin on Linux.// OpenSSL writes both PEM blocks to captured stdout; no key file is created.const generated = spawnSync('openssl', [@@ -35,3 +46,5 @@ export function createFixtureTls(hostname) {throw new Error('fixture_certificate_generation_failed')}}++if (import.meta.main) requireFixtureOpenSsl()diff --git a/scripts/tests/hcc-watch-api-proxy.test.mjs b/scripts/tests/hcc-watch-api-proxy.test.mjsindex a4bfe0b0b..3edfde08d 100644--- a/scripts/tests/hcc-watch-api-proxy.test.mjs+++ b/scripts/tests/hcc-watch-api-proxy.test.mjs@@ -934,7 +934,7 @@ test('TLS fixture timeout terminates its signer', { timeout: 25000 }, () => {writeFileSync(signerPath,`require('node:fs').writeFileSync(${JSON.stringify(pidPath)}, String(process.pid)); process.stdin.resume(); setTimeout(() => {}, 30000)`)writeFileSync(join(directory, 'openssl'),- `#!/bin/sh\nexec ${quote(process.execPath)} ${quote(signerPath)}\n`, { mode: 0o700 })+ `#!/bin/sh\nif [ "$1" = version ]; then printf "OpenSSL 3.0.0\\n"; exit 0; fi\nexec ${quote(process.execPath)} ${quote(signerPath)}\n`, { mode: 0o700 })const result = spawnSync(process.execPath, [join(root, 'scripts/e2e/_lib/hcc-watch-tls-manifest.mjs'),'timeout-fixture', 'test-fixture', 'run-fixture',diff --git a/scripts/tests/hcc-watch-openssl.test.mjs b/scripts/tests/hcc-watch-openssl.test.mjsnew file mode 100644index 000000000..1e22ad3e8--- /dev/null+++ b/scripts/tests/hcc-watch-openssl.test.mjs@@ -0,0 +1,30 @@+import assert from 'node:assert/strict'+import { spawnSync } from 'node:child_process'+import { mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { dirname, join, resolve } from 'node:path'+import test from 'node:test'+import { fileURLToPath } from 'node:url'++const lib = resolve(dirname(fileURLToPath(import.meta.url)), '../e2e/_lib')++for (const vendor of ['LibreSSL 3.3.6', 'unrecognized implementation']) {+ test(`rejects ${vendor} before attempting generation or creating an artifact`, () => {+ const directory = mkdtempSync(join(tmpdir(), 'hcc-openssl-preflight-'))+ try {+ writeFileSync(join(directory, 'openssl'),+ `#!/bin/sh\nif [ "$1" = version ]; then printf '%s\\n' '${vendor}'; exit 0; fi\nprintf unexpected > "$0.called"\nexit 99\n`,+ { mode: 0o700 })+ const result = spawnSync(process.execPath, [join(lib, 'hcc-watch-tls-manifest.mjs'),+ 'vendor-fixture', 'test-fixture', 'run-fixture', join(lib, 'hcc-watch-api-proxy.mjs')], {+ cwd: directory, env: { PATH: directory }, encoding: 'utf8', timeout: 10000,+ })+ assert.equal(result.status, 1)+ assert.equal(result.stdout, '')+ assert.match(result.stderr, /fixture_openssl_required/)+ assert.deepEqual(readdirSync(directory), ['openssl'], 'no generation attempt or key artifact')+ } finally {+ rmSync(directory, { recursive: true, force: true })+ }+ })+}diff --git a/scripts/tests/test-hcc-watch-api-proxy.sh b/scripts/tests/test-hcc-watch-api-proxy.shindex c72060499..948c81fd3 100755--- a/scripts/tests/test-hcc-watch-api-proxy.sh+++ b/scripts/tests/test-hcc-watch-api-proxy.sh@@ -3,6 +3,7 @@ set -euo pipefailSCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"command -v openssl >/dev/null || { echo 'FAIL: openssl is required' >&2; exit 1; }node -e 'if (Number(process.versions.node.split(".")[0]) !== 24) { console.error("FAIL: Node 24 is required"); process.exit(1) }'+node "$SCRIPT_DIR/../e2e/_lib/hcc-watch-tls.mjs"# Test certificates and the generator output stay in Node memory; never tee or# redirect the generator itself to any artifact. The reporter prints test results.-exec node --test --test-timeout=15000 "$SCRIPT_DIR/hcc-watch-api-proxy.test.mjs" "$SCRIPT_DIR/hcc-watch-bookmarks.test.mjs" "$SCRIPT_DIR/hcc-watch-tls.test.mjs" "$SCRIPT_DIR/hcc-watch-config.test.mjs" "$SCRIPT_DIR/hcc-watch-control.test.mjs"+exec node --test --test-timeout=15000 "$SCRIPT_DIR/hcc-watch-api-proxy.test.mjs" "$SCRIPT_DIR/hcc-watch-bookmarks.test.mjs" "$SCRIPT_DIR/hcc-watch-tls.test.mjs" "$SCRIPT_DIR/hcc-watch-config.test.mjs" "$SCRIPT_DIR/hcc-watch-control.test.mjs" "$SCRIPT_DIR/hcc-watch-openssl.test.mjs"