oliver-zehentleitner / maity

hub: forge: one segment rule (SEGMENT/_SEGMENT, stored_repository_url vs valid_repository) and one DNS-host check shared with person_links

Sign in to report

tsk-e37zwpg18j81 Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication.

What is wrong

  • hub/src/maity_hub/forge.py:61 _SEGMENT and forge.py:215 SEGMENT are the same regex [A-Za-z0-9._-]{1,255}.
  • The segment rule (fullmatch, not . or .., no .git or .atom suffix) is coded in stored_repository_url (forge.py:119-127) and again in valid_repository (forge.py:218-226).
  • The new forge._dns_host (forge.py:59-60, :68-74, plus _HOST_MAX) is the same check as person_links._dns (hub/src/maity_hub/person_links.py:27-28, :38-48); its own comment points there.

Proposal: one SEGMENT and a per-segment valid_segment() used by both functions; move dns_host() into a shared helper (net.py or plain_text.py) used by forge and person_links.

Effort / risk: S. Low risk.