Merge remote-tracking branch 'origin/main' into seo-sitemap-fix-20261117
CI (SIAX Cloud) / sonar (pull_request) Skipped
CI (SIAX Cloud) / security (pull_request) Successful in 25s
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Successful in 13s
masterplan-lock / check (pull_request) Successful in 9s
CI (SIAX Cloud) / integration (pull_request) Successful in 1m21s
security / scan (pull_request) Failing after 59s
CI (SIAX Cloud) / quality (pull_request) Successful in 4m3s

This commit is contained in:
2026-11-17 22:00:26 +01:00
6 changed files with 37 additions and 9 deletions
+8
View File
@@ -16,3 +16,11 @@ packages:
onlyBuiltDependencies:
- sharp
- esbuild
# Supply-chain hardening (Semgrep p/ci blocking rules):
# - no transitive dependency from an untrusted/exotic source
# - wait 7 days (10080 min) for newly published versions
# - never accept a downgrade of security settings via a dependency update
blockExoticSubdeps: true
minimumReleaseAge: 10080
trustPolicy: no-downgrade
+4 -1
View File
@@ -70,7 +70,10 @@ export function parseServiceTenants(value: string | undefined | null): string[]
/** Read the configured service tenant allowlist from the environment. */
export function resolveInternalServiceTenants(
env: { INTERNAL_SERVICE_TENANTS?: string } = process.env,
// @types/node 22's ProcessEnv has only an index signature, so a direct
// default is not assignable to the narrow named-property shape. This is a
// type-only view of the same object; runtime behaviour is unchanged.
env: { INTERNAL_SERVICE_TENANTS?: string } = process.env as { INTERNAL_SERVICE_TENANTS?: string },
): string[] {
return parseServiceTenants(env.INTERNAL_SERVICE_TENANTS);
}
+4 -1
View File
@@ -63,7 +63,10 @@ function timingSafeEqualStr(a: string, b: string): boolean {
*/
export function verifyInternalServiceToken(
headers: HeaderLookup,
env: { INTERNAL_TOKEN?: string } = process.env,
// @types/node 22's ProcessEnv has only an index signature, so a direct
// default is not assignable to the narrow named-property shape. This is a
// type-only view of the same object; runtime behaviour is unchanged.
env: { INTERNAL_TOKEN?: string } = process.env as { INTERNAL_TOKEN?: string },
): boolean {
const expected = env.INTERNAL_TOKEN?.trim();
if (!expected) return false;
+7 -2
View File
@@ -23,6 +23,11 @@ function req(url: string, headers: Record<string, string> = {}): NextRequest {
return new NextRequest(new URL(url, 'http://localhost'), { headers });
}
// @types/node 22 declares NODE_ENV readonly. These tests deliberately save
// and restore it; a typed mutable view keeps that exact without weakening the
// production auth checks under test.
const mutableEnv = process.env as Record<string, string | undefined>;
describe('anonymous-access regression: /api/orders (GET) and /api/admin/metrics (GET)', () => {
const saved = { auth: process.env.AUTH_ENFORCE, node: process.env.NODE_ENV };
@@ -35,8 +40,8 @@ describe('anonymous-access regression: /api/orders (GET) and /api/admin/metrics
afterEach(() => {
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
else process.env.AUTH_ENFORCE = saved.auth;
if (saved.node === undefined) delete process.env.NODE_ENV;
else process.env.NODE_ENV = saved.node;
if (saved.node === undefined) delete mutableEnv.NODE_ENV;
else mutableEnv.NODE_ENV = saved.node;
});
it('REGRESSION: GET /api/orders 401s with no Authorization header (was: 200 + full order list)', async () => {
+8 -3
View File
@@ -36,6 +36,11 @@ function h(init: Record<string, string>): Headers {
return new Headers(init);
}
// @types/node 22 declares NODE_ENV readonly. These tests deliberately save
// and restore it; a typed mutable view keeps that exact without weakening the
// fail-closed auth contract under test.
const mutableEnv = process.env as Record<string, string | undefined>;
describe('auth default -- fail-closed (no AUTH_ENFORCE in the environment)', () => {
const saved = { auth: process.env.AUTH_ENFORCE, node: process.env.NODE_ENV };
@@ -46,8 +51,8 @@ describe('auth default -- fail-closed (no AUTH_ENFORCE in the environment)', ()
afterEach(() => {
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
else process.env.AUTH_ENFORCE = saved.auth;
if (saved.node === undefined) delete process.env.NODE_ENV;
else process.env.NODE_ENV = saved.node;
if (saved.node === undefined) delete mutableEnv.NODE_ENV;
else mutableEnv.NODE_ENV = saved.node;
});
it('REGRESSION: with the variable unset, an unauthenticated request is REJECTED (401)', async () => {
@@ -98,7 +103,7 @@ describe('auth default -- fail-closed (no AUTH_ENFORCE in the environment)', ()
});
it('a production process with AUTH_ENFORCE=false cannot serve a request at all (throws)', async () => {
process.env.NODE_ENV = 'production';
mutableEnv.NODE_ENV = 'production';
process.env.AUTH_ENFORCE = 'false';
await expect(
resolveAuthContext(h({ 'x-tenant-id': 'tenant_attacker' }), { verify: okVerify }),
+6 -2
View File
@@ -20,6 +20,10 @@ function req(path: string, headers: Record<string, string> = {}): NextRequest {
return new NextRequest(new URL(path, 'http://localhost'), { headers });
}
// @types/node 22 declares NODE_ENV readonly. This key is one of the three
// restored below; a typed mutable view keeps that exact.
const mutableEnv = process.env as Record<string, string | undefined>;
describe('middleware.ts: internal-token path for /api/0pt/quality/bridge-run', () => {
const saved = { auth: process.env.AUTH_ENFORCE, internal: process.env.INTERNAL_TOKEN, node: process.env.NODE_ENV };
@@ -31,8 +35,8 @@ describe('middleware.ts: internal-token path for /api/0pt/quality/bridge-run', (
afterEach(() => {
for (const [k, v] of Object.entries(saved)) {
const envKey = k === 'auth' ? 'AUTH_ENFORCE' : k === 'internal' ? 'INTERNAL_TOKEN' : 'NODE_ENV';
if (v === undefined) delete process.env[envKey];
else process.env[envKey] = v;
if (v === undefined) delete mutableEnv[envKey];
else mutableEnv[envKey] = v;
}
});