Skip to content

Commit b4893a8

Browse files
authored
Merge pull request #27 from mbrg/feature/add_resource_type_filter_for_env
add resource type filter per env
2 parents a993790 + 0befc86 commit b4893a8

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

src/powerpwn/powerdump/gui/gui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from powerpwn.cli.const import LOGGER_NAME
99
from powerpwn.powerdump.gui.prep import (
10+
env_resources_table_by_resource_type_wrapper,
1011
env_resources_table_wrapper,
1112
flt_connection_table_wrapper,
1213
flt_resource_wrapper,
@@ -29,6 +30,7 @@ def run(self, cache_path: str) -> None:
2930
register_specs(app=app, cache_path=cache_path)
3031
app.route("/")(full_resources_table_wrapper(cache_path=cache_path))
3132
app.route("/env/<env_id>")(env_resources_table_wrapper(cache_path=cache_path))
33+
app.route("/env/<env_id>/<resource_type>")(env_resources_table_by_resource_type_wrapper(cache_path=cache_path))
3234
app.route("/credentials")(full_connection_table_wrapper(cache_path=cache_path))
3335
app.route("/automation")(full_logic_flows_table_wrapper(cache_path=cache_path))
3436
app.route("/app/")(full_canvasapps_table_wrapper(cache_path))

src/powerpwn/powerdump/gui/prep.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,29 @@ def full_resources_table():
5454
def env_resources_table_wrapper(cache_path: str):
5555
def env_resources_table(env_id: str):
5656
resources = list(load_resources(cache_path=cache_path, env_id=env_id))
57-
58-
return render_template("resources_table.html", title=f"{TOOL_NAME} - environment {env_id}", resources=resources)
57+
title = f"{TOOL_NAME} - environment {env_id}"
58+
return render_template("resources_table.html", title=title, resources=resources)
5959

6060
return env_resources_table
6161

6262

63+
def env_resources_table_by_resource_type_wrapper(cache_path: str):
64+
def env_per_resource_type_table(env_id: str, resource_type: str):
65+
if resource_type == "app":
66+
resources = load_canvasapps(cache_path, env_id)
67+
elif resource_type == "credentials":
68+
resources = load_connections(cache_path, env_id, with_logic_flows=False)
69+
elif resource_type == "automation":
70+
resources = load_logic_flows(cache_path, env_id)
71+
elif resource_type == "connector":
72+
resources = load_connectors(cache_path, env_id)
73+
title = f"{TOOL_NAME} - environment {env_id} - {resource_type}"
74+
75+
return render_template("resources_table.html", title=title, resources=resources)
76+
77+
return env_per_resource_type_table
78+
79+
6380
def full_connection_table_wrapper(cache_path: str):
6481
def full_connection_table():
6582
connections = list(load_connections(cache_path=cache_path, with_logic_flows=False))
@@ -108,7 +125,7 @@ def full_connector_table():
108125
def flt_resource_wrapper(cache_path: str):
109126
def get_resource_page(resource_type: str, env_id: str, resource_id: str):
110127
resource: Optional[ResourceEntityBase] = None
111-
if resource_type == "app":
128+
if resource_type in ("app", "canvas_app"):
112129
resource = get_canvasapp(cache_path, env_id, resource_id)
113130
elif resource_type in ("credentials", "automation", "connection"):
114131
resource = get_connection(cache_path, env_id, resource_id)

src/powerpwn/powerdump/gui/templates/canvasapps_table.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<table id="data" class="table table-striped">
55
<thead>
66
<tr>
7-
<th>Display name</th>
7+
<th>App</th>
88
<th>Environment </th>
99
<th>Version</th>
1010
<th>Created by</th>
@@ -16,7 +16,7 @@
1616
{% for canvasapp in resources %}
1717
<tr>
1818
<td>{{ canvasapp.display_name }}</td>
19-
<td>{{ canvasapp.environment_id }}</td>
19+
<td><a href="/env/{{ canvasapp.environment_id }}/app">{{ canvasapp.environment_id }}</a> </td>
2020
<td>{{ canvasapp.version }}</td>
2121
<td>{{ canvasapp.created_by.email }}</td>
2222
<td>{{ canvasapp.created_at }}</td>

src/powerpwn/powerdump/gui/templates/connections_table.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<td><img src="{{ connection.icon_uri }}" class="img-thumbnail" alt="{{ connection.connection_id }}" width="25"></td>
2222
<td><a href="/credentials/{{ connection.connector_id }}">{{ connection.connector_id }}</a></td>
2323
<td>{{ connection.display_name }}</td>
24-
<td>{{ connection.environment_id }}</td>
24+
<td><a href="/env/{{ connection.environment_id }}/credentials">{{ connection.environment_id }}</a> </td>
2525
<td>{{ connection.is_valid }}</td>
2626
<td>{{ connection.last_modified_at }}</td>
2727
<td>{{ connection.expiration_time }}</td>

src/powerpwn/powerdump/gui/templates/connectors_table.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<table id="data" class="table table-striped">
55
<thead>
66
<tr>
7-
<th>Display name</th>
7+
<th>Connector</th>
8+
<th>Environment</th>
89
<th>Version</th>
910
<th>Created by</th>
1011
<th>Created at </th>
@@ -15,6 +16,7 @@
1516
{% for connector in resources %}
1617
<tr>
1718
<td>{{ connector.display_name }}</td>
19+
<td><a href="/env/{{ connector.environment_id }}/{{connector.entity_type}}">{{ connector.environment_id }}</a> </td>
1820
<td>{{ connector.version }}</td>
1921
<td>{{ connector.created_by }}</td>
2022
<td>{{ connector.created_at }}</td>

src/powerpwn/powerdump/gui/templates/logic_flows_table.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
</tr>
1414
</thead>
1515
<tbody>
16-
{% for connection in resources %}
16+
{% for automation in resources %}
1717
<tr>
18-
<td><img src="{{ connection.icon_uri }}" class="img-thumbnail" alt="{{ connection.connection_id }}" width="25"></td>
19-
<td>{{ connection.display_name }}</td>
20-
<td>{{ connection.environment_id }}</td>
21-
<td>{{ connection.created_at }}</td>
22-
<td>{{ connection.created_by.email }}</td>
23-
<td>{{ connection.last_modified_at }}</td>
24-
<td><a href="/api/{{ connection.connector_id }}/{{ connection.connection_id }}">Playground</a></td>
25-
<td><a href="/env/{{ connection.environment_id }}/automation/{{ connection.entity_id }}">Raw</a> </td>
18+
<td><img src="{{ automation.icon_uri }}" class="img-thumbnail" alt="{{ automation.connection_id }}" width="25"></td>
19+
<td>{{ automation.display_name }}</td>
20+
<td><a href="/env/{{ automation.environment_id }}/automation">{{ automation.environment_id }}</a> </td>
21+
<td>{{ automation.created_at }}</td>
22+
<td>{{ automation.created_by.email }}</td>
23+
<td>{{ automation.last_modified_at }}</td>
24+
<td><a href="/api/{{ automation.connector_id }}/{{ automation.connection_id }}">Playground</a></td>
25+
<td><a href="/env/{{ automation.environment_id }}/automation/{{ automation.entity_id }}">Raw</a> </td>
2626
</tr>
2727
{% endfor %}
2828
</tbody>

0 commit comments

Comments
 (0)