Skip to content

Commit

Permalink
depwatcher: immediately remove github_token from input
Browse files Browse the repository at this point in the history
for cred safety.
This resource prints and returns the input into the output, which
is unsafe if the input has creds. But, without printing the
input/ouptut, it makes it difficult to understand what's happening from
the UI.

So, immediately take the token out before anything else.
  • Loading branch information
arjun024 authored and robdimsdale committed Feb 27, 2025
1 parent 00e62ae commit 7691b03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dockerfiles/depwatcher/src/check.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ require "./depwatcher/*"
require "json"

data = JSON.parse(STDIN)
STDERR.puts data.to_json
source = data["source"]

if source.as_h.has_key?("github_token")
token = source["github_token"].to_s
ENV["OAUTH_AUTHORIZATION_TOKEN"] = token
# To avoid leaking the credential, immediately remove it from the data struct
source.as_h.delete("github_token")
end
STDERR.puts data.to_json

case type = source["type"].to_s
when "github_releases"
Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/depwatcher/src/in.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ require "json"

dir = ARGV[0]
data = JSON.parse(STDIN)
STDERR.puts data.to_json
source = data["source"]
version = data["version"]

if source.as_h.has_key?("github_token")
token = source["github_token"].to_s
ENV["OAUTH_AUTHORIZATION_TOKEN"] = token
# To avoid leaking the credential, immediately remove it from the data struct
source.as_h.delete("github_token")
end
STDERR.puts data.to_json

case type = source["type"].to_s
when "github_releases"
Expand Down

0 comments on commit 7691b03

Please sign in to comment.