All notable changes to this project are documented here. Versions follow Semantic Versioning.
Starting with 1.2.1, release tags have no v prefix.
block-insecure-codealso blocks shell execution functions by default:exec,shell_exec,system,passthru,popen,proc_open,pcntl_execandcreate_functionin PHP, andnew Function(...)in JavaScript/TypeScript. Use--exclude-functionsto allow some.block-insecure-codeonly matches global function calls. Method and static calls ($pdo->exec(),obj.eval()) and function definitions are no longer matched, exceptwindow.eval(),globalThis.eval()andself.eval().
forbid-env-files,forbid-dump-files,forbid-log-filesandforbid-cache-files: code-free hooks (language: fail) customized with pre-commit's standardfilesandexcludeoptions. Without customization, they forbid exactly the same files as theblock-*-fileshooks.- README: migration guide, and recommended companion hooks (gitleaks for secrets,
check-added-large-files,detect-private-key).
block-env-files,block-dump-files,block-log-filesandblock-cache-fileswill be removed in 3.0.0. Their name shows their replacement on every run, and their failure output includes a deprecation note.
- The Python package is renamed
ctrlweb_pre_commit_hooks(distributionctrlweb-pre-commit-hooks), so it no longer shares its name with the officialpre-commit/pre-commit-hooks. Hook ids and arguments are unchanged.
block-debug-statementsandblock-insecure-codenow ignore comments and strings properly instead of cutting each line at the first//or#:- Calls after a URL or a
#color on the same line are now found ($url = "https://…"; var_dump($x);). - Calls inside docblocks,
/* */comments, strings, heredocs and template literals are no longer flagged (echo "use var_dump()";). - PHP 8 attributes (
#[...]) are not treated as comments. - Inline HTML outside
<?php ?>and Blade templates are still checked ({{ dd($x) }},@dd($x)). - In
diffmode, a line added inside an existing/* */comment is not flagged.
- Calls after a URL or a
block-debug-statementsandblock-insecure-codecan run in parallel on large file sets (require_serialremoved).- All hooks declare
minimum_pre_commit_version: 3.2.0, required bystages: [pre-commit]. - Python 3.9 or later is required.
- MIT license.
- CI on Ubuntu and Windows, linting with ruff.
block-env-filesandblock-log-filesnow match file names in any directory (e.g.config/.env,logs/error_log), not only at the repository root.--extra-*and--exclude-*values are case-insensitive, and a file matching any--exclude-*value is never blocked (--exclude-prefixespreviously had no effect).ddno longer matchesadd((e.g.$collection->add(...)), andevalno longer matchesliteral_eval(or$eval(. Pattern names are matched literally.block-insecure-codeno longer crashes on binary files, and both content hooks no longer crash on files that aren't valid UTF-8 or when printing non-ASCII lines on Windows.diffmode works withcolor.ui=always, reports correct line numbers after a "No newline at end of file" marker, and uses--from-ref/--to-refin CI.
block-env-filesallows.env.example,.env.sample,.env.dist,.env.templateandenv.d.tsby default.block-dump-filesalso blocks.sqlite3files.block-debug-statementsalso checks.mjs,.cjsand.tsxfiles.block-insecure-codeonly checks PHP and JavaScript/TypeScript files, as documented.
block-insecure-codehook, blockingeval()calls.
--check-mode=diffforblock-debug-statements, to check only the modified lines.
--exclude-patternsofblock-debug-statementshad no effect.
block-debug-statementshook, blockingvar_dump(),print_r(),dd()andconsole.log()in PHP and JavaScript files.
block-env-files,block-dump-files,block-log-filesandblock-cache-fileshooks, with--extra-*and--exclude-*arguments.