fix(build): enforce secure TLS registry and binary verification

This commit is contained in:
devops committed 2026-10-25 08:19:30 +00:00
1 parent cc0358bb12
commit fd14c05f3a
6 files changed
+64 -14

No files matched your search

+2 -2
View File
@@ -24,7 +24,7 @@ services:
context: ./backend
dockerfile: Dockerfile
args:
NPM_REGISTRY: ${NPM_REGISTRY:-}
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.parsaaghayi.ir/repository/npm/}
container_name: canino_backend_stage
restart: always
env_file:
@@ -66,7 +66,7 @@ services:
context: .
dockerfile: Dockerfile
args:
NPM_REGISTRY: ${NPM_REGISTRY:-}
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.parsaaghayi.ir/repository/npm/}
NEXT_PUBLIC_API_URL: "https://stageapi.canina.ir/api"
VITE_API_URL: "https://stageapi.canina.ir"
container_name: canino_frontend_stage
+1 -1
View File
@@ -14,7 +14,7 @@ ALLOWED = {'nginx.conf', 'Dockerfile', 'backend/Dockerfile', '.dockerignore',
'scripts/compose.stage.yml', 'scripts/rollout-stage.sh', 'scripts/revalidation-runtime.py',
'scripts/provision-revalidation-env.py', 'scripts/tests/test_revalidation_runtime.py',
'scripts/tests/test_ci_host_boundary.py', 'scripts/tests/test_stage_provision_wiring.py',
'scripts/tests/test_stage_rollout.py',
'scripts/tests/test_stage_rollout.py', 'scripts/tests/test_secure_build_install.py',
# CI1285 verified-payload upgrade repair; no model, cron or payload wildcard.
'infra/hermes-editorial/installer.py',
'infra/hermes-editorial/tests/test_installer.py',
+2 -1
View File
@@ -28,7 +28,8 @@ class ProductionGuards(unittest.TestCase):
def test_exact_editorial_installer_repair_paths_allowed_only(self):
paths = ['infra/hermes-editorial/installer.py',
'infra/hermes-editorial/tests/test_installer.py']
'infra/hermes-editorial/tests/test_installer.py',
'scripts/tests/test_secure_build_install.py']
r = self.receipt(); r['paths'] = paths
m.validate_receipt(r, 'a'*40, 'b'*40, paths)
for path in ['infra/hermes-editorial/model-policy.json',
@@ -0,0 +1,52 @@
"""Regression gates for CI1286: trusted routing and fail-closed frontend installs."""
from pathlib import Path
import os
import re
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[2]
REGISTRY = 'https://registry.parsaaghayi.ir/repository/npm/'
class SecureBuildInstallTests(unittest.TestCase):
def test_stage_supplies_operational_tls_registry(self):
compose = (ROOT / 'scripts/compose.stage.yml').read_text()
self.assertEqual(compose.count('NPM_REGISTRY: ${NPM_REGISTRY:-' + REGISTRY + '}'), 2)
def test_frontend_uses_supported_node_lts_in_all_stages(self):
images = re.findall(r'^FROM node:(\S+)', (ROOT / 'Dockerfile').read_text(), re.M)
self.assertEqual(images, ['22-alpine'] * 3)
def test_registry_configuration_never_disables_tls(self):
for name in ['Dockerfile', 'backend/Dockerfile']:
self.assertNotIn('strict-ssl false', (ROOT / name).read_text())
def test_false_successful_incomplete_install_aborts_layer(self):
dockerfile = (ROOT / 'Dockerfile').read_text().replace('\\\n', '')
commands = re.findall(r'^RUN (npm ci[^\n]+)', dockerfile, re.M)
self.assertEqual(len(commands), 2)
for command, binary in zip(commands, ['next', 'vite']):
with self.subTest(binary=binary), tempfile.TemporaryDirectory() as d:
root = Path(d)
npm = root / 'npm'
# Reproduce npm's observed zero exit with no complete node_modules.
npm.write_text('#!/bin/sh\nexit 0\n')
npm.chmod(0o755)
result = subprocess.run(['sh', '-c', command], cwd=d,
env={**os.environ, 'PATH': d + ':' + os.environ['PATH']},
capture_output=True)
self.assertNotEqual(result.returncode, 0, 'incomplete install was accepted')
target = root / 'node_modules/.bin' / binary
target.parent.mkdir(parents=True)
target.write_text('#!/bin/sh\nexit 0\n')
target.chmod(0o755)
result = subprocess.run(['sh', '-c', command], cwd=d,
env={**os.environ, 'PATH': d + ':' + os.environ['PATH']},
capture_output=True)
self.assertEqual(result.returncode, 0, result.stderr)
if __name__ == '__main__':
unittest.main()