From aa91fd3e5e8705c5f60413ea002319d47f4b5780 Mon Sep 17 00:00:00 2001 From: Ivan Kalita <72927991+ivankalitaonefootball@users.noreply.github.com> Date: Thu, 2 Sep 2021 16:26:01 +0200 Subject: [PATCH] Fix default twitter rules (#614) Regexps for default Twitter rules ("Twitter Secret Key" and "Twitter Client ID") have a small flaw that make the default configuration vulnerable to some false-positives. I believe these rules should detect the cases like (SOME_CLIENT_ID should be longer): ``` "twitter_client_id": "SOME_CLIENT_ID" ``` However, currently the twitter rules also detect the false positives for the cases like: ``` someObj := twitter.NewObjectWithALongName() config.Twitter.DomainAccessToken ``` I'm trying to address this issue the similar way it's done for facebook client ids and AWS secret keys, where the secret is expected to be quoted. --- config/default.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/default.go b/config/default.go index cb9d8f1a..5afd90a7 100644 --- a/config/default.go +++ b/config/default.go @@ -33,12 +33,12 @@ title = "gitleaks config" [[rules]] description = "Twitter Secret Key" - regex = '''(?i)twitter(.{0,20})?[0-9a-z]{35,44}''' + regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{35,44}['\"]''' tags = ["key", "Twitter"] [[rules]] description = "Twitter Client ID" - regex = '''(?i)twitter(.{0,20})?[0-9a-z]{18,25}''' + regex = '''(?i)twitter(.{0,20})?['\"][0-9a-z]{18,25}['\"]''' tags = ["client", "Twitter"] [[rules]]