fix(sdk): enable TLS interception when modify adds a secret - #1432
Open
IIITManjeet wants to merge 2 commits into
Open
fix(sdk): enable TLS interception when modify adds a secret#1432IIITManjeet wants to merge 2 commits into
IIITManjeet wants to merge 2 commits into
Conversation
Adding a secret through `modify()` persisted the binding but left `network.tls.enabled` false, so the placeholder reached the upstream unsubstituted. Create already upheld this in `secret_entry`. Share the invariant between both paths and plan the implied TLS enable as a `tls` change, so it is restart-backed instead of flipping a config field the running proxy knows nothing about. Removing the last secret leaves interception on, since `TlsConfig` records no provenance. Fixes superradcompany#1422
|
|
Contributor
Author
|
Hey @appcypher can you please review this PR. |
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.
Adding a secret through
modify()persisted the binding but leftnetwork.tls.enabledfalse, so the guest's placeholder reached the upstream unsubstituted. The modification path now upholds the same secrets-require-TLS invariant thatSandboxBuilder::secret_entryalready enforced at create time.Description
ensure_tls_for_secretsinsdk/rust/lib/sandbox/config.rs, beside the existing network-config helpers. It ispub(crate), so this adds no public API; both call sites live in the same crate.apply_secret_patch_to_configinsdk/rust/lib/sandbox/modify.rs, somodifypersists interception alongside the secret.SandboxBuilder::secret_entrywith the shared helper. No behavior change; it removes the duplication that let the two paths drift.tlschange frompush_secret_changeswhen a patch declares secrets and interception is off. Persisting the flag alone is not enough: a config that already carries secrets with interception off, which is the state this bug produced, can take a rotate or allowed-hosts update that classifies as live, andapplymirrors those into the active config. Flipping the flag there would makeinspectreport interception the running proxy does not have. The planner's emission condition matches the persist step exactly, so the plan cannot disagree with what is written.spec_dispositionrules, so it is restart-backed:cannot apply modification: tls requires restartunder the default policy, an actual restart underrestart, andnext startwhen stopped. The CLI renders it through the existing free-form field path astls requires restart: interception disabled -> interception enabled, so no CLI change is needed.TlsConfigrecords no provenance and callers enable it independently of secrets, for bypass and inspection policy or for DNS-over-TLS.docs/sandboxes/secrets.mdxanddocs/sandboxes/tuning.mdx, including atlsrow in the change-disposition table.Compatibility
No format change.
tls.enabledis a pre-existing field, andtlsis a new value for the already free-formConfigPlannedChange.field, which older CLIs render verbatim.One behavior change is worth calling out: on configs already carrying secrets with interception off, a rotate or allowed-hosts update that previously classified as live now requires a restart. That live update never actually worked, since without interception nothing was substituted, but scripts calling
msb modify --secretwithout--restartagainst such a sandbox will now get an explicit error instead of a silent no-op.Out of scope
NetworkBuilder::build()(the.network(|n| n.secret(...))create path) andSandboxBuilder::from_spec_jsoncan still produce secrets with interception off. Auto-enabling there would change behavior for deliberately plain-HTTP secrets, sincerequire_tls_identity: falseis supported, so that seems like a maintainer call rather than something to fold into this fix. Happy to open a follow-up issue.Test Plan
New tests in
sdk/rust/lib/sandbox/config.rs:ensure_tls_for_secrets_enables_interception_for_a_non_empty_set— flips once for a non-empty set, then reports no further change.ensure_tls_for_secrets_leaves_an_empty_set_alone— an empty set neither enables nor disables interception.New tests in
sdk/rust/lib/sandbox/modify.rs:adding_first_secret_enables_tls_in_durable_config— the direct regression for this issue.first_secret_plans_tls_change_and_forces_restart— covers all three policies, including thatrestartyieldsplan_requires_restart, which is what rebuilds the active config from the TLS-enabled durable one.live_secret_change_on_tls_disabled_config_requires_restart— covers the legacy secrets-without-TLS config and asserts the exact error.removing_last_secret_keeps_tls_enabled— locks the one-way asymmetry.secret_change_with_tls_already_enabled_plans_no_tls_change— guards against plan noise.The
config_with_secrettest fixture was itself building a secret-without-TLS config, a shape no real entry point can now produce, so it now mirrors the invariant. A separateconfig_with_secret_and_tls_disabledfixture keeps the legacy shape available for the test that needs it.Environment notes:
cargo test --workspacereports 4 failures on this host, all pre-existing Windows path and platform assumptions unrelated to this change:test_create_local_validates_direct_config_mounts,test_runtime_name_validation_uses_explicit_backend_paths,test_sandbox_cli_args_flat_oci_attaches_one_raw_root_disk, andtest_builder_rejects_remote_named_pipe_and_datagram. Verified identical on cleanmain(601 passed / 4 failed) and on this branch (606 passed / 4 failed, the +5 being the newmodify.rstests).Fixes #1422