MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / rate_limited

Function rate_limited

IntelOSINT.py:2158–2168  ·  view source on GitHub ↗
(scope, limit=20, window=60)

Source from the content-addressed store, hash-verified

2156
2157
2158def rate_limited(scope, limit=20, window=60):
2159 now = time.time()
2160 key = f"{scope}:{client_ip()}"
2161 with RATE_LIMIT_LOCK:
2162 bucket = [ts for ts in RATE_LIMIT_BUCKETS.get(key, []) if now - ts < window]
2163 if len(bucket) >= limit:
2164 RATE_LIMIT_BUCKETS[key] = bucket
2165 return True
2166 bucket.append(now)
2167 RATE_LIMIT_BUCKETS[key] = bucket
2168 return False
2169
2170
2171def require_sensitive_request(scope, limit=20, window=60):

Callers 2

Calls 1

client_ipFunction · 0.85

Tested by

no test coverage detected