fix: XSS in legend innerHTML and shebang allowlist in hooks

This commit is contained in:
Safi
2026-04-08 19:53:10 +01:00
parent b64c231467
commit 1cc54b3bbf
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -365,7 +365,7 @@ def to_html(
legend_data = []
for cid in sorted((community_labels or {}).keys()):
color = COMMUNITY_COLORS[cid % len(COMMUNITY_COLORS)]
lbl = (community_labels or {}).get(cid, f"Community {cid}")
lbl = _html.escape(sanitize_label((community_labels or {}).get(cid, f"Community {cid}")))
n = len(communities.get(cid, []))
legend_data.append({"cid": cid, "color": color, "label": lbl, "count": n})
+5
View File
@@ -17,6 +17,11 @@ if [ -n "$GRAPHIFY_BIN" ]; then
*/env\\ *) GRAPHIFY_PYTHON="${_SHEBANG#*/env }" ;;
*) GRAPHIFY_PYTHON="$_SHEBANG" ;;
esac
# Allowlist: only keep characters valid in a filesystem path to prevent
# injection if the shebang contains shell metacharacters
case "$GRAPHIFY_PYTHON" in
*[!a-zA-Z0-9/_.-]*) GRAPHIFY_PYTHON="python3" ;;
esac
if ! "$GRAPHIFY_PYTHON" -c "import graphify" 2>/dev/null; then
GRAPHIFY_PYTHON="python3"
fi