2021-11-10 09:04:07 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
2023-09-05 18:27:41 +00:00
|
|
|
, kubescape
|
|
|
|
, testers
|
2021-11-10 09:04:07 +00:00
|
|
|
}:
|
2021-09-03 17:23:07 +00:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "kubescape";
|
2023-09-05 18:27:41 +00:00
|
|
|
version = "2.9.1";
|
2021-09-03 17:23:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2023-03-08 00:26:48 +00:00
|
|
|
owner = "kubescape";
|
2021-09-03 17:23:07 +00:00
|
|
|
repo = pname;
|
2023-03-05 19:48:59 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-09-05 18:27:41 +00:00
|
|
|
hash = "sha256-FKWR3pxFtJBEa14Mn3RKsLvrliHaj6TuF4F2JLtw2qA=";
|
2023-03-05 19:48:59 +00:00
|
|
|
fetchSubmodules = true;
|
2021-09-03 17:23:07 +00:00
|
|
|
};
|
2023-03-05 19:48:59 +00:00
|
|
|
|
2023-09-05 18:27:41 +00:00
|
|
|
vendorHash = "sha256-zcv8oYm6srwkwT3pUECtTewyqVVpCIcs3i0VRTRft68=";
|
2021-09-03 17:23:07 +00:00
|
|
|
|
2021-11-10 09:04:07 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2023-08-17 07:23:04 +00:00
|
|
|
"-X=github.com/kubescape/kubescape/v2/core/cautils.BuildNumber=v${version}"
|
2021-11-10 09:04:07 +00:00
|
|
|
];
|
2021-10-26 13:27:47 +00:00
|
|
|
|
2022-04-11 14:58:37 +00:00
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# Feed in all but the integration tests for testing
|
|
|
|
# This is because subPackages above limits what is built to just what we
|
|
|
|
# want but also limits the tests
|
|
|
|
# Skip httphandler tests - the checkPhase doesn't care about excludedPackages
|
|
|
|
getGoDirs() {
|
|
|
|
go list ./... | grep -v httphandler
|
|
|
|
}
|
|
|
|
|
2022-05-24 08:57:34 +00:00
|
|
|
# remove tests that use networking
|
|
|
|
rm core/pkg/resourcehandler/urlloader_test.go
|
2023-03-05 19:48:59 +00:00
|
|
|
rm core/pkg/opaprocessor/*_test.go
|
2023-08-17 07:23:04 +00:00
|
|
|
rm core/cautils/getter/downloadreleasedpolicy_test.go
|
2022-05-24 08:57:34 +00:00
|
|
|
|
|
|
|
# remove tests that use networking
|
|
|
|
substituteInPlace core/pkg/resourcehandler/repositoryscanner_test.go \
|
|
|
|
--replace "TestScanRepository" "SkipScanRepository" \
|
|
|
|
--replace "TestGit" "SkipGit"
|
|
|
|
|
2022-05-26 07:53:03 +00:00
|
|
|
# remove test that requires networking
|
2022-05-24 08:57:34 +00:00
|
|
|
substituteInPlace core/cautils/scaninfo_test.go \
|
2022-05-26 07:53:03 +00:00
|
|
|
--replace "TestSetContextMetadata" "SkipSetContextMetadata"
|
2022-03-31 16:53:17 +00:00
|
|
|
'';
|
|
|
|
|
2021-10-26 13:27:47 +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-03 17:23:07 +00:00
|
|
|
|
2023-09-05 18:27:41 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = kubescape;
|
|
|
|
command = "kubescape version";
|
|
|
|
version = "v${version}";
|
|
|
|
};
|
2023-03-08 00:26:48 +00:00
|
|
|
|
2021-09-03 17:23:07 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Tool for testing if Kubernetes is deployed securely";
|
2023-03-08 00:26:48 +00:00
|
|
|
homepage = "https://github.com/kubescape/kubescape";
|
|
|
|
changelog = "https://github.com/kubescape/kubescape/releases/tag/v${version}";
|
2021-10-26 13:27:47 +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-03 17:23:07 +00:00
|
|
|
license = licenses.asl20;
|
2021-10-26 13:27:47 +00:00
|
|
|
maintainers = with maintainers; [ fab jk ];
|
2021-09-03 17:23:07 +00:00
|
|
|
};
|
|
|
|
}
|