-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #910 from dsalaza4/main
feat(back): #909 secure kubernetes
- Loading branch information
Showing
6 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
__nixpkgs__, | ||
fetchGithub, | ||
fetchUrl, | ||
isLinux, | ||
makeScript, | ||
... | ||
}: { | ||
name, | ||
setup, | ||
severity, | ||
... | ||
}: let | ||
bin = | ||
if isLinux | ||
then | ||
fetchUrl { | ||
url = "https://github.com/PaloAltoNetworks/rbac-police/releases/download/v1.0.1/rbac-police_v1.0.1_linux_amd64"; | ||
sha256 = "0k4dvc9r165q9lwidnks0vm7kqzi55l29p6iw9xy9l3982saihvi"; | ||
} | ||
else | ||
fetchUrl { | ||
url = "https://github.com/PaloAltoNetworks/rbac-police/releases/download/v1.0.1/rbac-police_v1.0.1_darwin_amd64"; | ||
sha256 = "16bi40pj2gq22w3b04bsfmh2iy2ax4jh8349lvpwm9rckkhrkg91"; | ||
}; | ||
repo = fetchGithub { | ||
owner = "PaloAltoNetworks"; | ||
repo = "rbac-police"; | ||
rev = "ffe47f709a747fc92cbeeb2eec688b4ea544b958"; | ||
sha256 = "0hna14rwkfadqq2higzz033hkdpxpnzi5vg340xsk50ipr41g689"; | ||
}; | ||
in | ||
makeScript { | ||
name = "secure-kubernetes-with-rbac-police-for-${name}"; | ||
replace = { | ||
__argBin__ = bin; | ||
__argRepo__ = repo; | ||
__argSeverity__ = severity; | ||
}; | ||
searchPaths = { | ||
bin = [__nixpkgs__.jq]; | ||
source = setup; | ||
}; | ||
entrypoint = ./entrypoint.sh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# shellcheck shell=bash | ||
|
||
function evaluate { | ||
local output="${1}" | ||
local evaluated | ||
local passed | ||
|
||
: \ | ||
&& if ! echo "${output}" | jq -rec &> /dev/null; then | ||
warn "Kubernetes cluster could not be reached." \ | ||
&& error "${output}" | ||
fi \ | ||
&& evaluated="$(echo "${output}" | jq -rec .summary.evaluated)" \ | ||
&& passed="$(echo "${output}" | jq -rec .summary.passed)" \ | ||
&& echo "${output}" | jq -re \ | ||
&& if [ "${passed}" != "${evaluated}" ]; then | ||
return 1 | ||
fi | ||
} | ||
|
||
function main { | ||
local bin | ||
local output | ||
|
||
: \ | ||
&& bin="$(mktemp)" \ | ||
&& copy "__argBin__" "${bin}" \ | ||
&& chmod +x "${bin}" \ | ||
&& pushd "__argRepo__" \ | ||
&& output="$("${bin}" "eval" "lib/" -s "__argSeverity__" 2>&1)" \ | ||
&& popd \ | ||
&& evaluate "${output}" \ | ||
|| return 1 | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/evaluator/modules/secure-kubernetes-with-rbac-police/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
__toModuleOutputs__, | ||
secureKubernetesWithRbacPolice, | ||
... | ||
}: { | ||
config, | ||
lib, | ||
... | ||
}: let | ||
type = lib.types.submodule (_: { | ||
options = { | ||
setup = lib.mkOption { | ||
default = []; | ||
type = lib.types.listOf lib.types.package; | ||
}; | ||
severity = lib.mkOption { | ||
default = "Low"; | ||
type = lib.types.str; | ||
}; | ||
}; | ||
}); | ||
output = name: { | ||
setup, | ||
severity, | ||
}: { | ||
name = "/secureKubernetesWithRbacPolice/${name}"; | ||
value = secureKubernetesWithRbacPolice { | ||
inherit name; | ||
inherit setup; | ||
inherit severity; | ||
}; | ||
}; | ||
in { | ||
options = { | ||
secureKubernetesWithRbacPolice = lib.mkOption { | ||
default = {}; | ||
type = lib.types.attrsOf type; | ||
}; | ||
}; | ||
config = { | ||
outputs = __toModuleOutputs__ output config.secureKubernetesWithRbacPolice; | ||
}; | ||
} |