|
| 1 | +{ lib |
| 2 | +, stdenv |
| 3 | +, buildGoModule |
| 4 | +, fetchFromGitHub |
| 5 | +, installShellFiles |
| 6 | +, fetchpatch |
| 7 | +}: |
| 8 | + |
| 9 | +buildGoModule rec { |
| 10 | + pname = "kdigger"; |
| 11 | + version = "1.2.0"; |
| 12 | + |
| 13 | + src = fetchFromGitHub { |
| 14 | + owner = "quarkslab"; |
| 15 | + repo = pname; |
| 16 | + rev = "v${version}"; |
| 17 | + sha256 = "sha256-j4HIwfRIUpV25DmbQ+9go8aJMEYaFDPxrdr/zGWBeVU="; |
| 18 | + # populate values that require us to use git. By doing this in postFetch we |
| 19 | + # can delete .git afterwards and maintain better reproducibility of the src. |
| 20 | + leaveDotGit = true; |
| 21 | + postFetch = '' |
| 22 | + cd "$out" |
| 23 | + git rev-parse HEAD > $out/COMMIT |
| 24 | + find "$out" -name .git -print0 | xargs -0 rm -rf |
| 25 | + ''; |
| 26 | + }; |
| 27 | + vendorSha256 = "sha256-3vn3MsE/4lBw89wgYgzm0RuJJ5RQTkgS6O74PpfFcUk="; |
| 28 | + |
| 29 | + patches = [ |
| 30 | + (fetchpatch { |
| 31 | + name = "simplify-ldflags.patch"; |
| 32 | + url = "https://github.com/quarkslab/kdigger/pull/2.patch"; |
| 33 | + sha256 = "sha256-d/NdoAdnheVgdqr2EF2rNn3gJvbjRZtOKFw2DqWR8TY="; |
| 34 | + }) |
| 35 | + ]; |
| 36 | + |
| 37 | + nativeBuildInputs = [ installShellFiles ]; |
| 38 | + |
| 39 | + CGO_ENABLED = 0; |
| 40 | + ldflags = [ |
| 41 | + "-s" |
| 42 | + "-w" |
| 43 | + "-X github.com/quarkslab/kdigger/commands.VERSION=v${version}" |
| 44 | + "-X github.com/quarkslab/kdigger/commands.BUILDERARCH=${stdenv.hostPlatform.linuxArch}" |
| 45 | + ]; |
| 46 | + |
| 47 | + preBuild = '' |
| 48 | + ldflags+=" -X github.com/quarkslab/kdigger/commands.GITCOMMIT=$(cat COMMIT)" |
| 49 | + ''; |
| 50 | + |
| 51 | + postInstall = '' |
| 52 | + installShellCompletion --cmd kdigger \ |
| 53 | + --bash <($out/bin/kdigger completion bash) \ |
| 54 | + --fish <($out/bin/kdigger completion fish) \ |
| 55 | + --zsh <($out/bin/kdigger completion zsh) |
| 56 | + ''; |
| 57 | + |
| 58 | + doInstallCheck = true; |
| 59 | + installCheckPhase = '' |
| 60 | + runHook preInstallCheck |
| 61 | +
|
| 62 | + $out/bin/kdigger --help |
| 63 | +
|
| 64 | + runHook postInstallCheck |
| 65 | + ''; |
| 66 | + |
| 67 | + meta = with lib; { |
| 68 | + homepage = "https://github.com/quarkslab/kdigger"; |
| 69 | + changelog = "https://github.com/quarkslab/kdigger/releases/tag/v${version}"; |
| 70 | + description = "An in-pod context discovery tool for Kubernetes penetration testing"; |
| 71 | + longDescription = '' |
| 72 | + kdigger, short for "Kubernetes digger", is a context discovery tool for |
| 73 | + Kubernetes penetration testing. This tool is a compilation of various |
| 74 | + plugins called buckets to facilitate pentesting Kubernetes from inside a |
| 75 | + pod. |
| 76 | + ''; |
| 77 | + license = licenses.asl20; |
| 78 | + maintainers = with maintainers; [ jk ]; |
| 79 | + # aarch64-linux support progress - https://github.com/quarkslab/kdigger/issues/3 |
| 80 | + platforms = [ "x86_64-linux" ]; |
| 81 | + }; |
| 82 | +} |
0 commit comments