Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the pattern order on rubygems regex matches #66

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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