Skip to content

feat: support updating egress proxy secret envs for key rotation#158

Merged
sjmiller609 merged 11 commits into
mainfrom
hypeship/update-egress-proxy-secrets-v2
Mar 20, 2026
Merged

feat: support updating egress proxy secret envs for key rotation#158
sjmiller609 merged 11 commits into
mainfrom
hypeship/update-egress-proxy-secrets-v2

Conversation

@sjmiller609

@sjmiller609 sjmiller609 commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds PATCH /instances/{id} API endpoint for updating mutable instance properties
  • Adds UpdateInstanceRules() to egress proxy service for live header inject rule updates
  • Adds UpdateInstance() to instance manager with UpdateInstanceRequest type
  • Enables credential/secret key rotation without instance restart — the host-side egress proxy recompiles header inject rules in-place with the new secret values
  • Extends egress proxy integration test to verify key rotation flow end-to-end

How it works

The egress proxy runs on the host and intercepts outbound HTTPS traffic from the guest. Credential secrets are never exposed to the guest — the guest only sees mock placeholder values. When secrets are updated via the API:

  1. New env values are merged into instance metadata
  2. Credential env bindings are re-validated
  3. Header inject rules are recompiled from the updated env + existing credential policies
  4. The egress proxy's in-memory rules are swapped atomically via UpdateInstanceRules()

No guest restart or signaling is needed because the proxy operates entirely on the host side.

Test plan

  • Extended TestEgressProxyRewritesHTTPSHeaders integration test to include:
    • Update credential env value via UpdateInstance()
    • Verify guest-visible env still shows mock placeholder (secrets never leak)
    • Verify subsequent HTTPS requests use the rotated credential value
    • Verify old credential value is no longer injected
  • go build ./... passes
  • go vet ./... passes
  • All egress proxy unit tests pass
  • All builds package unit tests pass
  • CI must pass

Note

Medium Risk
Adds a new instance mutation API and runtime egress-proxy rule updates; incorrect validation/rollback could leave proxies injecting stale or inconsistent credentials for running VMs.

Overview
Adds PATCH /instances/{id} to update an instance’s env vars (limited to credential-policy source.env keys) to support live secret/key rotation without restarting the VM.

Implements manager.UpdateInstance with validation, metadata persistence, and egress proxy rule recompilation plus rollback if saving metadata fails; the egress proxy gains UpdateInstanceRules and improved logging/tracing/metrics around register/update/unregister and request handling.

Updates OpenAPI/stainless specs, scopes, and tests (new unit tests and an integration test that rotates a key and verifies the guest still sees mock env while outbound HTTPS uses the rotated value).

Written by Cursor Bugbot for commit 5bdd7a6. This will update automatically on new commits. Configure here.

Enables key rotation for egress proxy credentials without instance restart.
Updates are propagated to the running guest via the host-side egress proxy
service — the proxy recompiles header inject rules with the new secret
values in-place, so the guest never needs to be restarted or signaled.

Changes:
- Add UpdateInstanceRules() to egressproxy.Service for live rule updates
- Add UpdateInstance() to instances.Manager with UpdateInstanceRequest type
- Add PATCH /instances/{id} API endpoint (OpenAPI + handler + codegen)
- Extend egress proxy integration test with key rotation verification
- Update mock in lib/builds to satisfy Manager interface

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Mar 19, 2026

Copy link
Copy Markdown

✱ Stainless preview builds

This PR will update the hypeman SDKs with the following commit message.

feat: support updating egress proxy secret envs for key rotation
hypeman-openapi studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅

hypeman-go studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ⏭️lint ✅test ✅

go get github.com/stainless-sdks/hypeman-go@96b32092d707499c6a962d89a3530b413be4ccab
⚠️ hypeman-typescript studio · code

Your SDK build had at least one "error" diagnostic.
generate ❗build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/hypeman-typescript/f5bc12b81b0bda445d8feab08f665d1b6438b1f9/dist.tar.gz

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-03-20 22:28:40 UTC

@sjmiller609 sjmiller609 marked this pull request as ready for review March 20, 2026 14:24
Comment thread lib/instances/update.go
Comment thread lib/instances/update.go
Comment thread lib/egressproxy/service.go

@masnwilliams masnwilliams left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solid PR — credential rotation with rollback semantics is well-designed. the integration test proving secrets never leak to the VM is the highlight. main feedback is around histogram bucket config for useful latency data and a minor observability gap in the CONNECT setup path.

Comment thread lib/egressproxy/metrics.go
Comment thread lib/egressproxy/service.go
Comment thread lib/instances/update_test.go
Comment thread openapi.yaml Outdated
Comment thread lib/instances/update.go Outdated

@masnwilliams masnwilliams left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sjmiller609 sjmiller609 merged commit 4215cf1 into main Mar 20, 2026
6 checks passed
@sjmiller609 sjmiller609 deleted the hypeship/update-egress-proxy-secrets-v2 branch March 20, 2026 22:27

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread lib/instances/update.go
Comment thread lib/instances/update.go
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