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
tsk-e37zwpg18j81 Open
Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication.
What is wrong
hub/src/maity_hub/forge.py:61_SEGMENTandforge.py:215SEGMENTare the same regex[A-Za-z0-9._-]{1,255}.- The segment rule (fullmatch, not
.or.., no.gitor.atomsuffix) is coded instored_repository_url(forge.py:119-127) and again invalid_repository(forge.py:218-226). - The new
forge._dns_host(forge.py:59-60,:68-74, plus_HOST_MAX) is the same check asperson_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.