Skip to content

Commit b54aac8

Browse files
committed
Add ripsecrets hook
1 parent 6184635 commit b54aac8

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

modules/hooks.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,20 @@ in
12221222
};
12231223
};
12241224
};
1225+
ripsecrets = mkOption {
1226+
description = lib.mdDoc "ripsecrets hook";
1227+
type = types.submodule {
1228+
imports = hookModule;
1229+
options.settings = {
1230+
additionalPatterns =
1231+
mkOption {
1232+
type = types.listOf types.str;
1233+
description = lib.mdDoc "Additional regex patterns used to find secrets. If there is a matching group in the regex the matched group will be tested for randomness before being reported as a secret.";
1234+
default = [ ];
1235+
};
1236+
};
1237+
};
1238+
};
12251239
rome = mkOption {
12261240
description = lib.mdDoc "rome hook";
12271241
type = types.submodule {
@@ -2677,6 +2691,26 @@ in
26772691
# all file names in a single run.
26782692
require_serial = true;
26792693
};
2694+
ripsecrets =
2695+
{
2696+
name = "ripsecrets";
2697+
description = "Prevent committing secret keys into your source code";
2698+
package = tools.ripsecrets;
2699+
entry =
2700+
let
2701+
cmdArgs = mkCmdArgs (
2702+
with hooks.ripsecrets.settings; [
2703+
[ true "--strict-ignore" ]
2704+
[
2705+
(additionalPatterns != [ ])
2706+
"--additional-pattern ${lib.strings.concatStringsSep " --additional-pattern " additionalPatterns}"
2707+
]
2708+
]
2709+
);
2710+
in
2711+
"${hooks.ripsecrets.package}/bin/ripsecrets ${cmdArgs}";
2712+
types = [ "text" ];
2713+
};
26802714
rome =
26812715
{
26822716
name = "rome";

nix/tools.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
, pre-commit-hook-ensure-sops ? null
5656
, python3Packages
5757
, php82Packages
58+
, ripsecrets ? null
5859
, ruff ? null
5960
, runCommand
6061
, rustfmt
@@ -135,6 +136,7 @@ in
135136
ormolu
136137
pre-commit-hook-ensure-sops
137138
revive
139+
ripsecrets
138140
ruff
139141
rustfmt
140142
shellcheck

0 commit comments

Comments
 (0)