Skip to content

Commit

Permalink
feat(compliance): add cis_1.8 for kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrooot committed Mar 27, 2024
1 parent fd572fb commit 812e27d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
21 changes: 0 additions & 21 deletions dashboard/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,6 @@ def generate_help_menu():
className="h-screen mx-auto",
)

# Matomo integration
script = """
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setDoNotTrack", true]);
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://prowlerpro.matomo.cloud/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '2']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://cdn.matomo.cloud/prowlerpro.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
"""


# Callback to update navigation bar
@dashboard.callback(Output("navigation-bar", "children"), [Input("url", "pathname")])
Expand Down Expand Up @@ -185,7 +165,6 @@ def update_nav_bar(pathname):
[html.Ul(generate_help_menu(), className="")],
className="flex flex-col gap-y-6 mt-auto",
),
html.Script(script),
],
className="flex flex-col bg-prowler-stone-900 py-7 h-full",
)
24 changes: 24 additions & 0 deletions dashboard/compliance/cis_1_8_kubernetes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import warnings

from dashboard.common_methods import get_section_containers_cis

warnings.filterwarnings("ignore")


def get_table(data):
aux = data[
[
"REQUIREMENTS_ID",
"REQUIREMENTS_DESCRIPTION",
"REQUIREMENTS_ATTRIBUTES_SECTION",
"CHECKID",
"STATUS",
"REGION",
"ACCOUNTID",
"RESOURCEID",
]
].copy()

return get_section_containers_cis(
aux, "REQUIREMENTS_ID", "REQUIREMENTS_ATTRIBUTES_SECTION"
)
8 changes: 8 additions & 0 deletions dashboard/lib/layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def create_layout_overview(
className="flex justify-between items-center",
),
html.Div(id="table", className="grid"),
html.Img(
src="https://prowlerpro.matomo.cloud/matomo.php?idsite=2&amp;rec=1&amp;action_name=Overview",
alt="",
),
],
className="grid gap-x-8 gap-y-8 2xl:container mx-auto",
)
Expand Down Expand Up @@ -142,6 +146,10 @@ def create_layout_compliance(
className="text-prowler-stone-900 text-lg font-bold",
),
html.Div(className="flex flex-wrap", id="output"),
html.Img(
src="https://prowlerpro.matomo.cloud/matomo.php?idsite=2&amp;rec=1&amp;action_name=Compliance",
alt="",
),
],
className="grid gap-x-8 gap-y-8 2xl:container mx-auto",
)
8 changes: 8 additions & 0 deletions dashboard/pages/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ def load_csv_files(files):
if "gcp" in analytics_input or "azure" in analytics_input:
data = data.rename(columns={"LOCATION": "REGION"})

# Add the column ACCOUNTID to the data if the provider is kubernetes
if "kubernetes" in analytics_input:
data.rename(columns={"CONTEXT": "ACCOUNTID"}, inplace=True)
data.rename(columns={"NAMESPACE": "REGION"}, inplace=True)
if "REQUIREMENTS_ATTRIBUTES_PROFILE" in data.columns:
data["REQUIREMENTS_ATTRIBUTES_PROFILE"] = data[
"REQUIREMENTS_ATTRIBUTES_PROFILE"
].apply(lambda x: x.split(" - ")[0])
# Filter the chosen level of the CIS
if is_level_1:
data = data[data["REQUIREMENTS_ATTRIBUTES_PROFILE"] == "Level 1"]
Expand Down

0 comments on commit 812e27d

Please sign in to comment.