Skip to content

Bake improvement - #260

Open
vsilent wants to merge 13 commits into
mainfrom
bake-improvement
Open

vsilent wants to merge 13 commits into
mainfrom
bake-improvement

Conversation

@vsilent

@vsilent vsilent commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces version 0.3.3, which includes several new features, enhancements, and bug fixes across chat session management, agent hardening, marketplace field policy, deployment lifecycle, and security. It also adds important database migrations and improvements to the bake utility to enforce build box sanitization and track required environment keys.

Major new features and improvements:

Release and Versioning

  • Bump version to 0.3.3 in Cargo.toml and document all changes in CHANGELOG.md. (F7f5fb14R1, [1] [2]

Chat, Agent, and Security Enhancements

  • Added chat session endpoints with encryption and RBAC rules, enforced per-tenant agent ownership, improved agent token verification, and hardened agent authentication.
  • Introduced mTLS for Vault access and improved Docker preflight checks.

Marketplace and Field Policy

  • Added support for advanced field policies (fixed, editable, generated, derived_jwt), secret federation, and policy-driven secret generation.

Deployment and Cleanup Lifecycle

  • Added new tables and tools for tracking deployment containers, scheduled cleanup, and audit log retention.
  • Added migration to fix type mismatch in cleanup routines and implemented scheduled cleanup for the cleanup_log table. [1] [2]

Bake Utility and Snapshot Registry

  • The bake utility now requires --ssh-key by default to sanitize the build box before snapshotting, preventing accidental credential leakage; --allow-unsanitized-snapshot can override this for private images. [1] [2] [3] [4]
  • Tracks and records the required environment keys for each baked snapshot to prevent misconfigured deployments. [1] [2] [3]

Bug Fixes

  • Fixed SSH key authorization logic, CLI dry-run behavior, config escaping, and migration version collisions.

Database and Migrations

  • Added a new required_env_keys field to baked_snapshots to record which environment variables are needed for deployment, with up and down migrations. [1] [2]

Most important changes by theme:

1. Security and Agent Hardening

  • Enforced per-tenant agent ownership, improved agent token verification, and required service keys for agent registration.
  • The bake tool now requires an SSH key to sanitize the build box before snapshotting, preventing accidental leakage of credentials and secrets. [1] [2] [3] [4]

2. Marketplace and Field Policy

  • Added advanced field-policy support to the marketplace, including secret federation and policy-driven secret generation.

3. Deployment Lifecycle and Cleanup

  • Added deployment_container tracking, scheduled cleanup for stale resources, and a cron job for audit-log cleanup.
  • Fixed type mismatch in cleanup routines and scheduled periodic cleanup of the cleanup_log table. [1] [2]

4. Bake Utility and Deployment Robustness

  • The bake process now records required environment keys in the baked_snapshots table, preventing silent misconfiguration on deploy. [1] [2] [3]

5. Bug Fixes and Quality Improvements

  • Fixed SSH key authorization, improved CLI and migration reliability, and enhanced environment/config handling.

- 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.
@gitguardian

gitguardian Bot commented Sep 19, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 5 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
37449299 Triggered Generic High Entropy Secret 7b6c5e6 src/cli/generator/compose.rs View secret
37449298 Triggered Generic Password 7b6c5e6 src/cli/generator/compose.rs View secret
37456823 Triggered Generic Password 27017fa src/helpers/bake_finalize.rs View secret
37456824 Triggered Generic High Entropy Secret 27017fa src/cli/generator/compose.rs View secret
37456824 Triggered Generic High Entropy Secret 27017fa 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.


assert!(
result.contains("postgresql://stackpilot:${POSTGRES_PASSWORD}@db:5432/stackpilot"),
"password replaced in place:\n{result}"
);
assert!(
!result.contains("2213a996143863b99a0f2d3e22907690"),
"no literal left:\n{result}"
.expect("no conflict");
assert!(
result.contains("GREETING: administrator"),
"untouched:\n{result}"
.expect("no conflict");
assert!(
result.contains("aaaaaaaaaaaaaaaa"),
"left literal:\n{result}"

assert!(
result.contains("image: myapp:2213a996143863b99a0f2d3e22907690"),
"image digest untouched:\n{result}"
);
assert!(
result.contains("TOKEN: ${TOKEN}"),
"env replaced:\n{result}"

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.

3 participants