Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TruffleHog #441

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3462,15 +3462,6 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
);
files = "(\\.json$)|(\\.toml$)|(\\.mli?$)";
};
trim-trailing-whitespace =
{
name = "trim-trailing-whitespace";
description = "Trim trailing whitespace.";
types = [ "text" ];
stages = [ "commit" "push" "manual" ];
package = tools.pre-commit-hooks;
entry = "${hooks.trim-trailing-whitespace.package}/bin/trailing-whitespace-fixer";
};
treefmt =
let
inherit (hooks.treefmt) packageOverrides settings;
Expand All @@ -3496,6 +3487,32 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
packageOverrides = { treefmt = tools.treefmt; };
entry = "${hooks.treefmt.package}/bin/treefmt --fail-on-change";
};
trim-trailing-whitespace =
{
name = "trim-trailing-whitespace";
description = "Trim trailing whitespace.";
types = [ "text" ];
stages = [ "commit" "push" "manual" ];
package = tools.pre-commit-hooks;
entry = "${hooks.trim-trailing-whitespace.package}/bin/trailing-whitespace-fixer";
};
trufflehog =
{
name = "trufflehog";
description = "Secrets scanner";
entry =
let
script = pkgs.writeShellScript "precommit-trufflehog" ''
set -e
${hooks.trufflehog.package}/bin/trufflehog --no-update git "file://$(git rev-parse --show-top-level)" --since-commit HEAD --only-verified --fail
'';
in
builtins.toString script;
package = tools.trufflehog;

# trufflehog expects to run across the whole repo, not particular files
pass_filenames = false;
};
typos =
{
name = "typos";
Expand Down
2 changes: 2 additions & 0 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
, texlive
, topiary ? null ## Added in nixpkgs on Dec 2, 2022
, treefmt
, trufflehog
, typos
, typstfmt
, typstyle ? null ## Add in nixpkgs added on commit 800ca60
Expand Down Expand Up @@ -152,6 +153,7 @@ in
taplo
topiary
treefmt
trufflehog
typos
typstfmt
typstyle
Expand Down