Skip to content

Commit

Permalink
Merge pull request #66 from github/fix-pattern-order
Browse files Browse the repository at this point in the history
fix the pattern order on `rubygems` regex matches
  • Loading branch information
GrantBirki authored Jul 23, 2024
2 parents 9da7729 + a712f93 commit e6160d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/patterns/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# These patterns are sourced from different places on the internet, some came from https://github.com/l4yton/RegHex
module Patterns
DEFAULT = [
# RubyGems Token
# https://guides.rubygems.org/api-key-scopes/
/rubygems_[0-9a-f]{48}/,

# GitHub Personal Access Token
# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/,
Expand Down Expand Up @@ -42,11 +46,7 @@ module Patterns

# Vault Tokens
# https://github.com/hashicorp/vault/issues/27151
/[sbr]\.[a-zA-Z0-9]{24,}/, # <= 1.9.x
/hv[sbr]\.[a-zA-Z0-9]{24,}/, # >= 1.10

# RubyGems Token
# https://guides.rubygems.org/api-key-scopes/
/rubygems_[0-9a-f]{48}/
/[sbr]\.[a-zA-Z0-9]{24,}/, # <= 1.9.x
/hv[sbr]\.[a-zA-Z0-9]{24,}/ # >= 1.10
].freeze
end
2 changes: 1 addition & 1 deletion spec/lib/redacting_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
{
case: "redacts a RubyGems token",
message: "using rubygems token: rubygems_0123456789abcdef0123456789abcdef0123456789abcdef",
expected_message: "using rubygems token: rubygems_[REDACTED]"
expected_message: "using rubygems token: [REDACTED]"
}
].each do |test|
it "redacts #{test[:case]}" do
Expand Down

0 comments on commit e6160d5

Please sign in to comment.