MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _set_toml_value_fallback

Function _set_toml_value_fallback

webapp_modern.py:10677–10691  ·  view source on GitHub ↗

Fallback: use sub-python to update a TOML value when tomlkit is unavailable here. Passes key and value as separate argv parameters and JSON-encodes the value. No exec, no string-built code — so a malicious key or value can never reach the Python parser as code.

(dotted_key, value)

Source from the content-addressed store, hash-verified

10675# → next attempts rejected for _AUTH_LOCKOUT_WINDOW seconds.
10676# Memory only: resets on process restart. Sufficient on a single-Pi deployment.
10677_AUTH_LOCKOUT_THRESHOLD = 5
10678_AUTH_LOCKOUT_WINDOW = 60
10679_auth_attempts = {} # ip -> list[timestamp] of failed attempts
10680_auth_attempts_lock = threading.Lock()
10681
10682
10683def _auth_client_ip():
10684 # Trust X-Forwarded-For only if explicitly configured; otherwise use remote_addr.
10685 return request.headers.get('X-Real-IP') or request.remote_addr or 'unknown'
10686
10687
10688def _auth_rate_limited(ip):
10689 now = time.time()
10690 with _auth_attempts_lock:
10691 attempts = [t for t in _auth_attempts.get(ip, []) if now - t < _AUTH_LOCKOUT_WINDOW]
10692 _auth_attempts[ip] = attempts
10693 if len(attempts) >= _AUTH_LOCKOUT_THRESHOLD:
10694 retry_after = int(_AUTH_LOCKOUT_WINDOW - (now - attempts[0])) + 1

Callers 1

save_pwnagotchi_configFunction · 0.85

Calls 2

errorMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected