File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
modules/post/multi/gather Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,25 @@ def run
40
40
download_key ( paths )
41
41
end
42
42
43
+ # Ruby gem credentials are pretty standard and can come
44
+ # in a few flavors, but the most common are straight yaml
45
+ # and json, both of which are colon delimited. I suppose
46
+ # you could concievably have more than one, but that'd be
47
+ # manually editing, and the first one is probably the best
48
+ # one anyway.
49
+ def extract_key ( path )
50
+ data = read_file ( path )
51
+ keys = data . split ( ":" ) . strip . select { |k | k =~ /[0-9a-f]{32}/ }
52
+ keys . first
53
+ end
54
+
43
55
def download_key ( paths )
44
56
print_status ( "Looting #{ paths . count } files" )
45
57
paths . each do |path |
46
58
path . chomp!
47
59
next if [ '.' , '..' ] . include? ( path )
48
60
49
- rubygems_api_key = YAML . load ( read_file ( path ) ) [ :rubygems_api_key ]
61
+ rubygems_api_key = extract_key ( path )
50
62
next unless rubygems_api_key
51
63
52
64
print_good ( "Found a RubyGems API key: #{ rubygems_api_key } " )
You can’t perform that action at this time.
0 commit comments