Skip to content

Commit

Permalink
Merge pull request #27 from mbrg/feature/add_resource_type_filter_for…
Browse files Browse the repository at this point in the history
…_env

add resource type filter per env
  • Loading branch information
lanasalameh1 authored Mar 26, 2024
2 parents 9b42199 + 3a97e80 commit a4440a3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/powerpwn/powerdump/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from powerpwn.cli.const import LOGGER_NAME
from powerpwn.powerdump.gui.prep import (
env_resources_table_by_resource_type_wrapper,
env_resources_table_wrapper,
flt_connection_table_wrapper,
flt_resource_wrapper,
Expand All @@ -29,6 +30,7 @@ def run(self, cache_path: str) -> None:
register_specs(app=app, cache_path=cache_path)
app.route("/")(full_resources_table_wrapper(cache_path=cache_path))
app.route("/env/<env_id>")(env_resources_table_wrapper(cache_path=cache_path))
app.route("/env/<env_id>/<resource_type>")(env_resources_table_by_resource_type_wrapper(cache_path=cache_path))
app.route("/credentials")(full_connection_table_wrapper(cache_path=cache_path))
app.route("/automation")(full_logic_flows_table_wrapper(cache_path=cache_path))
app.route("/app/")(full_canvasapps_table_wrapper(cache_path))
Expand Down
23 changes: 20 additions & 3 deletions src/powerpwn/powerdump/gui/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,29 @@ def full_resources_table():
def env_resources_table_wrapper(cache_path: str):
def env_resources_table(env_id: str):
resources = list(load_resources(cache_path=cache_path, env_id=env_id))

return render_template("resources_table.html", title=f"{TOOL_NAME} - environment {env_id}", resources=resources)
title = f"{TOOL_NAME} - environment {env_id}"
return render_template("resources_table.html", title=title, resources=resources)

return env_resources_table


def env_resources_table_by_resource_type_wrapper(cache_path: str):
def env_per_resource_type_table(env_id: str, resource_type: str):
if resource_type == "app":
resources = load_canvasapps(cache_path, env_id)
elif resource_type == "credentials":
resources = load_connections(cache_path, env_id, with_logic_flows=False)
elif resource_type == "automation":
resources = load_logic_flows(cache_path, env_id)
elif resource_type == "connector":
resources = load_connectors(cache_path, env_id)
title = f"{TOOL_NAME} - environment {env_id} - {resource_type}"

return render_template("resources_table.html", title=title, resources=resources)

return env_per_resource_type_table


def full_connection_table_wrapper(cache_path: str):
def full_connection_table():
connections = list(load_connections(cache_path=cache_path, with_logic_flows=False))
Expand Down Expand Up @@ -108,7 +125,7 @@ def full_connector_table():
def flt_resource_wrapper(cache_path: str):
def get_resource_page(resource_type: str, env_id: str, resource_id: str):
resource: Optional[ResourceEntityBase] = None
if resource_type == "app":
if resource_type in ("app", "canvas_app"):
resource = get_canvasapp(cache_path, env_id, resource_id)
elif resource_type in ("credentials", "automation", "connection"):
resource = get_connection(cache_path, env_id, resource_id)
Expand Down
4 changes: 2 additions & 2 deletions src/powerpwn/powerdump/gui/templates/canvasapps_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<table id="data" class="table table-striped">
<thead>
<tr>
<th>Display name</th>
<th>App</th>
<th>Environment </th>
<th>Version</th>
<th>Created by</th>
Expand All @@ -16,7 +16,7 @@
{% for canvasapp in resources %}
<tr>
<td>{{ canvasapp.display_name }}</td>
<td>{{ canvasapp.environment_id }}</td>
<td><a href="/env/{{ canvasapp.environment_id }}/app">{{ canvasapp.environment_id }}</a> </td>
<td>{{ canvasapp.version }}</td>
<td>{{ canvasapp.created_by.email }}</td>
<td>{{ canvasapp.created_at }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<td><img src="{{ connection.icon_uri }}" class="img-thumbnail" alt="{{ connection.connection_id }}" width="25"></td>
<td><a href="/credentials/{{ connection.connector_id }}">{{ connection.connector_id }}</a></td>
<td>{{ connection.display_name }}</td>
<td>{{ connection.environment_id }}</td>
<td><a href="/env/{{ connection.environment_id }}/credentials">{{ connection.environment_id }}</a> </td>
<td>{{ connection.is_valid }}</td>
<td>{{ connection.last_modified_at }}</td>
<td>{{ connection.expiration_time }}</td>
Expand Down
4 changes: 3 additions & 1 deletion src/powerpwn/powerdump/gui/templates/connectors_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<table id="data" class="table table-striped">
<thead>
<tr>
<th>Display name</th>
<th>Connector</th>
<th>Environment</th>
<th>Version</th>
<th>Created by</th>
<th>Created at </th>
Expand All @@ -15,6 +16,7 @@
{% for connector in resources %}
<tr>
<td>{{ connector.display_name }}</td>
<td><a href="/env/{{ connector.environment_id }}/{{connector.entity_type}}">{{ connector.environment_id }}</a> </td>
<td>{{ connector.version }}</td>
<td>{{ connector.created_by }}</td>
<td>{{ connector.created_at }}</td>
Expand Down
18 changes: 9 additions & 9 deletions src/powerpwn/powerdump/gui/templates/logic_flows_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
</tr>
</thead>
<tbody>
{% for connection in resources %}
{% for automation in resources %}
<tr>
<td><img src="{{ connection.icon_uri }}" class="img-thumbnail" alt="{{ connection.connection_id }}" width="25"></td>
<td>{{ connection.display_name }}</td>
<td>{{ connection.environment_id }}</td>
<td>{{ connection.created_at }}</td>
<td>{{ connection.created_by.email }}</td>
<td>{{ connection.last_modified_at }}</td>
<td><a href="/api/{{ connection.connector_id }}/{{ connection.connection_id }}">Playground</a></td>
<td><a href="/env/{{ connection.environment_id }}/automation/{{ connection.entity_id }}">Raw</a> </td>
<td><img src="{{ automation.icon_uri }}" class="img-thumbnail" alt="{{ automation.connection_id }}" width="25"></td>
<td>{{ automation.display_name }}</td>
<td><a href="/env/{{ automation.environment_id }}/automation">{{ automation.environment_id }}</a> </td>
<td>{{ automation.created_at }}</td>
<td>{{ automation.created_by.email }}</td>
<td>{{ automation.last_modified_at }}</td>
<td><a href="/api/{{ automation.connector_id }}/{{ automation.connection_id }}">Playground</a></td>
<td><a href="/env/{{ automation.environment_id }}/automation/{{ automation.entity_id }}">Raw</a> </td>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit a4440a3

Please sign in to comment.