diff options
| author | Bitflash <admin@bitflash.network> | 2026-08-07 15:07:56 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-07 15:07:56 -0300 |
| commit | 78cf0c3cb6752bd36bbc8fe7017d5d60cca13da7 (patch) | |
| tree | 7935ac82f4d46bb0f2652c6970d516bae9d57eb0 /scripts/build-pool-index.py | |
| parent | a0355492c3bae37ad57ef3e05302a3e5b1a80e3e (diff) | |
tools: reject non-http(s) dashboard URLs in the pool directory
A pool's dashboard URL comes from its self-published status file. Escaping
it for HTML is not enough: a javascript: or data: scheme would still render
as a clickable script-injection on the public directory page. Only emit a
link for http(s) schemes; anything else shows as no link.
Diffstat (limited to 'scripts/build-pool-index.py')
| -rw-r--r-- | scripts/build-pool-index.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/build-pool-index.py b/scripts/build-pool-index.py index 40eb8f4..382b6c3 100644 --- a/scripts/build-pool-index.py +++ b/scripts/build-pool-index.py | |||
| @@ -56,10 +56,15 @@ def render_html(pools, generated_at): | |||
| 56 | rows = [] | 56 | rows = [] |
| 57 | for p in pools: | 57 | for p in pools: |
| 58 | dash = p["dashboardUrl"] | 58 | dash = p["dashboardUrl"] |
| 59 | dash_html = ( | 59 | # Only linkify http(s). The dashboard URL comes from an operator's |
| 60 | '<a href="{0}">dashboard</a>'.format(html.escape(dash, quote=True)) | 60 | # self-published status file, so a "javascript:" or "data:" scheme |
| 61 | if dash else "-" | 61 | # would become a clickable script-injection on this public page. |
| 62 | ) | 62 | dash_lower = dash.lower() |
| 63 | if dash_lower.startswith("http://") or dash_lower.startswith("https://"): | ||
| 64 | dash_html = '<a href="{0}" rel="noopener noreferrer">dashboard</a>'.format( | ||
| 65 | html.escape(dash, quote=True)) | ||
| 66 | else: | ||
| 67 | dash_html = "-" | ||
| 63 | rows.append( | 68 | rows.append( |
| 64 | "<tr>" | 69 | "<tr>" |
| 65 | "<td>{status}</td>" | 70 | "<td>{status}</td>" |