From 1493cc14ed25f1492865b663b765dd3c34565a49 Mon Sep 17 00:00:00 2001 From: Wes Dean Date: Mon, 16 Dec 2024 15:50:32 -0500 Subject: [PATCH 1/2] Add a basic check to look for .env files --- .pre-commit-config.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 471fe145..1b1f7e0e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,3 +41,20 @@ repos: description: Detect hardcoded secrets using Gitleaks language: docker_image entry: zricethezav/gitleaks:v8.15.0 protect --verbose --redact --staged + + # fail if a commit includes a file named '.env' + # BAD: + # .env + # foo/.env + # + # Good: + # sample.env + # env.sample + # share/examples/sample.env + - repo: local + hooks: + - id: no-dotenv-files + name: "Files named .env are not allowed." + entry: "Files may not be named .env" + language: fail + files: '^(.*[/])?[.]env$' From 6fe5eabd3d47e386e2a7dfd51b5e3f2fd41ff7ed Mon Sep 17 00:00:00 2001 From: Wesley Dean Date: Mon, 16 Dec 2024 20:55:24 +0000 Subject: [PATCH 2/2] [MegaLinter] Apply linters fixes --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b1f7e0e..ecaf1261 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,4 +57,4 @@ repos: name: "Files named .env are not allowed." entry: "Files may not be named .env" language: fail - files: '^(.*[/])?[.]env$' + files: "^(.*[/])?[.]env$"