Skip to content

Commit fcff5af

Browse files
authored
fix(ci): redact package URL query strings (#492)
## What did you change, and why? **Why:** Bot dependency installation can print JFrog redirects containing AWS presigned query parameters into GitHub Actions logs. These credentials are short-lived, but complete signed URLs should not be logged. **Change:** Route the bot engine's pip and npm installs through a shared output filter that preserves URL host/path while replacing query strings with `?[REDACTED]`. The wrapper preserves the underlying command's exit code, and the focused test is included in PR checks. ## How do you know it works? **Testing:** The shell test verifies that AWS-style query parameters are removed while host/path remain visible, and that a wrapped command exiting with status 37 still returns status 37. Also ran Bash syntax checks and `git diff --check` locally. --- <!-- GITHUB_MCP_FOOTER: This attribution is automatically appended by GitHub MCP. --> _This PR was created with [GitHub MCP](http://go/mcps)._ Signed-off-by: rahul.singhal <rahul.singhal@databricks.com>
1 parent 375cdb6 commit fcff5af

4 files changed

Lines changed: 56 additions & 4 deletions

File tree

‎.github/actions/install-bot-engine/action.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ runs:
113113
if [ -s "$JFROG_NPMRC_FILE" ]; then
114114
NPM_ARGS=(--userconfig "$JFROG_NPMRC_FILE")
115115
fi
116+
source "${{ github.action_path }}/redact-command-output.sh"
116117
# pip reads PIP_INDEX_URL from the env setup-jfrog exported. REF mode
117118
# resolves the published engine's deps unpinned + installs the SDK/CLI by
118119
# version (a consumer can't see the engine's hash-locked requirements).
119120
# SDK_VERSION/CLI_VERSION track the engine at ENGINE_REF.
120-
python -m pip install --upgrade pip
121-
pip install "databricks-bot-engine @ git+https://github.com/${ENGINE_REPO}@${ENGINE_REF}"
122-
pip install "claude-agent-sdk==${SDK_VERSION}"
123-
npm install "${NPM_ARGS[@]}" -g "@anthropic-ai/claude-code@${CLI_VERSION}"
121+
run_with_redacted_url_queries python -m pip install --upgrade pip
122+
run_with_redacted_url_queries pip install "databricks-bot-engine @ git+https://github.com/${ENGINE_REPO}@${ENGINE_REF}"
123+
run_with_redacted_url_queries pip install "claude-agent-sdk==${SDK_VERSION}"
124+
run_with_redacted_url_queries npm install "${NPM_ARGS[@]}" -g "@anthropic-ai/claude-code@${CLI_VERSION}"
124125
echo "$(npm prefix -g)/bin" >> "$GITHUB_PATH"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
run_with_redacted_url_queries() {
4+
local previous_shell_options="$-"
5+
local command_status
6+
7+
set +e
8+
"$@" 2>&1 \
9+
| sed -E 's#([Hh][Tt][Tt][Pp][Ss]?://[^?[:space:]]+)\?[^[:space:]]+#\1?[REDACTED]#g'
10+
command_status=${PIPESTATUS[0]}
11+
if [[ "$previous_shell_options" == *e* ]]; then
12+
set -e
13+
fi
14+
15+
return "$command_status"
16+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
6+
source "$SCRIPT_DIR/redact-command-output.sh"
7+
8+
test_redacts_url_query_and_preserves_host_and_path() {
9+
local output
10+
11+
output=$(run_with_redacted_url_queries bash -c \
12+
'printf "%s\n" "Downloading https://packages.example.test/artifacts/pkg.whl?X-Amz-Algorithm=DUMMY&X-Amz-Credential=DUMMY"')
13+
14+
[[ "$output" == 'Downloading https://packages.example.test/artifacts/pkg.whl?[REDACTED]' ]]
15+
}
16+
17+
test_preserves_command_exit_code() {
18+
local output
19+
local status
20+
21+
set +e
22+
output=$(run_with_redacted_url_queries bash -c \
23+
'printf "%s\n" "Failed https://packages.example.test/pkg.tgz?X-Amz-Signature=DUMMY" >&2; exit 37')
24+
status=$?
25+
set -e
26+
27+
[[ "$status" -eq 37 ]]
28+
[[ "$output" == 'Failed https://packages.example.test/pkg.tgz?[REDACTED]' ]]
29+
}
30+
31+
test_redacts_url_query_and_preserves_host_and_path
32+
test_preserves_command_exit_code

‎.github/workflows/pr-checks.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
steps:
6464
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6565

66+
- name: Test install-log URL redaction
67+
run: bash .github/actions/install-bot-engine/redact-command-output_test.sh
68+
6669
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
6770
with:
6871
toolchain: stable

0 commit comments

Comments
 (0)