-
-
Save roktas/1b38495a2980f0f71647b419f3ef2c89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
def suspicious?(content) | |
re = / | |
( | |
(master_(key)) | |
| | |
(access_(token|key)) | |
| | |
(secrets_(key)) | |
| | |
(bearer_(token)) | |
) | |
(?<right> | |
.{8} | |
) | |
/xim | |
(suspicious = content.match(re)) && !suspicious[:right].match?(/ | |
^ | |
( | |
[`'"] | |
| | |
\s*=\s*['"]*xxx | |
) | |
/xi) | |
end | |
abort 'Suspicious' if suspicious?(ARGF.read) | |
puts 'OK' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment