Skip to content

artifactory-automation: harden shell scripting and fix curl JSON body#339

Merged
hooksie1 merged 1 commit into
chainguard-demo:mainfrom
faf0-addepar:faf0/artifactory-automation-refactor
May 20, 2026
Merged

artifactory-automation: harden shell scripting and fix curl JSON body#339
hooksie1 merged 1 commit into
chainguard-demo:mainfrom
faf0-addepar:faf0/artifactory-automation-refactor

Conversation

@faf0-addepar

Copy link
Copy Markdown
Contributor

Fixes a correctness bug where TOKEN_USER and TOKEN_PASSWORD were never interpolated into the curl request body (single-quote escaping prevented expansion), and hardens the surrounding shell script against word splitting, glob expansion, and malformed JSON payloads.

Changes:

  • Fix curl -d body to use jq -n --arg for safe, properly escaped JSON serialization
  • Quote all variable expansions ($PRUNE, $id, $PULL_TOKEN_JSON, $GITHUB_OUTPUT, $RESP, $BODY)
  • Add [[ -n "$id" ]] || continue guard in the token pruning loop
  • Use set +x before writing the pull token password to $GITHUB_OUTPUT to prevent it appearing in Actions debug logs
  • Switch HTTP status check from arithmetic -ne to string != to handle empty/non-numeric values gracefully
  • Capitalize "Artifactory" consistently in all input descriptions

Fixes a correctness bug where `TOKEN_USER` and `TOKEN_PASSWORD` were never
interpolated into the curl request body (single-quote escaping prevented
expansion), and hardens the surrounding shell script against word splitting,
glob expansion, and malformed JSON payloads.

Changes:
- Fix curl `-d` body to use `jq -n --arg` for safe, properly escaped JSON serialization
- Quote all variable expansions (`$PRUNE`, `$id`, `$PULL_TOKEN_JSON`, `$GITHUB_OUTPUT`, `$RESP`, `$BODY`)
- Add `[[ -n "$id" ]] || continue` guard in the token pruning loop
- Use `set +x` before writing the pull token password to `$GITHUB_OUTPUT` to prevent it appearing in Actions debug logs
- Switch HTTP status check from arithmetic `-ne` to string `!=` to handle empty/non-numeric values gracefully
- Capitalize "Artifactory" consistently in all input descriptions
@hooksie1 hooksie1 merged commit 61ca955 into chainguard-demo:main May 20, 2026
9 checks passed
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