Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
ee99b2de
Commit
ee99b2de
authored
13 years ago
by
Jean-Philippe Lang
Committed by
Holger Just
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Prevent mass-assignment vulnerability when adding/updating a news (#922).
parent
4c322d37
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/news_controller.rb
+8
-9
8 additions, 9 deletions
app/controllers/news_controller.rb
app/models/news.rb
+3
-0
3 additions, 0 deletions
app/models/news.rb
with
11 additions
and
9 deletions
app/controllers/news_controller.rb
+
8
−
9
View file @
ee99b2de
...
...
@@ -59,14 +59,12 @@ class NewsController < ApplicationController
def
create
@news
=
News
.
new
(
:project
=>
@project
,
:author
=>
User
.
current
)
if
request
.
post?
@news
.
attributes
=
params
[
:news
]
if
@news
.
save
flash
[
:notice
]
=
l
(
:notice_successful_create
)
redirect_to
:controller
=>
'news'
,
:action
=>
'index'
,
:project_id
=>
@project
else
render
:action
=>
'new'
end
@news
.
safe_attributes
=
params
[
:news
]
if
@news
.
save
flash
[
:notice
]
=
l
(
:notice_successful_create
)
redirect_to
:controller
=>
'news'
,
:action
=>
'index'
,
:project_id
=>
@project
else
render
:action
=>
'new'
end
end
...
...
@@ -74,7 +72,8 @@ class NewsController < ApplicationController
end
def
update
if
request
.
put?
and
@news
.
update_attributes
(
params
[
:news
])
@news
.
safe_attributes
=
params
[
:news
]
if
@news
.
save
flash
[
:notice
]
=
l
(
:notice_successful_update
)
redirect_to
:action
=>
'show'
,
:id
=>
@news
else
...
...
This diff is collapsed.
Click to expand it.
app/models/news.rb
+
3
−
0
View file @
ee99b2de
...
...
@@ -13,6 +13,7 @@
#++
class
News
<
ActiveRecord
::
Base
include
Redmine
::
SafeAttributes
belongs_to
:project
belongs_to
:author
,
:class_name
=>
'User'
,
:foreign_key
=>
'author_id'
has_many
:comments
,
:as
=>
:commented
,
:dependent
=>
:delete_all
,
:order
=>
"created_on"
...
...
@@ -32,6 +33,8 @@ class News < ActiveRecord::Base
:conditions
=>
Project
.
allowed_to_condition
(
args
.
first
||
User
.
current
,
:view_news
)
}}
safe_attributes
'title'
,
'summary'
,
'description'
def
visible?
(
user
=
User
.
current
)
!
user
.
nil?
&&
user
.
allowed_to?
(
:view_news
,
project
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment