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

Changed cookie serializer from :hybrid to :json as hybrid serializer has security issues; Fixed collaboration_controller dynamic resource path brakeman issue; #2101

Merged
merged 2 commits into from
Aug 12, 2021
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
4 changes: 2 additions & 2 deletions src/supermarket/app/controllers/collaborators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def destroy_group
"#{collaborator.user.username} is still a collaborator on this #{params[:resourceable_type]}" " "
end
end

resource_path_str = "#{params[:resourceable_type].underscore}_path"
redirect_to(
resource
send(resource_path_str, resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the need for extra variables resource_path_str

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just for the readibility.

)
else
not_found!
Expand Down
32 changes: 31 additions & 1 deletion src/supermarket/config/brakeman.ignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
{
"ignored_warnings": [
{
"warning_type": "Cross-Site Scripting",
"warning_code": 4,
"fingerprint": "11a6322283bc54ef48d681d41a4dcd60c59cd3cce38e48d3d8ad28a27c19e242",
"check_name": "LinkToHref",
"message": "Potentially unsafe model attribute in `link_to` href",
"file": "app/views/tools/_tool.html.erb",
"line": 28,
"link": "https://brakemanscanner.org/docs/warning_types/link_to_href",
"code": "link_to(\"View Source\", (Unresolved Model).new.source_url, :class => \"button tiny radius secondary\", :target => \"_blank\", :rel => \"noopener\", :itemprop => \"codeRepository\")",
"render_path": [
{
"type": "template",
"name": "users/tools",
"line": 15,
"file": "app/views/users/tools.html.erb",
"rendered": {
"name": "tools/_tool",
"file": "app/views/tools/_tool.html.erb"
}
}
],
"location": {
"type": "template",
"template": "tools/_tool"
},
"user_input": "(Unresolved Model).new.source_url",
"confidence": "Weak",
"note": ""
},
{
"warning_type": "Redirect",
"warning_code": 18,
Expand Down Expand Up @@ -81,6 +111,6 @@
"note": ""
}
],
"updated": "2021-08-03 17:58:38 +0530",
"updated": "2021-08-09 12:47:05 +0530",
"brakeman_version": "5.1.1"
}
8 changes: 7 additions & 1 deletion src/supermarket/config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :hybrid

# NOTE - Changed the serializer from :hybrid to :json as the rails
# has been upgraded to version:5 around 4 years back.
# Changing this now as the chances of preexisting cookies which are more than 4 years old is very less.
# In worst case the cookie will not be supported and the user will be asked to signin again.
# If that's an issue we will revert it back to :hybrid
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Rails.application.config.action_dispatch.cookies_serializer = :json