No test coverage for rss.py's feed parsing or app.py's ssrf_check #20
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
paul_loth/krautspaceTV#20
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
tests/currently coversbackend/rotation.py(test_rotation.py) andbackend/db.py(test_db.py) reasonably well, but two significant pieces of pure, easily-unit-testable logic added recently have zero automated test coverage:backend/slides/rss.py's feed parsing pipeline —_parse_items,_pick_headline,_html_to_lines,_join_lines,_guess_author,_first_image_url,_strip_html. This is the most logic-dense file inbackend/slides/(handles RSS 2.0, Atom, GoToSocial's truncated-title-with-ellipsis quirk, Mastodon tag RSS with no<title>/<author>at all, markdown bold stripping, media:content image extraction, per-instance username derivation from post links) and has been manually verified via ad-hoc scratch scripts during development, but none of that got committed as real tests. A future change to any of these functions has no safety net.backend/app.py'sssrf_check()(added in #16) — the entire SSRF protection for/proxylives in this one pure function (ssrf_check,_resolve_hostname_ips,_is_internal_address), which was manually verified during development (private IPs, loopback, link-local, multicast,file://scheme, public hosts) but again isn't captured as a real test. This is a security-critical function — a regression here silently reopens the SSRF hole from #16 with no test to catch it.Suggested fix
Add
tests/test_rss.pycovering_parse_items/_pick_headline/_html_to_lines/_join_lines/_guess_author/_first_image_urlagainst small inline RSS/Atom XML fixtures representing: a normal RSS feed with<title>+<description>, a GoToSocial-style feed with a truncated<title>(trailing...) and full<content:encoded>, a Mastodon tag RSS feed with no<title>/<author>and<p>-separated<description>, an Atom feed, and a feed with<media:content>images.Add
tests/test_app.py(or extend an existing file) coveringssrf_checkagainst: loopback (127.0.0.1), RFC1918 ranges (10/8, 172.16/12, 192.168/16), link-local (169.254.0.0/16), afile://URL, and a normal public hostname — mirroring the manual test matrix used when #16 was fixed.Where
New:
tests/test_rss.py,tests/test_app.py(or similar). Follow the existingtests/test_rotation.pystyle (plainpytest, no fixtures needed beyond maybe small XML string constants).Fixed and deployed. Added tests/test_rss.py (40 tests) and tests/test_app.py (9 tests) covering rss.py's feed-parsing quirks and app.py's ssrf_check. Full suite: 71/71 passing, verified independently in this session as well as by the implementing agent.