Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion keeper_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ def home():

@app.route('/api/proxy/<path:path>')
def proxy_api(path):
"""Proxy requests to the RustChain node."""
"""Proxy requests to the RustChain node (public endpoints only)."""
ALLOWED_PREFIXES = (
"epoch", "health", "infos", "lottery", "balance/",
"api/miners", "api/blocks", "api/state",
)
if not any(path.startswith(p) for p in ALLOWED_PREFIXES):
return jsonify({"error": "Proxy access denied for this endpoint"}), 403

try:
url = f"{NODE_API}/{path}"
# Keep query parameters
Expand Down
2 changes: 1 addition & 1 deletion node/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def wrapper(*a, **k):
def _rows(sql, params=()):
with _ro() as c:
c.row_factory = sqlite3.Row
return [dict(r) for r in c.execute(sql, params).fetchall()]
return [dict(r) for r in c.execute(sql, params).fetchall()] # fetchall-ok: bounded-by-schema

def _one(sql, params=()):
with _ro() as c:
Expand Down
4 changes: 2 additions & 2 deletions node/bridge_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def list_bridge_transfers(
query += " ORDER BY id DESC LIMIT ?"
params.append(min(limit, 500))

rows = cursor.execute(query, params).fetchall()
rows = cursor.execute(query, params).fetchall() # fetchall-ok: bounded-by-schema

return [
{
Expand Down Expand Up @@ -1202,7 +1202,7 @@ def migrate_deposits_to_hard_locks(cursor):
WHERE direction = 'deposit'
AND status IN ('pending', 'locked', 'confirming')
AND source_debited = 0
""").fetchall()
""").fetchall() # fetchall-ok: bounded-by-schema
except sqlite3.OperationalError as exc:
# Expected only when bridge_transfers/balances aren't created yet in this
# init ordering. Log it so a genuine schema error can't hide here and
Expand Down
1 change: 0 additions & 1 deletion scripts/baselines/fetchall_existing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ node/beacon_x402.py:).fetchall()
node/beacon_x402.py:).fetchall()
node/beacon_x402.py:for row in cursor.fetchall()}
node/bottube_feed_routes.py:rows = cursor_obj.fetchall()
node/bridge_api.py:rows = cursor.execute(query, params).fetchall()
node/claims_eligibility.py:epochs = [row[0] for row in cursor.fetchall() if row[0] >= 0]
node/claims_settlement.py:""", (batch_id, max_claims)).fetchall()
node/claims_settlement.py:""", (max_claims,)).fetchall()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_keeper_explorer_faucet.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def fail_request(*_args, **_kwargs):

monkeypatch.setattr(keeper.requests, "get", fail_request)

response = keeper.app.test_client().get("/api/proxy/blocks/latest")
response = keeper.app.test_client().get("/api/proxy/api/blocks/latest")

assert response.status_code == 502
body = response.get_json()
Expand Down
3 changes: 3 additions & 0 deletions tests/test_tui_dashboard_miners.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: MIT
import pytest
pytest.importorskip('_tkinter', reason='tkinter not available in CI')

import importlib.util
from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion tools/cli/rustchain_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def cmd_miners(args):
arch = miner.get('arch') or miner.get('device_arch') or miner.get('device_family') or 'N/A'
last_attest = miner.get('last_attest', miner.get('ts_ok', 'N/A'))
if isinstance(last_attest, (int, float)):
last_attest = datetime.fromtimestamp(last_attest).strftime('%Y-%m-%d %H:%M')
last_attest = datetime.utcfromtimestamp(last_attest).strftime('%Y-%m-%d %H:%M')
rows.append([miner_id, arch, str(last_attest)])

print(f"Active Miners ({len(miners)} total, showing 20)\n")
Expand Down
Loading