abuse reports in the browser: notice, visitor tips, operator form and queue

A listing page says when the node hides the listing and who flagged it. A
visitor can tip off the operator (proof-of-work, nothing is hidden by it); the
signed-in operator can sign or withdraw a report from the page and works
through the tips at #/mine/reports. e2e covers the real binaries.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-18 21:23:13 +01:00
co-authored by Claude Sonnet 5.5
parent 6d55222ac5
commit 0d5903be79
13 changed files with 873 additions and 6 deletions
+16
View File
@@ -125,6 +125,22 @@ UI=$ROOT/scripts/e2e/ui.ts
node $UI buyer http://127.0.0.1:18102 http://127.0.0.1:18101 $TOKEN $AUTHOR $ID > $W/ui-buyer.txt 2>&1 \
&& { sed 's/^OK /PASS: UI: /' $W/ui-buyer.txt; } || { cat $W/ui-buyer.txt; bad "the buyer flow through the web UI"; }
echo "== abuse reports: the operator's report hides the listing on A; B receives it but does not count a stranger's"
count() { curl -s "http://127.0.0.1:$1/api/v1/listings$2" | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))'; }
[ "$(count 18101 '')" = 1 ] && [ "$(count 18102 '')" = 1 ] && ok "both nodes list it before any report" || bad "the listing is missing before the report"
REPORT="{\"listing\":{\"author\":\"$AUTHOR\",\"id\":\"$ID\"},\"category\":\"scam\",\"note\":\"e2e\"}"
curl -s -o /dev/null -w "%{http_code}" -X POST -d "$REPORT" http://127.0.0.1:18101/api/v1/reports | grep -q 401 && ok "reporting needs the admin token"
curl -s -X POST -H "Authorization: Bearer $TOKEN" -d "$REPORT" http://127.0.0.1:18101/api/v1/reports \
| python3 -c 'import json,sys; s=json.load(sys.stdin); assert s["hidden"] and s["own"]=="scam", s' && ok "A signed the report and hides the listing" || bad "A did not hide it"
[ "$(count 18101 '')" = 0 ] && [ "$(count 18101 '?hidden=1')" = 1 ] && ok "A leaves it out of search; ?hidden=1 still lists it" || bad "A's search does not hide it"
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:18101/api/v1/listings/$AUTHOR/$ID | grep -q 200 && ok "its own link still works" || bad "a hidden listing is not reachable by its link"
wait_for "B received A's signed report" 20 bash -c "curl -s 'http://127.0.0.1:18102/api/v1/reports?author=$AUTHOR&id=$ID' | grep -q '\"others\":1'"
ok "B received it through the network"
[ "$(count 18102 '')" = 1 ] && ok "B does not trust A, so it still shows the listing" || bad "B hid a listing on a stranger's report"
sleep 1 # a newer report must be dated a second later
curl -s -X POST -H "Authorization: Bearer $TOKEN" -d "${REPORT/scam/withdrawn}" http://127.0.0.1:18101/api/v1/reports >/dev/null
[ "$(count 18101 '')" = 1 ] && ok "withdrawing the report shows the listing again" || bad "a withdrawn report still hides it"
echo "== recover on A (simulate a stolen machine)"
OLD_DEVICE=$(curl -s http://127.0.0.1:18101/api/v1/status | python3 -c 'import json,sys; print(json.load(sys.stdin)["device"])')
kill ${PIDS[0]}; wait ${PIDS[0]} 2>/dev/null