Skip to content

Feature/bake sanitization - #262

Open
vsilent wants to merge 17 commits into
mainfrom
feature/bake-sanitization
Open

vsilent wants to merge 17 commits into
mainfrom
feature/bake-sanitization

Conversation

@vsilent

@vsilent vsilent commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

robotizeit and others added 17 commits September 18, 2026 08:22
- Chat session management with archive and encryption
- Agent hardening: per-tenant ownership, token digest verification, fail-closed auth
- Marketplace field policy: config_contract, generated-field stripping, derived_jwt signing
- Project sync, one-click deploy improvements, deployment container tracking
- SSH key authorization fixes, mTLS for Vault, port validation
- Stale project/server cleanup, audit-log cron, env size validator
- Multiple BDD and migration fixes
- create_handler now uses update_metadata_for_resubmit for submitted/under_review/approved templates
- CLI submit command uses resubmit endpoint for approved templates instead of submit endpoint
- adds marketplace_resubmit client method for POST /api/templates/{id}/resubmit
…lookup for resubmit

- build_project_app now copies config_contract from the form app
- get_source_project_id checks all versions (not just latest) since
  resubmit_with_new_version creates a new version row before
  set_source_project_id is called
…ubmit

- unit test: project_level_apps_from_form propagates config_contract
- integration test: sync persists config_contract on project apps
- integration test: create_handler updates approved template metadata
- integration test: resubmit with new version preserves source_project_id
The insert/update SQL does not include config_contract — it is persisted
via a dedicated set_config_contract call. sync_project_level_apps_from_form
now calls set_config_contract after each insert/update when the form app
declares a config_contract.
Remove dead agent rows whose deployment is deleted/missing and that show
no sign of life within 30 days (last_heartbeat AND audit_log). Remove
rows with structurally invalid deployment_hash unconditionally — these
can never authenticate and often leak a raw token in plaintext.

The audit_log check protects agents that are alive but failing
authentication: last_heartbeat only advances on successful wait/report,
while audit_log captures auth_failure entries.

Migration 20260113000002 already converted audit_log.created_at to
timestamptz — no new migration needed.

Includes 9 integration tests covering the key cases from the sweep plan.
…ed snapshots

- Add parameterize_compose_env_vars() to replace literal env values with
  ${VAR} references in generated compose files
- Integrate into deploy pipeline so compose never contains author secrets
- Docker Compose resolves ${VAR} from co-located .env at runtime
- Add 3 unit tests for parameterization behavior

This fixes the security issue where every buyer of a marketplace template
received the author's literal secrets in the baked compose file.
feat(compose): parameterize env vars to prevent secret leakage in bak…
prepare server for baking, clean creds, keys, logs etc
Follow-up to 27017fa. An adversarial review of that change found the
sanitize step could destroy the build box, refuse healthy deploys, or
report success over an image it had not actually checked.

Volume reset was enumerating every volume on the host, not the
project's. On a real build box that removes the ingress' certificates
and the agent's state, and aborts the bake on the first volume still
held by a running container. Scoped to the project's own compose and
matched through Compose's own label; keep entries are validated and
matched on whole segments.

The required-key list was read from the text of the compose file, so
`${VAR:-default}` and `$$`-escaped text counted as required and no
buyer could ever satisfy them. It now comes from the contract — the
only thing that has a source on a buyer's machine. References the
contract does not cover are resolved back to their literals before the
snapshot, since a buyer's env file is replaced wholesale and would
leave them empty.

Further:

- config_contract is now the only authority on what is sensitive;
  the weaker name heuristic is gone. A credential embedded inside a
  larger value (a password inside a DSN) is cleared in .env as well as
  in compose.
- The author's own access no longer survives: authorized_keys, private
  keys, known_hosts and registry credentials are removed alongside the
  machine identity. Cloud-init appends the buyer's key rather than
  replacing the file, so a key left behind would grant root on every
  server cloned from the image.
- The tear-down runs before the rewrites, so a cleared .env cannot fail
  `docker compose down` with the files already modified.
- Files are written in chunks, so a large compose no longer exceeds the
  argument-length limit mid-sanitize; error messages no longer echo the
  payload.
- A failure reports which steps completed and whether a retry against
  the same box is still equivalent.
- The bake refuses when no contract resolved, when a compose reads
  values through `env_file:` that a buyer would silently lose, on an
  unknown argument, and when the contract describes a different version.
- Value-stripping no longer clears the field policies inside
  config_contract itself.

Adds scripts/check-staged-secrets.sh, wired as a pre-commit check — the
scanner already configured in .pre-commit-config.yaml was never
installed, so nothing was checking. Adds docs/SECRET_LIFECYCLE.md,
tracing where one value lives at each stage and which component owns it.

2083 unit tests and 329 BDD scenarios green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gitguardian

gitguardian Bot commented Sep 21, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 6 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
37456823 Triggered Generic Password 27017fa src/helpers/bake_finalize.rs View secret
37449298 Triggered Generic Password 4b1e286 src/cli/generator/compose.rs View secret
37449299 Triggered Generic High Entropy Secret 4b1e286 src/cli/generator/compose.rs View secret
37456824 Triggered Generic High Entropy Secret 13a65d3 src/cli/generator/compose.rs View secret
37490585 Triggered Generic High Entropy Secret 07828d0 src/cli/generator/compose.rs View secret
37490586 Triggered Generic Password 07828d0 src/cli/generator/compose.rs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants