AnonymousSpottedToad/securityPatternsRecovery / ground_truth /python /limit_request_rate__shangyankeji_super-dev.json
| { | |
| "role_mappings": [ | |
| { | |
| "patternRole": "Entity", | |
| "entity": "", | |
| "file": "", | |
| "lines": "", | |
| "notes": "Callers of the FastAPI app in super_dev/web/api.py are external HTTP clients; no in-repo UI/SDK calling /api/* routes was found (searched JS/TS/HTML files; only tests hit the API).", | |
| "status": "missing", | |
| "nodeId": null | |
| }, | |
| { | |
| "patternRole": "Enforcer", | |
| "entity": "__call__", | |
| "file": "super_dev/web/rate_limit.py", | |
| "lines": "51", | |
| "notes": "ASGI __call__ of RateLimitMiddleware, registered via app.add_middleware(RateLimitMiddleware) at super_dev/web/api.py:373; it derives the client IP via _client_ip (rate_limit.py:30) and returns 429 with Retry-After or forwards to self.app. The rate decision is inline here, so it is also the Limiter.", | |
| "status": "present", | |
| "nodeId": null | |
| }, | |
| { | |
| "patternRole": "Limiter", | |
| "entity": "__call__", | |
| "file": "super_dev/web/rate_limit.py", | |
| "lines": "51", | |
| "notes": "Same method as the Enforcer (tie-break rule 2): __call__ prunes the per-IP deque to the window and blocks when len(dq) >= max_requests (rate_limit.py:68), else appends the timestamp (line 88). No smaller helper makes the decision; _cleanup (line 40) only prunes old entries.", | |
| "status": "present", | |
| "nodeId": null | |
| }, | |
| { | |
| "patternRole": "HistoryProvider", | |
| "entity": "_hits", | |
| "file": "super_dev/web/rate_limit.py", | |
| "lines": "26", | |
| "notes": "In-memory dict of client_ip -> deque of request timestamps in RateLimitMiddleware, read and updated directly by the Limiter __call__ (rate_limit.py:62, 88); no retrieval method exists, so the field is cited. _cleanup (line 40) prunes it. Per-process, non-persistent.", | |
| "status": "present", | |
| "nodeId": null | |
| }, | |
| { | |
| "patternRole": "PolicyProvider", | |
| "entity": "__init__", | |
| "file": "super_dev/web/rate_limit.py", | |
| "lines": "19", | |
| "notes": "RateLimitMiddleware.__init__ loads the policy from env vars SUPER_DEV_RATE_LIMIT (default 100) and SUPER_DEV_RATE_WINDOW (default 60s) into self.max_requests/self.window, which the Limiter __call__ uses at rate_limit.py:64 and 68. Single global policy for all IPs.", | |
| "status": "present", | |
| "nodeId": null | |
| }, | |
| { | |
| "patternRole": "System", | |
| "entity": "run_workflow", | |
| "file": "super_dev/web/api.py", | |
| "lines": "1968", | |
| "notes": "Representative FastAPI route handler (POST /api/workflow/run) reached when the Enforcer __call__ forwards via await self.app(...) at rate_limit.py:89; the middleware covers every route of the app in super_dev/web/api.py.", | |
| "status": "present", | |
| "nodeId": null | |
| } | |
| ], | |
| "interaction_order": { | |
| "available": true, | |
| "language": "python", | |
| "repo": "shangyankeji_super-dev", | |
| "reason": "", | |
| "entryRole": "Enforcer", | |
| "entryRule": "behaviour", | |
| "interactions": [ | |
| { | |
| "rank": 1, | |
| "interaction": "Enforcer \u2192 Limiter", | |
| "from": "Enforcer", | |
| "to": "Limiter", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 51, | |
| "via": [], | |
| "mechanism": "co-located", | |
| "path": [], | |
| "parent": "" | |
| }, | |
| { | |
| "rank": 2, | |
| "interaction": "Enforcer \u2192 HistoryProvider", | |
| "from": "Enforcer", | |
| "to": "HistoryProvider", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 43, | |
| "via": [ | |
| "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup" | |
| ], | |
| "mechanism": "data", | |
| "path": [ | |
| { | |
| "caller": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware.__call__", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 60, | |
| "code": "self._cleanup(ip, now)", | |
| "callee": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup", | |
| "mechanism": "call" | |
| }, | |
| { | |
| "caller": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 43, | |
| "code": "", | |
| "callee": "_hits", | |
| "mechanism": "data" | |
| } | |
| ], | |
| "parent": "" | |
| }, | |
| { | |
| "rank": 3, | |
| "interaction": "Limiter \u2192 HistoryProvider", | |
| "from": "Limiter", | |
| "to": "HistoryProvider", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 43, | |
| "via": [ | |
| "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup" | |
| ], | |
| "mechanism": "data", | |
| "path": [ | |
| { | |
| "caller": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware.__call__", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 60, | |
| "code": "self._cleanup(ip, now)", | |
| "callee": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup", | |
| "mechanism": "call" | |
| }, | |
| { | |
| "caller": "super_dev/web/rate_limit.py:<module>.RateLimitMiddleware._cleanup", | |
| "file": "super_dev/web/rate_limit.py", | |
| "line": 43, | |
| "code": "", | |
| "callee": "_hits", | |
| "mechanism": "data" | |
| } | |
| ], | |
| "parent": "" | |
| } | |
| ], | |
| "anchoredRoles": [ | |
| { | |
| "role": "Enforcer", | |
| "kind": "METHOD" | |
| }, | |
| { | |
| "role": "HistoryProvider", | |
| "kind": "MEMBER" | |
| }, | |
| { | |
| "role": "Limiter", | |
| "kind": "METHOD" | |
| }, | |
| { | |
| "role": "PolicyProvider", | |
| "kind": "METHOD" | |
| } | |
| ], | |
| "skippedRoles": [ | |
| "Entity", | |
| "System" | |
| ] | |
| } | |
| } |
Xet Storage Details
- Size:
- 5.73 kB
- Xet hash:
- 4b2dacf8a72f06e4ef0b5092ea7d585f70b4fae64f008db3cdca6f21c643c1ba
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.