CI / CI configuration security checks (pull_request) Successful in 2s
CI / Capabilities and shell quality (pull_request) Successful in 15s
CI / Python tests and compilation (pull_request) Successful in 36s
CI / QMD unit tests (pull_request) Successful in 7s
CI / Build and inspect generated packages (pull_request) Successful in 16s
CI / Bash integration and installation guards (pull_request) Failing after 51s
CI / PowerShell tests on Ubuntu (pull_request) Failing after 1m45s
CI / Installed client configuration smoke tests (pull_request) Canceled after 1m24s
- Resolve contradictions: authorization is never a skipped "boundary check"; one browser token policy (BFF/HttpOnly cookies first, RFC 10017); one sanitizer-bypass rule; Angular responses are unknown until validated. - Add security rules for AI/LLM integration and Java XXE, concrete crypto and password-hashing parameters, and RFC 8725 JWT validation. - Update version-dependent guidance after checking official sources: Angular 22, TypeScript 6/7, Node 24+, .NET 10/C# 14, JDK 21-25, Spring Boot 4; add a Spring Boot and Spring Security topic. - Give every rule a unique level-1 title and scope line, keep language security files to language specifics, and fix routing for inbound vs outbound HTTP, XML parsing, and WPF/Angular parent rules. - Validate rule structure and routing in validate-config.py, with tests. - Fix CI issues found by a local run: shellcheck directive order, pinned ruff rule set, Invoke-Python test mock, CRLF-tolerant package checks, Windows-only credential test, and refreshed prompt-budget baselines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
5.0 KiB
Python
96 lines
5.0 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
import uuid
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).parents[2]
|
|
|
|
|
|
class UserCustomizationTests(unittest.TestCase):
|
|
def test_build_references_the_shell_specific_credential_helper(self):
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/build.ps1'), '-Summary',
|
|
], capture_output=True, text=True, timeout=30)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
self.assertIn('with-credential.ps1', (ROOT / 'generated/codex-powershell/AGENTS.md').read_text())
|
|
self.assertIn('with-credential.sh', (ROOT / 'generated/claude-bash/CLAUDE.md').read_text())
|
|
for client, name in (('codex', 'AGENTS.md'), ('claude', 'CLAUDE.md')):
|
|
for shell in ('powershell', 'bash'):
|
|
self.assertNotIn('.my-ai-configuration/instructions/',
|
|
(ROOT / 'generated' / f'{client}-{shell}' / name).read_text())
|
|
|
|
def test_add_instruction_creates_client_overlays_outside_managed_configuration(self):
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
home = Path(directory)
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-instruction.ps1'),
|
|
'-Client', 'Both', '-Instruction', 'Always use the local release process.',
|
|
'-HomePath', str(home),
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
for client in ('codex', 'claude'):
|
|
self.assertEqual('Always use the local release process.\n',
|
|
(home / '.my-ai-configuration/instructions' / f'{client}.md').read_text())
|
|
appended = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-instruction.ps1'),
|
|
'-Client', 'Codex', '-Instruction', 'Keep the release notes current.',
|
|
'-HomePath', str(home),
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, appended.returncode, appended.stderr)
|
|
self.assertEqual('Always use the local release process.\nKeep the release notes current.\n',
|
|
(home / '.my-ai-configuration/instructions/codex.md').read_text())
|
|
|
|
def test_add_credentials_installs_a_client_scoped_helper(self):
|
|
if os.name != 'nt':
|
|
self.skipTest('The OS credential store is supported on Windows only.')
|
|
powershell = shutil.which('powershell') or shutil.which('pwsh')
|
|
if powershell is None:
|
|
self.skipTest('PowerShell is unavailable.')
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
home = Path(directory)
|
|
key = f'MY_TEST_TOKEN_{uuid.uuid4().hex}'
|
|
stored = False
|
|
try:
|
|
result = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
|
str(ROOT / 'scripts/commands/add-credentials.ps1'),
|
|
'-Client', 'Codex', '-Key', key, '-ValueFromStdin',
|
|
'-HomePath', str(home),
|
|
], input='test-value', capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, result.returncode, result.stderr)
|
|
stored = True
|
|
helper = home / '.my-ai-configuration/bin/with-credential.ps1'
|
|
self.assertTrue(helper.is_file())
|
|
self.assertTrue((home / '.my-ai-configuration/bin/with-credential.sh').is_file())
|
|
child = f"if ([Environment]::GetEnvironmentVariable('{key}', 'Process')) {{ exit 0 }}; exit 1"
|
|
injected = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', str(helper),
|
|
'-Client', 'Codex', '-Key', key, '-FilePath', powershell,
|
|
'-NoProfile', '-Command', child,
|
|
], capture_output=True, text=True, timeout=20)
|
|
self.assertEqual(0, injected.returncode, injected.stderr)
|
|
finally:
|
|
cleanup = subprocess.run([
|
|
powershell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
|
|
f". '{ROOT / 'scripts/lib/with-credential.ps1'}'; Remove-ManagedCredential -Client Codex -Key {key}",
|
|
], capture_output=True, text=True, timeout=20)
|
|
if stored:
|
|
self.assertEqual(0, cleanup.returncode, cleanup.stderr)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|