Make deploy-managed-agent.sh fail when an env-var value is refused - #78
Open
akhilesharora wants to merge 1 commit into
Open
Make deploy-managed-agent.sh fail when an env-var value is refused#78akhilesharora wants to merge 1 commit into
akhilesharora wants to merge 1 commit into
Conversation
set -euo pipefail does not abort on a failed assignment inside a command substitution, and the deploy nests three deep (yaml2json -> resolve_manifest -> create_agent), so a refused env-var value (SAFE allowlist rejects ? & =) left resolve_manifest continuing with empty json. The dry-run then printed [] and exited 0, and test-cookbooks.sh green-lit a cookbook with zero bodies. Guard the four masked command substitutions with || exit 1 so the refusal propagates.
|
All contributors have signed the CLA ✍️ ✅ |
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.
set -euo pipefaildoes not catch a failed assignment when it runs inside a command substitution, and the deploy nests three deep:json=$(yaml2json ...)(inresolve_manifest) runs insidejson=$(resolve_manifest ...)(increate_agent) runs insideOUT=$(create_agent ...). So whenyaml2jsonrejects an env-var value (theSAFEallowlist excludes?,&,=, so a connector URL carrying a?token=query string is refused), the non-zero exit never propagates:resolve_manifestcontinues with an emptyjson, and the deploy reports success with no bodies.In
--dry-runthat is EXIT 0 and an empty[].test-cookbooks.shthen iterates the empty list, finds no errors, and green-lights a cookbook that produced zero agents. The real path eventually errors, but with a misleadingPOST /v1/agents failed for :rather than the refusal reason.Before (on main), a connector URL with a query string:
After, the refusal aborts with its reason:
|| exit 1on the four masked command substitutions (yaml2json,resolve_manifest, and bothcreate_agentcalls) makes the failure propagate through the nesting. A valid deploy is unchanged;test-cookbooks.shstill passes 5/5:Tested on Ubuntu 24.04, bash 5.x. This fixes the silent swallow itself, which masks any future rejection. Widening the
SAFEallowlist to accept URL query characters is a separate call (it guards acurl -F/jqinjection surface), so I left it out.Closes #77.