Skip to content

Dynamic Render Path警告の解消(Book.exist?の安全化) #1737

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

Merged
merged 2 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/controllers/sotechsha2_pages_controller.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/controllers/sotechsha_pages_controller.rb

This file was deleted.

11 changes: 8 additions & 3 deletions app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ def find(title)
end

def exist?(title, page)
page.nil? ?
self.find(title).any? :
self.find(title).map(&:filename).include?(page + ".html")
return false unless page.present?

view_paths = [
Rails.root.join("app/views/books/#{title}/#{page}.html.erb"),
Rails.root.join("app/views/#{title}/#{page}.html.erb")
]

view_paths.any? { |path| File.exist?(path) }
end
end

Expand Down
46 changes: 0 additions & 46 deletions config/brakeman.ignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
{
"ignored_warnings": [
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
"fingerprint": "69b5a133fab8ea617d2581423cefaf077b9366e683c5fac715647bddeec7f50a",
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/controllers/sotechsha_pages_controller.rb",
"line": 5,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => \"sotechsha_pages/#{params[:page]}\", {})",
"render_path": null,
"location": {
"type": "method",
"class": "SotechshaPagesController",
"method": "show"
},
"user_input": "params[:page]",
"confidence": "Medium",
"cwe_id": [
22
],
"note": ""
},
{
"warning_type": "Command Injection",
"warning_code": 14,
Expand Down Expand Up @@ -188,29 +165,6 @@
],
"note": ""
},
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
"fingerprint": "c54623ebce2c2053b95088b9da8112aee962e7cadd79bd9b4b9afdedaddc15b1",
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/controllers/sotechsha2_pages_controller.rb",
"line": 5,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => \"sotechsha2_pages/#{params[:page]}\", {})",
"render_path": null,
"location": {
"type": "method",
"class": "Sotechsha2PagesController",
"method": "show"
},
"user_input": "params[:page]",
"confidence": "Medium",
"cwe_id": [
22
],
"note": ""
},
{
"warning_type": "Cross-Site Scripting",
"warning_code": 2,
Expand Down