Repository navigation
Conversation
aryanorastar
left a comment
There was a problem hiding this comment.
Reviewed 67f1ff2.
plugins/omi-whoop-app/main.py still returns the raw exception from the /tools handlers: Failed to get recovery/strain/sleep/workouts/weekly summary/measurements: {str(e)}. plugins/omi-whoop-app/test_whoop_tools_auth.py imports whoop_tools_auth and never loads main.py, so those leaks are not pinned.
Addresses review on BasedHardware#15918: the seven /tools handlers returned 'Failed to get ...: {str(e)}', exposing raw internal exception detail to callers. Replace with generic messages (full detail still goes to log()). Also fix the OAuth callback 'Authentication error: {str(e)}' the same way. Add test_whoop_tools_no_leak.py which loads main.py (hermetic stubs) and drives every tool handler with a raising whoop_api_request, asserting the returned error never contains the raw exception text.
|
Thanks for the review @aryanorastar — addressed both points in adf7239:
|
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @piyush295 — verified both points from the earlier review are addressed on adf7239: the seven /tools handlers (and the OAuth callback in whoop_callback) now return generic error strings with detail preserved in log(), and the new test_whoop_tools_no_leak.py loads main.py under hermetic stubs and drives every tool handler. whoop_tools_auth.py itself looks right: fail-closed 503 when WHOOP_TOOLS_SECRET is unset, 401 on missing/wrong token, hmac.compare_digest, and all seven routes covered via Depends. I ran the plugin's suite in a clean container with the plugin-pinned requirements (fastapi 0.104.1 / httpx 0.26) — test_whoop_tools_auth.py 5/5 and test_whoop_tools_no_leak.py pass.
Requesting changes for what that run showed — the new guard breaks three existing test files that weren't updated, plus small wiring gaps:
test_weekly_summary.pyfails 3/3 withAssertionError: 503 != 200. Its TestClient posts to/tools/get_weekly_summarywith no secret configured and noapp.dependency_overrides, so the fail-closed guard now blocks it. The behavior change is intentional; the tests need to setWHOOP_TOOLS_SECRETand send the token, or override the dependency for these handler-level tests.test_main.py,test_get_workouts.py, andtest_measurements_and_summary_hardening.pynow fail at import withImportError: cannot import name 'Depends' from 'fastapi': their hermeticfastapistub modules don't defineDepends, whichmain.pyline 18 imports. One line per file (_fastapi.Depends = _Framework/ addingDepends=to the stubmodule(...)) fixes it — #14447 did exactly this for the same pattern. Two of these are wired into.github/checks-manifest.yaml(whoop-measurements-tests,whoop-weekly-summary-hardening-tests), so they'd run red on anyplugins/omi-whoop-app/**change after this merges. The production code path itself is correct — this is purely the stubs lagging the new import._extract_presented_tokencan surface a non-ASCII string from header bytes, andhmac.compare_digestraisesTypeErroron non-ASCIIstr(reproduced in the same container) — a hostileAuthorizationheader would get a 500 instead of a clean 401. Comparing.encode("utf-8")bytes on both sides fixes it.- Wiring: the two new test files aren't registered in
.github/checks-manifest.yaml, andREADME.md's Environment Variables table doesn't mentionWHOOP_TOOLS_SECRETor the fail-closed rollout note (if the env var isn't set in production before merge, all seven/tools/*routes return 503).
The fix itself is sound and consistent with the shipbob/zapier pattern — with the test stubs, the guard robustness nit, and the manifest/README wiring handled, this should be in good shape. Leaving the shared-secret mechanism and the WHOOP_TOOLS_SECRET deployment coordination for maintainer sign-off given it gates all seven chat-tool routes.
🤖 Automated review on behalf of the maintainers.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Keeping this open on adf7239. Whoop /tools/get_recovery on main has no auth dependency. This head adds require_whoop_tools_auth. The check rollup was empty at classification. Not approving this SHA. — Astar, on behalf of @aryanorastar |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
Follow-up to review on BasedHardware#15918: - whoop_tools_auth: compare secrets on UTF-8 bytes so a non-ASCII Authorization header returns a clean 401 instead of a 500 (hmac.compare_digest raises TypeError on non-ASCII str). - Update existing tests broken by the new Depends import / fail-closed guard: add Depends to the hermetic fastapi stubs in test_main.py, test_get_workouts.py, test_measurements_and_summary_hardening.py; add a dependency_override for require_whoop_tools_auth in test_weekly_summary.py (handler-level tests) so it no longer 503s. - Register test_whoop_tools_auth.py and test_whoop_tools_no_leak.py in .github/checks-manifest.yaml. - Document WHOOP_TOOLS_SECRET in README (env table + setup), incl. the fail-closed 503 note. All whoop tests pass locally (auth 5, no-leak, workouts 4, measurements 4, weekly-summary 3).
|
Thanks for the thorough review @Git-on-my-level — all four points addressed in 817dfd4:
Local run: test_whoop_tools_auth 5/5, test_whoop_tools_no_leak pass, test_get_workouts 4/4, test_measurements_and_summary_hardening 4/4, test_weekly_summary 3/3. |
|
AI tooling disclosure (per the bounty program's contributor rules): Developed with AI assistance (an AI coding agent). Verification:
|
|
@aryanorastar Thanks for the review. The comment references On the current head, none of the seven
|
Verified on the current head 817dfd4 — all four items from this review are resolved: the guard compares UTF-8 bytes (non-ASCII Authorization headers now return a clean 401, not a TypeError/500), the hermetic fastapi stubs in test_main.py / test_get_workouts.py / test_measurements_and_summary_hardening.py define Depends (import failures gone, all pass), test_weekly_summary.py bypasses the guard via dependency_overrides, and both new suites are registered in checks-manifest.yaml with WHOOP_TOOLS_SECRET documented in the README. Full plugin suite passes in a clean container.
|
Verified on
Container run results: Two non-blocking observations for the record:
The earlier automated changes-requested review is dismissed since its concerns are addressed. The raw-exception-leak point from @aryanorastar's review is also resolved on this head (generic messages with detail preserved in by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
security(whoop-app): adds caller auth to /tools/* routes. aryanorastar's CHANGES_REQUESTED (raw str(e) leaks in /tools handlers, no test loading main.py) is resolved in the current head — diff confirms all 8 str(e) leaks removed, and new plugins/omi-whoop-app/test_whoop_tools_no_leak.py loads main.py directly and pins the no-leak behavior. mergeStateStatus is DIRTY so not merging; needs manual rebase.
|
@piyush295 this conflicts with |
All seven chat-tool routes acted with a user's stored Whoop OAuth token based solely on the body 'uid', with no caller authentication — anyone who knew a uid could read that user's sensitive health data (recovery, HRV, strain, sleep, body measurements). Add whoop_tools_auth.require_whoop_tools_auth: a shared-secret guard (Authorization: Bearer or whoop_tools_token query, WHOOP_TOOLS_SECRET env, hmac.compare_digest). Fail-closed 503 when unconfigured, 401 on missing/wrong token. Applied via dependencies=[Depends(...)] to all seven routes. Closes BasedHardware#14453
Addresses review on BasedHardware#15918: the seven /tools handlers returned 'Failed to get ...: {str(e)}', exposing raw internal exception detail to callers. Replace with generic messages (full detail still goes to log()). Also fix the OAuth callback 'Authentication error: {str(e)}' the same way. Add test_whoop_tools_no_leak.py which loads main.py (hermetic stubs) and drives every tool handler with a raising whoop_api_request, asserting the returned error never contains the raw exception text.
Follow-up to review on BasedHardware#15918: - whoop_tools_auth: compare secrets on UTF-8 bytes so a non-ASCII Authorization header returns a clean 401 instead of a 500 (hmac.compare_digest raises TypeError on non-ASCII str). - Update existing tests broken by the new Depends import / fail-closed guard: add Depends to the hermetic fastapi stubs in test_main.py, test_get_workouts.py, test_measurements_and_summary_hardening.py; add a dependency_override for require_whoop_tools_auth in test_weekly_summary.py (handler-level tests) so it no longer 503s. - Register test_whoop_tools_auth.py and test_whoop_tools_no_leak.py in .github/checks-manifest.yaml. - Document WHOOP_TOOLS_SECRET in README (env table + setup), incl. the fail-closed 503 note. All whoop tests pass locally (auth 5, no-leak, workouts 4, measurements 4, weekly-summary 3).
817dfd4 to
ba09024
Compare
|
@undivisible rebased on current |
|
@undivisible Thanks for the review! Rebased on The PR is now up-to-date with main and all previous review concerns have been addressed:
Ready for merge when you get a chance. Thanks! |
aryanorastar
left a comment
There was a problem hiding this comment.
On ba090242e91c229888468ce6a20215e25fd5d535, plugins/omi-whoop-app/main.py whoop_api_request still returns {"error": str(e)}.
Git-on-my-level
left a comment
There was a problem hiding this comment.
The shared-secret guard itself is well built and correctly wired, but one raw-exception leak path — the same one a maintainer flagged on this exact head — is still open, so requesting changes for that single item.
Blocking: whoop_api_request still leaks raw exception text into /tools/* responses. plugins/omi-whoop-app/main.py:182 returns {"error": str(e)} from its except, and six handlers interpolate it verbatim — e.g. main.py:643 error=f"Failed to get recovery: {result.get('error', 'Unknown error')}" (same pattern at 696, 746, 809, 963, 1012), plus whoop_fetch_all_records (main.py:202) propagates it into the weekly-summary response. A requests connection error carries host/URL/retry detail straight to the caller. test_whoop_tools_no_leak.py only pins the outer except path (it makes whoop_api_request itself raise), so the inner error-dict path escapes the suite. Suggested fix: return a generic marker (e.g. {"error": "upstream_error"}) from whoop_api_request — the real detail is already logged server-side at main.py:181 — and extend the no-leak test with a case where whoop_api_request returns an error dict.
The rest of the change looks right:
whoop_tools_auth.py— fail-closed 503 whenWHOOP_TOOLS_SECRETis unset, 401 on missing/wrong token,hmac.compare_digeston UTF-8 bytes (correctly dodging the non-ASCIITypeError→ 500). No bypass found. Non-blocking nit: thewhoop_tools_tokenquery param puts the secret in URLs (access/proxy logs); fine if it matches the sibling plugin fixes, but prefer header-only where the caller allows.main.pywiring — all seven/tools/*routes getDepends(require_whoop_tools_auth); the OAuth-callback error page de-leak is a good extra catch.README.md—WHOOP_TOOLS_SECRETdocumented with the fail-closed behavior..github/checks-manifest.yaml— both new suites registered with sensible triggers.test_whoop_tools_auth.py— covers 503/401 for both header and query presentation. Nit:setUp/tearDowndeleteWHOOP_TOOLS_SECRETwithout saving/restoring the ambient value.test_get_workouts.py/test_main.py/test_measurements_and_summary_hardening.py— minimalDependsshims; existing suites otherwise untouched.test_weekly_summary.py—app.dependency_overridesbypass withaddCleanupis the right pattern for handler-level tests.
Blast radius: all /tools/* Whoop routes. Rollout requires setting WHOOP_TOOLS_SECRET on both this plugin and its caller before deploy — otherwise every Whoop chat tool returns 503.
USER IMPACT: once deployed, Whoop chat tools answer only authenticated callers; if the secret isn't configured at rollout, the tools go dark (503) instead of answering.
Still want as a reviewer: (1) the inner-leak fix above, (2) a no-leak test case for the error-dict path, (3) confirmation that the calling side will send the secret at rollout.
Leaving security-review/needs-maintainer-review in place: the shared-secret rollout for a health-data plugin needs a maintainer's deployment sign-off, and the open leak finding deserves a human re-review after the fix.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Thanks for this contribution! Our review requested some changes (see above) and we haven't heard back in a while. If you're still working on it, just push a commit or leave a comment within the next 7 days. To keep the queue healthy we'll close this PR in 14 days if it stays inactive — and it can always be reopened once updates land. Happy to re-review! |
|
Hey @piyush295 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Summary
Fixes #14453. All seven
/tools/*routes inplugins/omi-whoop-app/main.py(get_recovery,get_strain,get_sleep,get_workouts,get_weekly_summary,get_body_measurements,get_profile) acted with a user's stored Whoop OAuth token based only on the bodyuid, with no caller authentication. Anyone who knew a uid could read that user's sensitive health data.Same defect class as the zapier (#14428/#14429), paid-mentor (#13685), and webhook (#14446/#14447) fixes; whoop was missed by all of them.
Fix
New
whoop_tools_auth.pywithrequire_whoop_tools_auth:Authorization: Bearer <secret>orwhoop_tools_tokenquery param, secret fromWHOOP_TOOLS_SECRET.hmac.compare_digest(timing-safe).dependencies=[Depends(require_whoop_tools_auth)]on all seven routes. Caller authentication only;uidremains body-level.Verification
ast.parsesyntax OK for both files.test_whoop_tools_auth.py(5 tests): unconfigured->503, missing->401, wrong->401, correct bearer->ok, correct query token->ok. All pass.Closes #14453