Skip to content

Commit

Permalink
add slack webhook pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed May 20, 2024
1 parent a31d242 commit 7e905e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/patterns/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module Patterns
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/, # GitHub Personal Access Token
/github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}/, # GitHub Personal Access Token (fine-grained)
/ghs_[a-zA-Z0-9]{36}/, # Temporary GitHub Actions Tokens
/\b(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9\/\\_-]{17,}\.(?:[a-zA-Z0-9\/\\_-]{10,}={0,2})?)(?:['|\"|\n|\r|\s|\x60|;]|$)/, # JWT tokens
/(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----/ # private keys
%r{\b(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9/\\_-]{17,}\.(?:[a-zA-Z0-9/\\_-]{10,}={0,2})?)(?:['|"|\n|\r|\s|\x60|;]|$)}, # JWT tokens
/(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----/, # private keys
%r{https://hooks\.slack\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}}, # Slack webhook
].freeze
end
5 changes: 5 additions & 0 deletions spec/lib/redacting_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
case: "redacts from a Numeric match with extra numbers",
message: 123_999_999_999_123,
expected_message: "123[REDACTED]123"
},
{
case: "redacts a Slack webhook",
message: "posting slack message to: https://hooks.slack.com/services/T1BAAA111/B0111AAA111/MMMAAA333CCC222bbbAAA111",
expected_message: "posting slack message to: [REDACTED]"
}
].each do |test|
it "redacts #{test[:case]}" do
Expand Down

0 comments on commit 7e905e0

Please sign in to comment.