emailcheck is a pre-commit hook that checks staged files
for strings which look like personal email addresses.
Email addresses are assumed to be ASCII-encoded without attempting to guess the surrounding text encoding. Binary files are ignored.
False positives can be excluded by adding them to a .emailcheck_ignore file.
Assuming pre-commit in already installed in the target repository you can install this
hook by updating the .pre-commit-config.yaml file.
First ensure that pre-commit will install pre-push hooks:
default_install_hook_types:
- pre-commit
- pre-pushThen add an entry to the repos list:
repos:
- repo: https://github.com/bennettoxford/emailcheck
rev: v1.0.1
hooks:
- id: emailcheckOnce installed, emailcheck runs automatically when you commit or push. If it finds an
email-like string, it prints the matching filename and address, then exits non-zero so
the commit or push is blocked:
Detected strings which look like email addresses:
contacts.txt: alice@test.org
This operation was blocked to prevent a possible data leak. If these
legitimately belong in this repo then you can add them to an
`.emailcheck_ignore` file in the project root directory.
To ignore all addresses from a particular domain use: @example-domain.com
You can also run it manually:
pre-commit run emailcheck --all-filesTo allow specific addresses, add a .emailcheck_ignore file in the root of the
repository being checked:
# fixture addresses
alice@test.org
bob@test.org carol@test.org # whitespace-separated addresses are supported
# Entire domains can be ignored where appropriate
@my-internal-domain.org
Blank lines and whitespace are ignored. Anything after # on a line is treated as a
comment. Address matching is case-insensitive.
The domain @example.com is automatically ignored.
Please see the additional information.