2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildGoModule,
|
|
|
|
fetchFromGitHub,
|
|
|
|
git,
|
|
|
|
installShellFiles,
|
|
|
|
kubescape,
|
|
|
|
testers,
|
2021-12-06 16:07:01 +00:00
|
|
|
}:
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "kubescape";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "3.0.10";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2023-03-08 16:32:21 +00:00
|
|
|
owner = "kubescape";
|
2024-04-21 15:54:59 +00:00
|
|
|
repo = "kubescape";
|
2023-03-08 16:32:21 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-r6w2Cfyjxqf/1DMBGgmE8Oh/WnvBOa7mAEGXnPjk1Pg=";
|
2023-03-08 16:32:21 +00:00
|
|
|
fetchSubmodules = true;
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
2023-03-08 16:32:21 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
vendorHash = "sha256-WPa6IKPjdBtoHYKA2yYtaI1LCbkyv374fcThxbSEKxo=";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
subPackages = [ "." ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeCheckInputs = [ git ];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2024-04-21 15:54:59 +00:00
|
|
|
"-X=github.com/kubescape/kubescape/v3/core/cautils.BuildNumber=v${version}"
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2021-10-28 06:52:43 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
preCheck = ''
|
2024-04-21 15:54:59 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# Remove tests that use networking
|
2022-06-16 17:23:12 +00:00
|
|
|
rm core/pkg/resourcehandler/urlloader_test.go
|
2023-03-08 16:32:21 +00:00
|
|
|
rm core/pkg/opaprocessor/*_test.go
|
2023-08-22 20:05:09 +00:00
|
|
|
rm core/cautils/getter/downloadreleasedpolicy_test.go
|
2024-04-21 15:54:59 +00:00
|
|
|
rm core/core/initutils_test.go
|
|
|
|
rm core/core/list_test.go
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# Remove tests that use networking
|
2022-06-16 17:23:12 +00:00
|
|
|
substituteInPlace core/pkg/resourcehandler/repositoryscanner_test.go \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "TestScanRepository" "SkipScanRepository" \
|
|
|
|
--replace-fail "TestGit" "SkipGit"
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# Remove test that requires networking
|
2022-06-16 17:23:12 +00:00
|
|
|
substituteInPlace core/cautils/scaninfo_test.go \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "TestSetContextMetadata" "SkipSetContextMetadata"
|
2022-04-03 18:54:34 +00:00
|
|
|
'';
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --cmd kubescape \
|
|
|
|
--bash <($out/bin/kubescape completion bash) \
|
|
|
|
--fish <($out/bin/kubescape completion fish) \
|
|
|
|
--zsh <($out/bin/kubescape completion zsh)
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = kubescape;
|
|
|
|
command = "kubescape version";
|
|
|
|
version = "v${version}";
|
|
|
|
};
|
2022-04-03 18:54:34 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Tool for testing if Kubernetes is deployed securely";
|
2023-03-08 16:32:21 +00:00
|
|
|
homepage = "https://github.com/kubescape/kubescape";
|
|
|
|
changelog = "https://github.com/kubescape/kubescape/releases/tag/v${version}";
|
2021-10-28 06:52:43 +00:00
|
|
|
longDescription = ''
|
|
|
|
Kubescape is the first open-source tool for testing if Kubernetes is
|
|
|
|
deployed securely according to multiple frameworks: regulatory, customized
|
|
|
|
company policies and DevSecOps best practices, such as the NSA-CISA and
|
|
|
|
the MITRE ATT&CK®.
|
|
|
|
Kubescape scans K8s clusters, YAML files, and HELM charts, and detect
|
|
|
|
misconfigurations and software vulnerabilities at early stages of the
|
|
|
|
CI/CD pipeline and provides a risk score instantly and risk trends over
|
|
|
|
time. Kubescape integrates natively with other DevOps tools, including
|
|
|
|
Jenkins, CircleCI and Github workflows.
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
license = licenses.asl20;
|
2024-05-15 15:35:15 +00:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
fab
|
|
|
|
jk
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "kubescape";
|
|
|
|
broken = stdenv.isDarwin;
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
|
|
|
}
|