Wire runtime read routes with explicit file-granted startup opt-in

This commit is contained in:
devops committed 2026-10-23 13:26:29 +00:00
1 parent 2023dd4e36
commit 16f9610027
3 files changed
+24 -2

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
import { RouterUsageModule } from './router-usage/router-usage.module';
import { HermesManagementModule } from './hermes-management/hermes-management.module';
import { runtimeReadRegistration } from './hermes-management/runtime-read.registration';
import { TasksModule } from './common/services/tasks.module';
import { Module, NestModule, MiddlewareConsumer } from "@nestjs/common";
import { PrismaModule } from "./prisma/prisma.module";
@@ -47,7 +47,7 @@ import { Request, Response, NextFunction } from "express";
imports: [
RouterUsageModule,
// Deny-all registration: no request identity or runtime credentials are accepted yet.
HermesManagementModule.register({origin:'http://canina-hermes:9119',token:async()=>''}),
runtimeReadRegistration(),
OrchestrationModule,
SupportChatModule,
RevalidationModule,
@@ -0,0 +1,16 @@
import { runtimeReadRegistration } from './runtime-read.registration';
import { RuntimeReadModule } from './runtime-read.module';
describe('application runtime registration',()=>{
afterEach(()=>jest.restoreAllMocks());
it('registers denied routes without reading files when not explicitly enabled',async()=>{
const file=jest.spyOn(RuntimeReadModule,'registerFromFile');
const register=jest.spyOn(RuntimeReadModule,'register');
await runtimeReadRegistration({});
expect(file).not.toHaveBeenCalled();expect(register).toHaveBeenCalledWith({});
});
it('uses only the fixed reviewed grants mount when enabled',async()=>{
const file=jest.spyOn(RuntimeReadModule,'registerFromFile').mockResolvedValue({module:RuntimeReadModule});
await runtimeReadRegistration({CANINA_RUNTIME_READ_ENABLED:'true'});
expect(file).toHaveBeenCalledWith('/run/secrets/hermes_runtime_grants');
});
});
@@ -0,0 +1,6 @@
import { RuntimeReadModule } from './runtime-read.module';
export function runtimeReadRegistration(env:Record<string,string|undefined>=process.env) {
return env.CANINA_RUNTIME_READ_ENABLED === 'true'
? RuntimeReadModule.registerFromFile('/run/secrets/hermes_runtime_grants')
: RuntimeReadModule.register({});
}