Skip to content

Commit e6160d5

Browse files
authored
Merge pull request #66 from github/fix-pattern-order
fix the pattern order on `rubygems` regex matches
2 parents 9da7729 + a712f93 commit e6160d5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/patterns/default.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# These patterns are sourced from different places on the internet, some came from https://github.com/l4yton/RegHex
55
module Patterns
66
DEFAULT = [
7+
# RubyGems Token
8+
# https://guides.rubygems.org/api-key-scopes/
9+
/rubygems_[0-9a-f]{48}/,
10+
711
# GitHub Personal Access Token
812
# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
913
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/,
@@ -42,11 +46,7 @@ module Patterns
4246

4347
# Vault Tokens
4448
# https://github.com/hashicorp/vault/issues/27151
45-
/[sbr]\.[a-zA-Z0-9]{24,}/, # <= 1.9.x
46-
/hv[sbr]\.[a-zA-Z0-9]{24,}/, # >= 1.10
47-
48-
# RubyGems Token
49-
# https://guides.rubygems.org/api-key-scopes/
50-
/rubygems_[0-9a-f]{48}/
49+
/[sbr]\.[a-zA-Z0-9]{24,}/, # <= 1.9.x
50+
/hv[sbr]\.[a-zA-Z0-9]{24,}/ # >= 1.10
5151
].freeze
5252
end

spec/lib/redacting_logger_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
{
155155
case: "redacts a RubyGems token",
156156
message: "using rubygems token: rubygems_0123456789abcdef0123456789abcdef0123456789abcdef",
157-
expected_message: "using rubygems token: rubygems_[REDACTED]"
157+
expected_message: "using rubygems token: [REDACTED]"
158158
}
159159
].each do |test|
160160
it "redacts #{test[:case]}" do

0 commit comments

Comments
 (0)