oliver-zehentleitner / maity

hub: second factor: one mail_is_factor predicate and one send-or-record-unavailable helper for _first_mail and routes/second_factor

Sign in to report

tsk-bvab3qn0b2kk Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: duplication (one rule in several places).

What is wrong

  • The predicate policy == "email" and via == mail_factor.VIA is written at hub/src/maity_hub/auth/second_factor.py:630 (_check_mail), :655 (refuse_losing_the_address) and hub/src/maity_hub/routes/second_factor.py:151-153.
  • "address_unverified and ever_had_address -> failed(..., UNAVAILABLE, ip, browser, os)" is written at auth/second_factor.py:324-330 (_first_mail) and routes/second_factor.py:156-165.
  • second_factor.policy() (:94-95) is a thin wrapper of second_factor_policy.

Proposal

  • second_factor.mail_is_factor(conn, hub, human_id) at the three sites.
  • second_factor.send_mail(conn, hub, row, *, with_link) that sends and writes the unavailable record, returning or raising what the route needs; the route keeps only the raise after the commit.
  • Drop the policy() wrapper.

Effort / risk: S. Low.