Production config, reply pipeline and STIX/TAXII conformance - #37
Merged
Conversation
- Validate required configuration at startup; create the initial admin with a provided or generated password - docker-compose.prod: publish app/n8n on loopback; run n8n as a non-root user - Reply pipeline: only reuse a prior draft when the validator confirmed it - STIX/TAXII: UTC Z timestamps, created/modified on attack-patterns, valid relationship time bounds, de-duplicate shared objects
There was a problem hiding this comment.
Pull request overview
This PR tightens production boot/security defaults, hardens the LLM reply retry pipeline to fail closed on unverified security, and updates STIX 2.1 / TAXII feed generation to better match OASIS conformance expectations.
Changes:
- Production: add a fail-fast secret policy check and switch to creating the initial admin at boot with either
ADMIN_PASSWORDor a generated one-time password; stop seeding a known default admin hash in SQL. - n8n/compose: run n8n as a non-root user in prod and bind exposed service ports to loopback by default.
- STIX/TAXII + LLM pipeline: enforce STIX timestamp shape/relationship semantics, dedupe STIX objects by id, and change retry best-of-3 behavior to only allow security-clean drafts.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| n8n/n8n-init.sh | Drops root assumptions and updates workflow import fallback to run directly (now needs to remain compatible with root-based dev compose usage). |
| infra/docker/backend/prod-seed-reference.sql | Removes seeded default admin credentials from prod SQL seed. |
| infra/docker/backend/docker-entrypoint-prod.sh | Adds secret validation command and boot-time initial admin creation with optional generated password. |
| docker-compose.prod.yml | Binds backend/n8n ports to loopback by default and runs n8n as non-root node. |
| backend-symfony/tests/Unit/Security/SecretPolicyTest.php | Unit coverage for prod-only secret policy behavior and weak/default detection. |
| backend-symfony/tests/Unit/Application/Stix/TtpAttackPatternBuilderTest.php | Updates relationship stop_time expectations to match STIX 2.1 constraints. |
| backend-symfony/tests/Unit/Application/Stix/StixOasisConformanceTest.php | Adds STIX/OASIS conformance guards (timestamp shape, stop_time, dedupe). |
| backend-symfony/tests/Unit/Application/LLM/RetryCoordinatorTest.php | Updates validator payload shape and adds fail-closed security rejection tests. |
| backend-symfony/tests/Unit/Application/LLM/RetryCoordinatorMutationTest.php | Updates mutation tests for new fail-closed behavior on validator exceptions. |
| backend-symfony/tests/Unit/Application/LLM/RetryCoordinatorAuditTest.php | Adjusts audit tests for validator payload changes (security_pass). |
| backend-symfony/tests/Functional/Console/CheckSecretsCommandTest.php | Functional tests for the prod secret-check console command exit behavior. |
| backend-symfony/src/UI/Console/CheckSecretsCommand.php | Introduces app:security:check-secrets to enforce secret policy in prod. |
| backend-symfony/src/Security/SecretPolicy.php | Implements prod-only secret validation against published defaults and weak markers. |
| backend-symfony/src/Application/Taxii/TaxiiService.php | Dedupes envelope objects by id and changes ISO8601 formatting to UTC-Z with milliseconds. |
| backend-symfony/src/Application/Stix/TtpAttackPatternBuilder.php | Omits invalid/equal stop_time on STIX relationships for single-point sightings. |
| backend-symfony/src/Application/Stix/ThreatActorStixBuilder.php | Adds deterministic created/modified timestamps for MITRE attack-pattern objects. |
| backend-symfony/src/Application/Stix/StixObjectDeduplicator.php | Adds a utility to preserve order while collapsing duplicate STIX objects by id. |
| backend-symfony/src/Application/LLM/RetryCoordinator.php | Restricts best-of-3 fallback to drafts that the validator marked security_pass=true. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+114
to
+118
| # ─── 0. Ensure data directory exists ─── | ||
| # This runs as the non-root node user (uid 1000). The n8n image ships | ||
| # /home/node/.n8n owned by node, so the named volume inherits that ownership — | ||
| # no privileged chown is needed. | ||
| log "Ensuring /home/node/.n8n exists..." |
Comment on lines
+309
to
312
| # Fallback: CLI import (works without auth but workflows may not be visible to admin). | ||
| # Runs as the node user directly (the container is no longer root). | ||
| if n8n import:workflow --input="$wf_file" 2>/dev/null; then | ||
| log " Imported (CLI): $wf_name" |
Comment on lines
882
to
886
| try { | ||
| return (new \DateTimeImmutable($value))->format(\DateTimeInterface::ATOM); | ||
| $dt = $value === '' ? new \DateTimeImmutable('now', $utc) : new \DateTimeImmutable($value); | ||
| } catch (\Exception) { | ||
| return (new \DateTimeImmutable())->format(\DateTimeInterface::ATOM); | ||
| $dt = new \DateTimeImmutable('now', $utc); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improvements to the production startup/config, the reply pipeline draft-reuse logic, and STIX 2.1 / TAXII feed conformance. Full test suite (unit + integration + functional) green; PHPStan level 8 and php-cs-fixer clean.