Hostile 99% github Download

datadog/system-tests

Shell sends developer credentials to networkPackage name one edit from popular package

Evidence

References an Amazon S3 HTTP URL lines 22–25
22:4… C++: Direct from github source
23# * Python: S3 https://dd-trace-py-builds.s3.amazonaws.com/<GIT_REF>/index.html
24# * Ruby: Direct from github source
25# * WAF: Direct from github source, but not working, …
Shell invokes the curl command lines 34–63
34:21… after a partial transfer would print the response twice
35curl_get() {
36 local output status=0
37 output=$(mktemp)
38 curl --retry 3 --retry-delay 5 --retry-connrefused --retry-all-errors --output "$output" "$@" || status=$?
39 if [ "$status" = 0 ]; then
40 cat "$output"
41 fi
42 rm -f "$output"
43 return "$status"
44}
⋯5 lines
50 fi
51
52 echo "Don't know how to load version $VERSION for $TARGET"
53
54 exit 1
55}
56
⋯7 lines
$GITHUB_TOKEN shell environment access lines 63–71
⋯4 lines
67
68ghcr_login_if_token_set() {
69 if [ -n "$GITHUB_TOKEN" ]; then
70 echo "Log to GHCR with token"
71 echo "$GITHUB_TOKEN" | docker login ghcr.io --password-stdin -u "actor" # username …
curl command substitution text lines 78–92
78:15… ded_branch
79 local response
80 local sha
81
82 encoded_branch=$(jq -rn --arg value "$branch" '$value | @uri')
83 if ! response=$(curl_get --fail --location --silent --show-error \
84 "${GITHUB_AUTH_HEADER[@]}" \
85 "https://api.github.com/repos/${repository}/branches/${encoded_branch}"); then
86 echo "Unable to resolve branch '${branch}' in ${repository}" >&2
87 exit 1
88 fi
89
90 sha=$(jq -r '.commit.sha // empty' <<< "$response")
91 if [[ ! "$sha" =~ ^[0-9a-f]{40}$ ]]; then
92 echo "Branch '${branch}' in ${repository} did not resolve to a commit SHA …
Curl body expands secret-named environment var lines 116–151
116:68… e"
117
118 # query filter seems not to be working ??
119 WORKFLOWS=$(curl_get --silent --fail --show-error -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$SLUG/actions/workflows/$WORKFLOW/runs?per_page=100")
120
121 if [ "$IGNORE_FAILED_WORKFLOW" = "true" ]; then
122 QUERY="[.workflow_runs[] | select(.conclusion != \"failure\" and .head_branch == \"$BRANCH\" and .status == \"completed\")][0]"
123 else
124 QUERY="[.workflow_runs[] | select(.head_branch == \"$BRANCH\" and .status == \"completed\")][0]"
125 fi
126
127 # this wil fail if there are more than 100 artifacts
128 ARTIFACT_URL=$(echo "$WORKFLOWS" | jq -r "$QUERY | .artifacts_url")
129 ARTIFACT_URL="$ARTIFACT_URL?per_page=100"
130
131 HTML_URL=$(echo "$WORKFLOWS" | jq -r "$QUERY | .html_url")
132 echo "Load artifacts for $HTML_URL"
133 ARTIFACTS=$(curl_get --fail --silent -H "Authorization: token $GITHUB_TOKEN" "$ARTIFACT_URL")
134 ARCHIVE_URL=$(echo "$ARTIFACTS" | jq -r --arg ARTIFACT_NAME "$ARTIFACT_NAME" '.artifacts | map(select(.name | contains($ARTIFACT_NAME))) | .[0].archive_download_url')
135 echo "Load archive $ARCHIVE_URL"
136
137 curl --retry 3 --retry-delay 5 --retry-connrefused --retry-all-errors --fail -H "Authorization: token $GITHUB_TOKEN" --output artifacts.zip -L "$ARCHIVE_URL"
138
139 mkdir -p artifacts/
140 unzip artifacts.zip -d artifacts/
141
142 find artifacts/ -type f -name "$PATTERN" -exec cp '{}' . ';'
143
144 rm -rf artifacts artifacts.zip
⋯7 lines

Showing the top 5 files — 3 more files (79 regions) not shown.

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.