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
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:
@@ -16,3 +16,11 @@ packages:
|
|||||||
onlyBuiltDependencies:
|
onlyBuiltDependencies:
|
||||||
- sharp
|
- sharp
|
||||||
- esbuild
|
- 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
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ export function parseServiceTenants(value: string | undefined | null): string[]
|
|||||||
|
|
||||||
/** Read the configured service tenant allowlist from the environment. */
|
/** Read the configured service tenant allowlist from the environment. */
|
||||||
export function resolveInternalServiceTenants(
|
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[] {
|
): string[] {
|
||||||
return parseServiceTenants(env.INTERNAL_SERVICE_TENANTS);
|
return parseServiceTenants(env.INTERNAL_SERVICE_TENANTS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,10 @@ function timingSafeEqualStr(a: string, b: string): boolean {
|
|||||||
*/
|
*/
|
||||||
export function verifyInternalServiceToken(
|
export function verifyInternalServiceToken(
|
||||||
headers: HeaderLookup,
|
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 {
|
): boolean {
|
||||||
const expected = env.INTERNAL_TOKEN?.trim();
|
const expected = env.INTERNAL_TOKEN?.trim();
|
||||||
if (!expected) return false;
|
if (!expected) return false;
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ function req(url: string, headers: Record<string, string> = {}): NextRequest {
|
|||||||
return new NextRequest(new URL(url, 'http://localhost'), { headers });
|
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)', () => {
|
describe('anonymous-access regression: /api/orders (GET) and /api/admin/metrics (GET)', () => {
|
||||||
const saved = { auth: process.env.AUTH_ENFORCE, node: process.env.NODE_ENV };
|
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(() => {
|
afterEach(() => {
|
||||||
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
|
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
|
||||||
else process.env.AUTH_ENFORCE = saved.auth;
|
else process.env.AUTH_ENFORCE = saved.auth;
|
||||||
if (saved.node === undefined) delete process.env.NODE_ENV;
|
if (saved.node === undefined) delete mutableEnv.NODE_ENV;
|
||||||
else process.env.NODE_ENV = saved.node;
|
else mutableEnv.NODE_ENV = saved.node;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('REGRESSION: GET /api/orders 401s with no Authorization header (was: 200 + full order list)', async () => {
|
it('REGRESSION: GET /api/orders 401s with no Authorization header (was: 200 + full order list)', async () => {
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ function h(init: Record<string, string>): Headers {
|
|||||||
return new Headers(init);
|
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)', () => {
|
describe('auth default -- fail-closed (no AUTH_ENFORCE in the environment)', () => {
|
||||||
const saved = { auth: process.env.AUTH_ENFORCE, node: process.env.NODE_ENV };
|
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(() => {
|
afterEach(() => {
|
||||||
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
|
if (saved.auth === undefined) delete process.env.AUTH_ENFORCE;
|
||||||
else process.env.AUTH_ENFORCE = saved.auth;
|
else process.env.AUTH_ENFORCE = saved.auth;
|
||||||
if (saved.node === undefined) delete process.env.NODE_ENV;
|
if (saved.node === undefined) delete mutableEnv.NODE_ENV;
|
||||||
else process.env.NODE_ENV = saved.node;
|
else mutableEnv.NODE_ENV = saved.node;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('REGRESSION: with the variable unset, an unauthenticated request is REJECTED (401)', async () => {
|
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 () => {
|
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';
|
process.env.AUTH_ENFORCE = 'false';
|
||||||
await expect(
|
await expect(
|
||||||
resolveAuthContext(h({ 'x-tenant-id': 'tenant_attacker' }), { verify: okVerify }),
|
resolveAuthContext(h({ 'x-tenant-id': 'tenant_attacker' }), { verify: okVerify }),
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ function req(path: string, headers: Record<string, string> = {}): NextRequest {
|
|||||||
return new NextRequest(new URL(path, 'http://localhost'), { headers });
|
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', () => {
|
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 };
|
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(() => {
|
afterEach(() => {
|
||||||
for (const [k, v] of Object.entries(saved)) {
|
for (const [k, v] of Object.entries(saved)) {
|
||||||
const envKey = k === 'auth' ? 'AUTH_ENFORCE' : k === 'internal' ? 'INTERNAL_TOKEN' : 'NODE_ENV';
|
const envKey = k === 'auth' ? 'AUTH_ENFORCE' : k === 'internal' ? 'INTERNAL_TOKEN' : 'NODE_ENV';
|
||||||
if (v === undefined) delete process.env[envKey];
|
if (v === undefined) delete mutableEnv[envKey];
|
||||||
else process.env[envKey] = v;
|
else mutableEnv[envKey] = v;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user