Skip to content

Commit 4dd5a5c

Browse files
authored
Merge pull request #49 from github/document_patterns
feat: add documentation and links for patterns
2 parents 770cf01 + 650b990 commit 4dd5a5c

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

lib/patterns/default.rb

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
11
# frozen_string_literal: true
22

33
# This module contains the default patterns to redact.
4+
# These patterns are sourced from different places on the internet, some came from https://github.com/l4yton/RegHex
45
module Patterns
56
DEFAULT = [
6-
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/, # GitHub Personal Access Token
7-
/github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}/, # GitHub Personal Access Token (fine-grained)
8-
/ghs_[a-zA-Z0-9]{36}/, # Temporary GitHub Actions Tokens
9-
%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
10-
/(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----/, # private keys
11-
%r{https://hooks\.slack\.com/services/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{24}}, # Slack webhook
12-
%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
13-
/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-
/[sbr]\.[a-zA-Z0-9]{24,}/, # vault token for 1.9.x or earlier
15-
/hv[sbr]\.[a-zA-Z0-9]{24,}/, # vault token for 1.10 and later
16-
/rubygems_[0-9a-f]{48}/ # RubyGems token
7+
# GitHub Personal Access Token
8+
# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
9+
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/,
10+
/github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}/, # Fine Grained
11+
/ghs_[a-zA-Z0-9]{36}/, # Temporary Actions Tokens
12+
13+
# JWT Token
14+
# https://en.wikipedia.org/wiki/JSON_Web_Token
15+
%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|;]|$)},
16+
17+
# PEM Private Keys
18+
# https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail
19+
/(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----/,
20+
21+
# Slack Webhook
22+
# https://api.slack.com/messaging/webhooks
23+
%r{https://hooks\.slack\.com/services/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{24}},
24+
25+
# Slack Workflows
26+
%r{https://hooks\.slack\.com/workflows/[a-zA-Z0-9]{9,}/[a-zA-Z0-9]{9,}/[0-9]+?/[a-zA-Z0-9]{24}},
27+
28+
# Slack Trigger
29+
# https://slack.com/help/articles/360041352714-Build-a-workflow--Create-a-workflow-that-starts-outside-of-Slack
30+
%r{https://hooks\.slack\.com/triggers/.+},
31+
32+
# Slack Tokens
33+
# https://api.slack.com/authentication/token-types
34+
/xoxp-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{6,})/,
35+
/xoxb-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})/,
36+
/xoxs-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})/,
37+
/xoxa-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})/,
38+
/xoxo-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})/,
39+
/xoxa-2-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})/,
40+
/xoxr-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[0-9a-f]{7,})/,
41+
/xoxb-(?:[0-9]{7,})-(?:[0-9]{7,})-(?:[A-Za-z0-9]{14,})/,
42+
43+
# Vault Tokens
44+
# 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}/
1751
].freeze
1852
end

lib/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module RedactingLogger
44
module Version
5-
VERSION = "1.3.0"
5+
VERSION = "1.3.1"
66
end
77
end

0 commit comments

Comments
 (0)