- endpoint moved: WodifyClient_Class/Classes/Class/ActionGetClassAttendees (old Schedule_OS GetClassAttendees no longer fires anywhere in the app) - render.attendees() delegates to attendee_rows() — PersonName, not Name - test fixtures updated to ClassDetailAttendee.List wire shape - CLAUDE.md: diagnosis notes (path re-prefix + lazy attendee action) prime now captures 8/8 actions; 138 tests pass
168 lines
6.5 KiB
Python
168 lines
6.5 KiB
Python
"""Read-only action allowlist, and the guard that enforces it.
|
|
|
|
The session credential this client uses is a full login -- Wodify issues no
|
|
read-only token -- so nothing at the credential layer prevents a write. This
|
|
module *is* the enforcement. Two independent layers, both required:
|
|
|
|
1. ``ACTIONS`` -- an explicit allowlist. Anything unregistered cannot be called.
|
|
2. ``assert_read_only`` -- refuses any path containing a write marker, applied
|
|
even to allowlisted entries, so a careless registry edit still fails closed.
|
|
|
|
Keep both. See tests/test_actions.py.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import dataclasses
|
|
|
|
#: Substrings that mark a mutating OutSystems action. Matched case-insensitively
|
|
#: against the action path. Deliberately blunt: a false positive is a developer
|
|
#: annoyance, a false negative charges the user money or takes someone's spot.
|
|
WRITE_MARKERS: tuple[str, ...] = (
|
|
"create", "update", "delete", "save", "insert", "remove",
|
|
"reserve", "cancel", "signin", "checkin", "check_in", "enroll", "book",
|
|
"waitlistjoin", "leavewaitlist", "like", "comment", "accept", "submit",
|
|
"purchase", "pay", "charge", "logout", "setresult", "addresult",
|
|
)
|
|
|
|
|
|
class WriteAttemptError(RuntimeError):
|
|
"""Raised when something tries to call a mutating endpoint."""
|
|
|
|
|
|
class UnknownActionError(KeyError):
|
|
"""Raised when an action key is not in the allowlist."""
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Action:
|
|
"""A single read-only data action.
|
|
|
|
``path`` is everything after ``/screenservices/``.
|
|
``view_name`` is the OutSystems screen the real client reports.
|
|
``inputs`` documents the inputParameters keys; an empty tuple means the
|
|
action takes none. Actual values are supplied per call.
|
|
"""
|
|
|
|
key: str
|
|
path: str
|
|
view_name: str
|
|
summary: str
|
|
inputs: tuple[str, ...] = ()
|
|
|
|
|
|
_FETCH = "WodifyClient_DataFetch_WB"
|
|
|
|
ACTIONS: dict[str, Action] = {
|
|
a.key: a
|
|
for a in (
|
|
Action(
|
|
key="bookings",
|
|
path=f"{_FETCH}/Schedule_OS/GetClientAttendancesDataFetch_WB/DataActionGetAttendances",
|
|
view_name="MainScreens.Home",
|
|
summary="Classes the user has reserved or attended",
|
|
inputs=("Request",),
|
|
),
|
|
# The actual workout content. Fires only on the properly-reached workout
|
|
# screen (class detail -> Go to workout), which is why a cold load of
|
|
# /WodifyClient/Exercise never reveals it.
|
|
Action(
|
|
key="workout",
|
|
path=f"{_FETCH}/WOD_Flow/GetAllWorkoutData_WB/DataActionGetAllWorkoutData",
|
|
view_name="MainScreens.Exercise",
|
|
summary="Workout / WOD content for a date and program",
|
|
inputs=("In_Request",),
|
|
),
|
|
# NOTE: despite the name, this returns only {"Response": bool} -- a probe
|
|
# for whether the WOD has leaderboard components. It is NOT the workout
|
|
# content; `workout` above is. Keeping it registered because the name is
|
|
# a trap: something will eventually reach for it expecting content.
|
|
Action(
|
|
key="wodflags",
|
|
path=f"{_FETCH}/WOD_Flow/GetWorkoutData_HasWodLeaderboardComponents"
|
|
f"/DataActionGetWorkoutDataHasWodLeaderboardComponents",
|
|
view_name="MainScreens.Home",
|
|
summary="Boolean probe: does this WOD have leaderboard components "
|
|
"(NOT the workout text)",
|
|
inputs=("Request",),
|
|
),
|
|
Action(
|
|
key="attendees",
|
|
# 2026-08 Wodify redesign: the old
|
|
# Schedule_OS/GetClassAttendees_WB/DataActionGetClassAttendees
|
|
# no longer fires anywhere in the app. The class screen now sources
|
|
# its attendee list from this ServiceAPI-style action instead, and
|
|
# it only triggers when a class is opened from the Scheduler.
|
|
path="WodifyClient_Class/Classes/Class/ActionGetClassAttendees",
|
|
view_name="Classes.Class",
|
|
summary="Who is signed up for a class",
|
|
inputs=("Request",),
|
|
),
|
|
Action(
|
|
key="classdetail",
|
|
path=f"{_FETCH}/Schedule_OS/GetClass_WB/DataActionGetClass",
|
|
view_name="Classes.Class",
|
|
summary="Single class: time, program, description",
|
|
inputs=("Request",),
|
|
),
|
|
Action(
|
|
key="coach",
|
|
path=f"{_FETCH}/Schedule_OS/GetEmployeesForClass_WB/DataActionGetEmployeesForClass",
|
|
view_name="Classes.Class",
|
|
summary="Coach assigned to a class",
|
|
inputs=("Request",),
|
|
),
|
|
# The schedule screen's class list, with reservation counts. This is the
|
|
# only class-list action that returns data.
|
|
#
|
|
# Do NOT re-add WodifyClient_Class/Classes/Attendance/DataActionGetClasses:
|
|
# it returns placeholder records (Id "0", empty ScheduleList) even when the
|
|
# real client itself calls it -- confirmed by capturing the app's own
|
|
# request/response pair during a live walk (200, ~10 KB, zero real
|
|
# records). It is not parameter-gated; it is empty by design.
|
|
Action(
|
|
key="schedule",
|
|
path=f"{_FETCH}/Schedule_OS/GetClassList_ForClient_WithReservationCounts_WB"
|
|
f"/DataActionGetClassList_ForClient_WithReservationCounts",
|
|
view_name="MainScreens.Scheduler",
|
|
summary="All classes on a given day, with reservation counts",
|
|
inputs=("In_Request",),
|
|
),
|
|
Action(
|
|
key="waitlist",
|
|
path=f"{_FETCH}/Schedule_OS/GetClassWaitList_WB/DataActionGetClassWaitList",
|
|
view_name="Classes.Class",
|
|
summary="Waitlist for a class (read only -- never join or leave)",
|
|
inputs=("Request",),
|
|
),
|
|
)
|
|
}
|
|
|
|
|
|
def assert_read_only(path: str) -> None:
|
|
"""Raise :class:`WriteAttemptError` if ``path`` looks mutating.
|
|
|
|
Applied to every request, including allowlisted ones.
|
|
"""
|
|
lowered = path.lower()
|
|
for marker in WRITE_MARKERS:
|
|
if marker in lowered:
|
|
raise WriteAttemptError(
|
|
f"refusing to call {path!r}: contains write marker {marker!r}. "
|
|
"This client is read-only by design."
|
|
)
|
|
|
|
|
|
def get(key: str) -> Action:
|
|
"""Look up an allowlisted action, verifying it is still read-only."""
|
|
try:
|
|
action = ACTIONS[key]
|
|
except KeyError as exc:
|
|
known = ", ".join(sorted(ACTIONS))
|
|
raise UnknownActionError(f"unknown action {key!r}; known: {known}") from exc
|
|
assert_read_only(action.path)
|
|
return action
|
|
|
|
|
|
def keys() -> list[str]:
|
|
return sorted(ACTIONS)
|