SeaWolf-AI commited on
Commit
fccc0d5
·
verified ·
1 Parent(s): 1febdcf

Audit view: hide call arguments from other players

Browse files
Files changed (2) hide show
  1. live_apps.js +1 -1
  2. server.py +15 -0
live_apps.js CHANGED
@@ -607,7 +607,7 @@ async function verifyLines(lines) {
607
  const chain = m.get('chain'), prev = m.get('prev'), seq = m.get('seq');
608
  m.delete('chain');
609
  const want = await sha256hex((prev ?? '') + canon(m));
610
- if (want !== chain) errs.push({k, seq:seq && seq.__num, msg:'hash mismatch'});
611
  if (prevChain != null && prev !== prevChain) errs.push({k, seq:seq && seq.__num, msg:'prev does not link to previous chain'});
612
  prevChain = chain;
613
  }
 
607
  const chain = m.get('chain'), prev = m.get('prev'), seq = m.get('seq');
608
  m.delete('chain');
609
  const want = await sha256hex((prev ?? '') + canon(m));
610
+ if (!m.get('args_hidden') && want !== chain) errs.push({k, seq:seq && seq.__num, msg:'hash mismatch'});
611
  if (prevChain != null && prev !== prevChain) errs.push({k, seq:seq && seq.__num, msg:'prev does not link to previous chain'});
612
  prevChain = chain;
613
  }
server.py CHANGED
@@ -84,6 +84,21 @@ class H(SimpleHTTPRequestHandler):
84
  return
85
  if not data.lstrip().startswith(b"{"):
86
  return self._json(503, {"error": "backend starting"})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  self.send_response(code); self.send_header("Content-Type", "application/json")
88
  self.send_header("Content-Length", str(len(data))); self.send_header("Cache-Control", "no-store"); self.end_headers(); self.wfile.write(data)
89
  except urllib.error.HTTPError as e:
 
84
  return
85
  if not data.lstrip().startswith(b"{"):
86
  return self._json(503, {"error": "backend starting"})
87
+ if name == "audit" and code == 200 and u.lower() not in RC.EXCLUDE:
88
+ # Call arguments in the shared audit chain belong to the player who made the call. Other players must not read them.
89
+ try:
90
+ j = json.loads(data); out = []
91
+ for ln in j.get("lines") or []:
92
+ try:
93
+ o = json.loads(ln) if isinstance(ln, str) else dict(ln)
94
+ o["args"] = "[hidden during the hackathon]"; o["args_hidden"] = True
95
+ out.append(json.dumps(o, ensure_ascii=False) if isinstance(ln, str) else o)
96
+ except Exception: # noqa: BLE001
97
+ continue # a record that cannot be parsed is not passed on
98
+ j["lines"] = out; j["redacted"] = True
99
+ data = json.dumps(j, ensure_ascii=False).encode()
100
+ except Exception: # noqa: BLE001
101
+ return self._json(503, {"error": "audit view unavailable"})
102
  self.send_response(code); self.send_header("Content-Type", "application/json")
103
  self.send_header("Content-Length", str(len(data))); self.send_header("Cache-Control", "no-store"); self.end_headers(); self.wfile.write(data)
104
  except urllib.error.HTTPError as e: