Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboards): add new Prowler dashboards #3575

Merged
merged 53 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
36a8a28
feat(dashboards): add prowler dashboards
sergargar Mar 18, 2024
9384c5c
dashboard integration
sergargar Mar 18, 2024
9fac22b
first cleaning
sergargar Mar 18, 2024
cdfb743
second cleaning
sergargar Mar 18, 2024
a5bdb00
feat(compliance): code refactor
pedrooot Mar 19, 2024
1511df7
feat(compliance): improve compliance logic WIP
pedrooot Mar 19, 2024
0565f3d
feat(dashboards): improve logic
pedrooot Mar 20, 2024
605e95f
delete unnecessary files
sergargar Mar 20, 2024
a7fcbb9
typo(): remove print
sergargar Mar 20, 2024
12ac9c7
feat(dashboards): refactor compliance code
pedrooot Mar 20, 2024
a8af31d
now yes
pedrooot Mar 21, 2024
f1bd765
feat(dashboard): handle muted status
pedrooot Mar 21, 2024
0b6c1f7
fix(css): update gitignore and add css
sergargar Mar 21, 2024
5c0d63f
fix(compliance): delete sorting to make values correct
pedrooot Mar 22, 2024
b5d5157
feat(overview): add muted to provider cards
pedrooot Mar 22, 2024
3e1e622
feat(overview): fix typo
pedrooot Mar 22, 2024
6010ba2
improve dashboard logic
sergargar Mar 22, 2024
879afec
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Mar 22, 2024
5942698
add note
sergargar Mar 22, 2024
c3bd22f
solve poetry.lock
sergargar Mar 22, 2024
fb0d2b2
solve flake8
sergargar Mar 22, 2024
3331f7b
black format
sergargar Mar 22, 2024
0c2aecb
solve vulture
sergargar Mar 22, 2024
25be12f
solve black
sergargar Mar 22, 2024
c806367
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Mar 22, 2024
02bab82
feat(overview): handle v3 csv outputs
pedrooot Mar 22, 2024
e8acdc4
add pip optimization
sergargar Mar 22, 2024
443d5c6
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Mar 25, 2024
f3af004
feat(dashboard): handle regions for azure
pedrooot Mar 25, 2024
708ae66
fix(compliance): refactor code for regions
pedrooot Mar 25, 2024
3df4633
feat(dashboard): code refactor
pedrooot Mar 27, 2024
15ac0b0
feat(compliance): Add CIS 1.8 framework for Kubernetes (#3600)
pedrooot Mar 26, 2024
fd572fb
fix(kubernetes): fix cis output for kubernetes
pedrooot Mar 27, 2024
812e27d
feat(compliance): add cis_1.8 for kubernetes
pedrooot Mar 27, 2024
5b68457
chore(report): improve shown report in UI (#3587)
sergargar Mar 27, 2024
55fd26b
feat(code): refactor code
pedrooot Mar 27, 2024
b75038f
feat(compliance): refactor code for k8s
pedrooot Mar 27, 2024
ffee16e
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Mar 27, 2024
482e152
feat(dashboard): improve ens compliance
pedrooot Mar 27, 2024
023212f
feat(ens): fix ens table format
pedrooot Apr 1, 2024
57a503c
feat(graph): modify graph still wip
pedrooot Apr 1, 2024
b88076b
feat(dashboards): change colors on dashboards still WIP
pedrooot Apr 2, 2024
de0636b
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Apr 2, 2024
0f6d670
solve poetry.lock
sergargar Apr 2, 2024
70ee034
fix(overview): handle cases for multiple versions
pedrooot Apr 2, 2024
9027f85
fix(overview): handle v3 azure csv outputs
pedrooot Apr 2, 2024
1b01666
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Apr 2, 2024
ce4ec9a
Merge branch 'prowler-4.0-dev' into prowler-dashboards
sergargar Apr 2, 2024
332033a
fix banner
sergargar Apr 2, 2024
8e6f4c2
fix(dashboard): handle regions for compliance
pedrooot Apr 2, 2024
025c3ba
feat(dashboards): handle cis for azure
pedrooot Apr 2, 2024
a1da948
fix(overview): delete duplications for azure
pedrooot Apr 2, 2024
308711e
feat(compliance): fix compliance names for cis
pedrooot Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
__pycache__
venv/
build/
dist/
/dist/
*.egg-info/
*/__pycache__/*.pyc

# Session
Session.vim
Expand Down Expand Up @@ -51,3 +52,6 @@ junit-reports/
.coverage*
.coverage
coverage*

# Node
node_modules
172 changes: 172 additions & 0 deletions dashboard/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Importing Packages
import sys
import warnings

import click
import dash
import dash_bootstrap_components as dbc
from colorama import Fore, Style
from dash import dcc, html
from dash.dependencies import Input, Output

from dashboard.config import folder_path_overview
from prowler.config.config import orange_color
from prowler.lib.banner import print_banner

warnings.filterwarnings("ignore")

cli = sys.modules["flask.cli"]
print_banner(verbose=False)
print(
f"{Fore.GREEN}Loading all CSV files from the folder {folder_path_overview} ...\n{Style.RESET_ALL}"
)
cli.show_server_banner = lambda *x: click.echo(
f"{Fore.YELLOW}NOTE:{Style.RESET_ALL} If you are a {Fore.GREEN}{Style.BRIGHT}Prowler SaaS{Style.RESET_ALL} customer and you want to use your data from your S3 bucket,\nrun: `{orange_color}aws s3 cp s3://<your-bucket>/output/csv ./output --recursive{Style.RESET_ALL}`\nand then run `prowler dashboard` again to load the new files."
)

# Initialize the app - incorporate css
dashboard = dash.Dash(
__name__,
external_stylesheets=[dbc.themes.DARKLY],
use_pages=True,
suppress_callback_exceptions=True,
title="Prowler Dashboard",
)

# Logo
prowler_logo = html.Img(
src="https://prowler.com/logo-dashboard.png", alt="Prowler Logo"
)

menu_icons = {
"overview": "/assets/images/icons/overview.svg",
"compliance": "/assets/images/icons/compliance.svg",
}


# Function to generate navigation links
def generate_nav_links(current_path):
nav_links = []
for page in dash.page_registry.values():
# Gets the icon URL based on the page name
icon_url = menu_icons.get(page["name"].lower())
is_active = (
" bg-prowler-stone-950 border-r-4 border-solid border-prowler-lime"
if current_path == page["relative_path"]
else ""
)
link_class = f"block hover:bg-prowler-stone-950 hover:border-r-4 hover:border-solid hover:border-prowler-lime{is_active}"

link_content = html.Span(
[
html.Img(src=icon_url, className="w-5"),
html.Span(page["name"], className="font-medium text-base leading-6"),
],
className="flex justify-center lg:justify-normal items-center gap-x-3 py-2 px-3",
)

nav_link = html.Li(
dcc.Link(link_content, href=page["relative_path"], className=link_class)
)
nav_links.append(nav_link)
return nav_links


def generate_help_menu():
help_links = [
{
"title": "Help",
"url": "https://github.com/prowler-cloud/prowler/issues",
"icon": "/assets/images/icons/help.png",
},
{
"title": "Docs",
"url": "https://docs.prowler.com",
"icon": "/assets/images/icons/docs.png",
},
]

link_class = "block hover:bg-prowler-stone-950 hover:border-r-4 hover:border-solid hover:border-prowler-lime"

menu_items = []
for link in help_links:
menu_item = html.Li(
html.A(
html.Span(
[
html.Img(src=link["icon"], className="w-5"),
html.Span(
link["title"], className="font-medium text-base leading-6"
),
],
className="flex items-center gap-x-3 py-2 px-3",
),
href=link["url"],
target="_blank",
className=link_class,
)
)
menu_items.append(menu_item)

return menu_items


# Layout
dashboard.layout = html.Div(
[
dcc.Location(id="url", refresh=False),
html.Link(rel="icon", href="assets/favicon.ico"),
# Placeholder for dynamic navigation bar
html.Div(
[
html.Div(id="navigation-bar", className="bg-prowler-stone-900"),
html.Div(
[
dash.page_container,
],
id="content_select",
className="bg-prowler-white w-full col-span-11 h-screen mx-auto overflow-y-scroll no-scrollbar px-10 py-7",
),
],
className="grid custom-grid 2xl:custom-grid-large h-screen",
),
],
className="h-screen mx-auto",
)


# Callback to update navigation bar
@dashboard.callback(Output("navigation-bar", "children"), [Input("url", "pathname")])
def update_nav_bar(pathname):
return html.Div(
[
html.Div([prowler_logo], className="mb-8 px-3"),
html.H6(
"Dashboards",
className="px-3 text-prowler-stone-500 text-sm opacity-90 font-regular mb-2",
),
html.Nav(
[html.Ul(generate_nav_links(pathname), className="")],
className="flex flex-col gap-y-6",
),
html.A(
[
html.Span(
[
html.Img(src="assets/favicon.ico", className="w-5"),
"Subscribe to prowler SaaS",
],
className="flex items-center gap-x-3",
),
],
href="https://prowler.com/",
target="_blank",
className="block mt-300 px-3 py-3 uppercase text-xs hover:bg-prowler-stone-950 hover:border-r-4 hover:border-solid hover:border-prowler-lime",
),
html.Nav(
[html.Ul(generate_help_menu(), className="")],
className="flex flex-col gap-y-6 mt-auto",
),
],
className="flex flex-col bg-prowler-stone-900 py-7 h-full",
)
Binary file added dashboard/assets/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions dashboard/assets/images/icons/compliance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/assets/images/icons/docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/assets/images/icons/help-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/assets/images/icons/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions dashboard/assets/images/icons/overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading