consolidator
AVFL consolidator. Merges, cross-checks, deduplicates, and scores validator findings.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- security-harden-proxy
- description
- Use when building a service or sidecar that calls an authenticated upstream API (Bearer token, API key) and relays results, to prevent the credential or full URL from leaking into logs or client responses
02 资源文件 1
- 参考文档agents/openai.yaml43 B
03 SKILL.md 正文
Secret-Safe Upstream Proxy
A service that authenticates to an upstream and returns aggregated/proxied data can leak the token through exception text, error responses, or logs. Build it so the secret never escapes.
-
Keep the token in one place — read it once from the environment; never embed it in returned data, never echo the constructed URL (which may carry it as a query param) back to the client.
-
Wrap every upstream call and sever the exception chain — HTTP-client exceptions stringify to text that includes the request URL (
urllib.error.HTTPErrorholds the URL, status, and response headers;requestserrors embed the full URL). If the key rides in the URL (?api_key=…), echoingstr(exc)to the client, or callinglog.exception(...)/logging the traceback, writes the credential into responses and logs. Keep every credential-bearing object — the token, the credentialed URL, and the response/request (HTTP response objects keep the full URL and often the authenticated request) — inside a helper, and raise a clean error from a caller that holds none of them, after theexceptblock, so it carries no reference to the original exception:def _fetch(path, accept): # the only frame that holds token, url, resp token = os.environ["UPSTREAM_TOKEN"] url = f"{BASE}{path}?api_key={token}" with _get(url, accept) as resp: return parse(resp) # all response processing stays in this frame def fetch(path, accept): # no secret-bearing locals in this frame failed = False try: return _fetch(path, accept) except Exception: failed = True # keep nothing from the original exception if failed: raise RuntimeError("upstream request failed") # __context__ and __cause__ are NoneScrubbing names in the raising frame (
del url, token) is not enough on its own: a failure while processing the response leavesrespbound, and any later-added local reopens the leak. The helper boundary covers every such object at once.raise … from Noneinside theexceptis not enough: it only sets__suppress_context__, which hides the original exception from standard traceback output and from error reporters that honor suppression (Sentry,traceback), but the credentialed exception stays reachable on__context__for custom handlers, debug middleware, and error reporters that walk the exception object graph directly. A cleared chain also does not cover traceback locals: the replacement exception's__traceback__still contains this frame, and Sentry/debug middleware serialize each frame's locals — sourl,tokenandrespleak unless the raise comes from a frame that never held them (the helper above). Also turn local capture off or scrub the token in the reporter (Sentryinclude_local_variables=False, or abefore_send/EventScrubberdenylist) — a caller further up the stack that holds the token would leak it. -
Return a generic error to clients — on failure, send a fixed status + opaque message (e.g.
502 "upstream error"); never include the exception text, URL, or headers in the HTTP response body. -
Override the log formatter to log message-only — ensure the access/error logger prints just the human message, not the request line or headers, and route it to stdout for container capture.
-
Stream and cap untrusted payloads — when the upstream returns a large/unbounded body, iterate it line-by-line and abort past a byte cap rather than buffering the whole response, keeping memory bounded regardless of upstream size.
-
Keep it internal-only — bind the service to the private network/IP, never expose it through the reverse proxy, since it holds a privileged credential.
-
Add a review/test that asserts no leak — a unit test that forces an upstream failure and asserts the token string does not appear in the raised message or response, and that the raised error has
__context__ is Noneand__cause__ is None(or, walking the whole chain, that no exception in it stringifies to text containing the token) — plus a check that serializing every frame'sf_localsalongexc.__traceback__(the shape Sentry/debug middleware capture) contains no credential, e.g."".join(traceback.TracebackException.from_exception(exc, capture_locals=True).format()). Force both failures: the request itself failing, and response processing failing after a successful request (the case that leavesrespbound). Run the assertion inside a test function — module-level frames capture every global and give false positives.
04 同仓库更多 Skills
upstream-fix
Traces quality failures upstream to spec, rule, or workflow root cause. Proposes fixes at the right level.
triage
Dedup gate + batch-classify observations into five classes, enrich ARTIFACTs, batch-approve, delegate to intake/decision or queue.
sprint-planning
Sprint planning — story selection, team composition, Gherkin specs, and visual companion plan gate for developer sign-off.
sprint-manager
Sole writer of stories/index.json and sprints/index.json — validates state transitions, activates sprints, manages epic membership.
sprint-dev
Sprint execution — dependency-driven story development, post-merge AVFL, and team review.
retro
Sprint retrospective — transcript audit engine (dynamic Workflow), story verification, findings document, and sprint closure.