Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return to ballotpopup #7858

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

holloway
Copy link
Contributor

@holloway holloway commented Aug 26, 2024

  • update the modal template route to take a param, rather than using request.path
  • ensure every place that uses the ballot_icon template tag is added to the allow list of valid 'return to' route handlers.

Copy link

codecov bot commented Aug 26, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.78%. Comparing base (c7f6bde) to head (a7c575d).
Report is 48 commits behind head on main.

Files Patch % Lines
ietf/doc/views_doc.py 66.66% 2 Missing ⚠️
ietf/doc/templatetags/ballot_icon.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7858      +/-   ##
==========================================
- Coverage   88.78%   88.78%   -0.01%     
==========================================
  Files         296      303       +7     
  Lines       41320    41430     +110     
==========================================
+ Hits        36687    36784      +97     
- Misses       4633     4646      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@holloway
Copy link
Contributor Author

holloway commented Aug 26, 2024

fyi @jennifer-richards: @rjsparks pointed out that the 'return to' param when coming from a modal doesn't make sense. Bootstrap modals are configured to scrape a modal template route (eg /doc/draft-ietf-opsawg-ipfix-tcpo-v6eh/ballotpopup/998718/) and then display that as a modal, so the 'return to' was the modal template route not the originating page from which the modal opened. This means there's a new layer of indirection when opening via modals, so the fix is to

  • update the modal template route to take a param, rather than using request.path, and validate the param using the same logic as before.
  • ensure every place that uses the ballot_icon template tag is added to the allow list of valid 'return to' route handlers. This is a bit like playing whack-a-mole, but I think I've found every usage.

@rjsparks
Copy link
Member

rjsparks commented Aug 27, 2024

This is a bit like playing whack-a-mole, but I think I've found every usage.

I think there are more, and the current behavior of the ballot modal is odd for pages that aren't included - it just dims the page the grid appears on, but the modal fails to appear.

Examples:

"GET /doc/draft-ietf-lamps-rfc8708bis/ballotpopup/1010652/?ballot_edit_return_point=/group/lamps/documents/ HTTP/1.0" 400 35
"GET /doc/draft-ietf-mls-architecture/ballotpopup/900022/?ballot_edit_return_point=/doc/in-last-call/ HTTP/1.0" 400 35
"GET /doc/draft-ietf-lamps-rfc8708bis/ballotpopup/1010652/?ballot_edit_return_point=/community/personal/[email protected]/ HTTP/1.0" 400 35

I think a careful traceback of any view that can include the ballot icon grid is what's going to have to happen, or the callback guard needs to be relaxed.

Could we review the threat model that leads to the current verification list?

Copy link
Member

@jennifer-richards jennifer-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, but I think a valid return point was missed. There are a couple minor bits of cleanup I suggest.

@@ -1457,7 +1457,7 @@ class ReturnToUrlTests(TestCase):
def test_invalid_return_to_url(self):
self.assertRaises(
Exception,
lambda: parse_ballot_edit_return_point('/doc/', 'draft-ietf-opsawg-ipfix-tcpo-v6eh', '998718'),
lambda: parse_ballot_edit_return_point('/', 'draft-ietf-opsawg-ipfix-tcpo-v6eh', '998718'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't noticed this pattern before, but you can avoid the lambda by using self.assertRaises() as a context manager:

with self.assertRaises(Exception):
    parse_ballot_edit_return_point(...)

I don't insist on changing this, but I find it a little easier to understand at a glance.

Should change Exception to ValueError though - I think that what comes back in every case, and it's better to be specific when possible. (And sorry for not catching this on an earlier review...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

ietf/doc/templatetags/ballot_icon.py Show resolved Hide resolved
ietf/doc/templatetags/ballot_icon.py Show resolved Hide resolved
ietf/doc/views_ballot.py Show resolved Hide resolved
Copy link
Member

@jennifer-richards jennifer-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. I didn't have a chance to double check that all the places search_result_row.html is included are in the allowed view list.

@holloway
Copy link
Contributor Author

@jennifer-richards fyi here's my notes on tracing back from search_result_row.html

search_result_row.html
	search_results.html
		view_list.html
			ietf/community/views.view_list
		drafts_for_ad.html
			ietf/doc/views_search.docs_for_ad
		drafts_in_last_call.html
			ietf/doc/views_search.drafts_in_last_call
		recent_drafts.html
			ietf/doc/views_search.recent_drafts
		search/search.html
			ietf/doc/views_search.search
		group_documents.html
			ietf/group/views.group_documents
		stream_documents.html
			ietf/group/views.stream_documents
	agenda_documents.html
		ietf/iesg/views.agenda_documents

(those views are in the allowed list)

@rjsparks rjsparks merged commit 715edaf into ietf-tools:main Aug 28, 2024
8 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants