Skip to content

Commit 387c2cd

Browse files
committed
Add detect-secrets as a new git hook
1 parent 59f1785 commit 387c2cd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

modules/hooks.nix

+20
Original file line numberDiff line numberDiff line change
@@ -2556,6 +2556,26 @@ in
25562556
entry = "${hooks.detect-private-keys.package}/bin/detect-private-key";
25572557
types = [ "text" ];
25582558
};
2559+
detect-secrets =
2560+
{
2561+
name = "detect-secrets";
2562+
description = "An enterprise friendly way of detecting and preventing secrets in code.";
2563+
package = tools.detect-secrets;
2564+
entry =
2565+
let
2566+
# 1. Check if `.secrets.baseline` exists if not we need to run `detect-secrets scan` to create it.
2567+
# 2. Run `detect-secrets audit .secrets.baseline` to scan the files.
2568+
script = pkgs.writeShellScript "precommit-detect-secrets" ''
2569+
if [ ! -f .secrets.baseline ]; then
2570+
${hooks.detect-secrets.package}/bin/detect-secrets scan
2571+
fi
2572+
${hooks.detect-secrets.package}/bin/detect-secrets audit .secrets.baseline
2573+
'';
2574+
in
2575+
toString
2576+
script;
2577+
types = [ "text" ];
2578+
};
25592579
dhall-format = {
25602580
name = "dhall-format";
25612581
description = "Dhall code formatter.";

0 commit comments

Comments
 (0)