Skip to content

Commit df8be6e

Browse files
ci(protocol): verify upstream workflow on subtree push and fix bandit XML parsing
1 parent 234c904 commit df8be6e

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

hushh_mcp/operons/kai/fetchers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
import os
1818
import time
1919
import urllib.parse
20-
import xml.etree.ElementTree as ET
2120
from collections import Counter
2221
from datetime import datetime, timedelta
2322
from typing import Any, Dict, List
2423

2524
import httpx
25+
from defusedxml import ElementTree as DefusedET
2626

2727
from hushh_mcp.consent.token import validate_token
2828
from hushh_mcp.constants import ConsentScope
@@ -101,7 +101,11 @@ def _parse_google_news_rss(xml_text: str, ticker: str) -> List[Dict[str, Any]]:
101101
if not xml_text.strip():
102102
return []
103103

104-
root = ET.fromstring(xml_text) # noqa: S314 - Parses trusted Google News RSS payload only.
104+
try:
105+
root = DefusedET.fromstring(xml_text)
106+
except DefusedET.ParseError:
107+
logger.warning("Skipping malformed Google News RSS payload for %s", ticker)
108+
return []
105109
items: list[Dict[str, Any]] = []
106110
for item in root.findall(".//item"):
107111
title = (item.findtext("title") or "").strip()

ops/monorepo/protocol.mk

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ CONSENT_UPSTREAM_BRANCH ?= main
66
CONSENT_SUBTREE_PREFIX ?= consent-protocol
77
CONSENT_SYNC_REF ?= refs/subtree-sync/consent-protocol
88
CONSENT_MONOREPO_OPS ?= consent-protocol/ops/monorepo
9+
CONSENT_UPSTREAM_VERIFY_CI ?= 1
910

10-
.PHONY: sync-protocol check-protocol-sync push-protocol push-protocol-force setup verify-setup
11+
.PHONY: sync-protocol check-protocol-sync push-protocol push-protocol-force verify-protocol-upstream-ci setup verify-setup
1112

1213
sync-protocol: ## Pull latest consent-protocol from upstream
1314
@echo "Pulling $(CONSENT_SUBTREE_PREFIX) from upstream..."
@@ -28,14 +29,29 @@ check-protocol-sync: ## Check if consent-protocol is in sync with upstream
2829
push-protocol: check-protocol-sync ## Push consent-protocol changes to upstream (sync check first)
2930
@echo "Pushing $(CONSENT_SUBTREE_PREFIX)/ to upstream..."
3031
git subtree push --prefix=$(CONSENT_SUBTREE_PREFIX) $(CONSENT_UPSTREAM_REMOTE) $(CONSENT_UPSTREAM_BRANCH)
32+
@if [ "$(CONSENT_UPSTREAM_VERIFY_CI)" = "1" ]; then \
33+
$(MAKE) --no-print-directory verify-protocol-upstream-ci; \
34+
else \
35+
echo "Skipping upstream CI verification (CONSENT_UPSTREAM_VERIFY_CI=$(CONSENT_UPSTREAM_VERIFY_CI))."; \
36+
fi
3137
@echo "Done. Upstream consent-protocol repo is now updated."
3238

3339
push-protocol-force: ## Push consent-protocol to upstream (skip sync check)
3440
@echo "⚠ Skipping upstream sync check (force mode)..."
3541
@echo "Pushing $(CONSENT_SUBTREE_PREFIX)/ to upstream..."
3642
git subtree push --prefix=$(CONSENT_SUBTREE_PREFIX) $(CONSENT_UPSTREAM_REMOTE) $(CONSENT_UPSTREAM_BRANCH)
43+
@if [ "$(CONSENT_UPSTREAM_VERIFY_CI)" = "1" ]; then \
44+
$(MAKE) --no-print-directory verify-protocol-upstream-ci; \
45+
else \
46+
echo "Skipping upstream CI verification (CONSENT_UPSTREAM_VERIFY_CI=$(CONSENT_UPSTREAM_VERIFY_CI))."; \
47+
fi
3748
@echo "Done. Upstream consent-protocol repo is now updated."
3849

50+
verify-protocol-upstream-ci: ## Verify upstream consent-protocol CI run for current upstream HEAD
51+
@CONSENT_UPSTREAM_REPO=hushh-labs/consent-protocol \
52+
CONSENT_UPSTREAM_BRANCH=$(CONSENT_UPSTREAM_BRANCH) \
53+
bash scripts/ci/verify-protocol-upstream-ci.sh
54+
3955
setup: ## First-time setup (hooks + remote + verification)
4056
@CONSENT_UPSTREAM_REMOTE=$(CONSENT_UPSTREAM_REMOTE) \
4157
CONSENT_UPSTREAM_BRANCH=$(CONSENT_UPSTREAM_BRANCH) \

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ google-auth>=2.14.1
8888

8989
# 📈 Market Data
9090
yfinance>=0.2.36
91+
92+
# 🔒 Secure XML parsing (Bandit-safe RSS parsing)
93+
defusedxml>=0.7.1

0 commit comments

Comments
 (0)