You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SECURITY] apply_k8s_manifest executes the live kubectl apply before its AUTO_APPLY approval check #102
With AUTO_APPLY=false and dry_run=false, K8sTools.apply_manifest executes the live kubectl apply before its approval check, so the cluster is mutated even though the caller is told the operation requires approval.
At tools/k8s_tools.py:56-59, when dry_run=False the command is built WITHOUT --dry-run=client and passed to executor.run() — the internal-call path that bypasses safety classification — before the not dry_run and not auto_apply approval branch at line 61 can return. The approval response is returned only after the live apply has already run.
Observe the executed command and the returned dict.
Expected Behavior
With AUTO_APPLY=false, no mutating command runs; the method returns requires_approval with an approval payload BEFORE any kubectl apply reaches a cluster (same contract the other host-mutating tools follow).
Actual Behavior
The live apply runs first. Reproduced deterministically with the executor's external-command boundary replaced by a recorder (no cluster involved):
Discovered during our fix for #89/#70 (host-mutation approval gating); that PR is being opened in parallel and does not change tools/k8s_tools.py. Issue #69's "verification still pass without observing the target" is a different defect; this one is execution-before-approval inside apply_manifest itself. The same Slack value-size consideration noted for large manifests applies, though the defect here is the ordering, not the transport.
Possible Solution
Unverified: validate with the dry-run command first, and only build/execute the live apply after approval (or route the live apply through run_safe after the approval gate). Also fix the inaccurate success message when no dry-run validation ran.
Activity
Merge pull request #106 from open-devops-agent/fix/k8s-apply-approval…
fix: dry-run k8s manifests before approval instead of applying them