Skip to content

Commit a744a5a

Browse files
committed
add a regex for rubygems tokens
1 parent 83de906 commit a744a5a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/patterns/default.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Patterns
1111
%r{https://hooks\.slack\.com/services/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{24}}, # Slack webhook
1212
%r{https://hooks\.slack\.com/workflows/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{9,}/[0-9]+?/[a-zA-Z0-9]{24}}, # Slack workflow
1313
/xoxp-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{6,})|xoxb-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})|xoxs-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})|xoxa-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})|xoxo-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})|xoxa-2-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})|xoxr-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})|xoxb-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})/, # Slack tokens
14-
/[sb]\.[a-zA-Z0-9]{24,}/ # vault token
14+
/[sb]\.[a-zA-Z0-9]{24,}/, # vault token
15+
/rubygems_[0-9a-f]{48}/ # RubyGems token
1516
].freeze
1617
end

spec/lib/redacting_logger_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
case: "redacts a vault token",
151151
message: "logging into vault with token: s.FakeToken1234567890123456",
152152
expected_message: "logging into vault with token: [REDACTED]"
153+
},
154+
{
155+
case: "redacts a RubyGems token",
156+
message: "using rubygems token: rubygems_0123456789abcdef0123456789abcdef0123456789abcdef",
157+
expected_message: "using rubygems token: rubygems_[REDACTED]"
153158
}
154159
].each do |test|
155160
it "redacts #{test[:case]}" do

0 commit comments

Comments
 (0)