Update CredentialChecker for new tool support and parsing improvements.

Review Request #11579 — Created April 6, 2021 and submitted — Latest diff uploaded

Information

ReviewBot
release-3.0.x

Reviewers

This updates CredentialChckerTool to subclass the newer BaseTool.

The original implementation had some regex patterns that didn't survive
the later stages of development, when combining into a single verbose
regex. Any pattern that expected a space (such as PGP private key
blocks) failed to match. This is now fixed.

The GitHub token checks have been greatly improved. As of April 2021,
GitHub introduced a new token format that can more easily be scanned,
and contains a checksum as the final 6 characters of the token, allowing
a scanner to detect real vs. fake tokens (though not active vs.
inactive). We now support enhanced validation for these GitHub tokens,
and have logic in place to allow for enhanced validation for future
tokens as well.

Most previous token types have been updated for modern token formats and
to reduce false-positives by preventing the tokens from being embedded
in other strings.

Token support has been added for:

  • Asana
  • Discord
  • Dropbox
  • Google Cloud Platform
  • JSON Web Tokens
  • Mailchimp
  • Mailgun
  • NPM
  • PyPI
  • Slack (WebHooks)
  • SSL Certificates
  • Stripe
  • Twilio

Unit tests pass on Python 2.7 and 3.x.

Extensively tested the new GitHub token validation logic. I've tested this
with a number of real-world tokens, along with garbage tokens, ensuring that
the real ones always validated and matched.

Commits

Files