Repository navigation
Conversation
Citation page: the citation text was printed with raw, so markup in a title or journal name ran in the page. It now goes through sanitized_title, which keeps sub, sup, em, i, strong and b and removes everything else. The publisher link is only shown for http(s) addresses (web_url), so a javascript: address in the record is no longer a link. People directory: show_committee built its list item by string concatenation and the view marked it html_safe with raw. It now builds safe HTML with tag.li, safe_join and link_to, which escape the committee and names, and the views drop raw. sanitized_title moves from DatatablesHelper to ApplicationHelper, as it is no longer only for datatables. Brakeman: 15 warnings down to 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brakeman flagged 10 cross-site scripting warnings in the citation page and the people directory (one of them high confidence). This fixes all of them: Brakeman goes from 15 warnings to 5, with none new.
Citation page (
citations/show.html.erb)raw @citation.formatted(long: true), so markup in a title or journal name ran in the page. It now goes throughsanitized_title, which keepssub,sup,em,i,strongandb(no attributes) and removes everything else.link_to ..., @citation.publisher_url, so ajavascript:address in a record became a clickable script. A newCitationsHelper#web_urlonly allowshttp://andhttps://addresses; anything else shows no link.People directory (
people/index.html.erb)PeopleHelper#show_committeebuilt its<li>by string concatenation, and the view marked it safe withraw(8 calls). It now builds the list item withtag.li,safe_joinandlink_to, which escape the committee and the names, and the views dropraw. The output is the same for normal names.Moved:
sanitized_titleand its tag list move fromDatatablesHelpertoApplicationHelper, since citations use it too. The datatable pages are unchanged.Not changed
Still flagged by Brakeman (5): the 3 accepted SQL warnings in
datatable.rb(admin-written queries),raw(datatable.title_and_years)indatatables/_datatable.html.erb:13andsponsors/index.html.erb:1. The citation abstract still goes throughmarkdown_to_htmlwithunsafe: true; Brakeman doesn't flag it, but it is the largest remaining raw-HTML path (audit finding 6) and needs a wider tag list than titles do.Before merging
Citations whose titles or journal names deliberately contain other markup, such as links or line breaks, will lose it on the citation page. A quick check on production data:
Testing
spec/requests/citation_people_markup_spec.rb: simple formatting stays and scripts and event handlers go from a citation title; a title like</script><script>alert(1)</script>can't break out of the page's JSON-LD data block; ajavascript:publisher URL is not linked while anhttps://one is; a person's name containing a script tag is escaped in the committee list, which still links to their page.spec/helpers/citations_helper_spec.rb(web_url) andspec/helpers/people_helper_spec.rb(show_committee): current members only, escaping of names and the committee, safe output.Generated by Claude Code