Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e617c946
Commit
e617c946
authored
Nov 27, 2018
by
Tetiana Chupryna
Committed by
Kamil Trzciński
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move VulnerabilityFeedback under namespace
parent
22ff93e5
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
91 additions
and
42 deletions
+91
-42
config/initializers/0_inflections.rb
config/initializers/0_inflections.rb
+1
-0
ee/app/controllers/projects/vulnerability_feedback_controller.rb
...controllers/projects/vulnerability_feedback_controller.rb
+3
-3
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+1
-1
ee/app/models/vulnerabilities/feedback.rb
ee/app/models/vulnerabilities/feedback.rb
+31
-0
ee/app/models/vulnerabilities/occurrence.rb
ee/app/models/vulnerabilities/occurrence.rb
+1
-1
ee/app/models/vulnerability_feedback.rb
ee/app/models/vulnerability_feedback.rb
+0
-25
ee/app/serializers/vulnerabilities/feedback_entity.rb
ee/app/serializers/vulnerabilities/feedback_entity.rb
+3
-1
ee/app/serializers/vulnerabilities/feedback_serializer.rb
ee/app/serializers/vulnerabilities/feedback_serializer.rb
+5
-0
ee/app/serializers/vulnerabilities/occurrence_entity.rb
ee/app/serializers/vulnerabilities/occurrence_entity.rb
+2
-2
ee/app/serializers/vulnerability_feedback_serializer.rb
ee/app/serializers/vulnerability_feedback_serializer.rb
+0
-3
ee/app/services/ee/users/migrate_to_ghost_user_service.rb
ee/app/services/ee/users/migrate_to_ghost_user_service.rb
+2
-2
ee/spec/factories/vulnerabilities/feedback.rb
ee/spec/factories/vulnerabilities/feedback.rb
+1
-1
ee/spec/models/vulnerabilities/feedback_spec.rb
ee/spec/models/vulnerabilities/feedback_spec.rb
+23
-0
ee/spec/models/vulnerabilities/scanner_spec.rb
ee/spec/models/vulnerabilities/scanner_spec.rb
+1
-1
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
+15
-0
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
+1
-1
No files found.
config/initializers/0_inflections.rb
View file @
e617c946
...
...
@@ -20,6 +20,7 @@ ActiveSupport::Inflector.inflections do |inflect|
file_registry
job_artifact_registry
vulnerability_feedback
vulnerabilities_feedback
)
inflect
.
acronym
'EE'
end
ee/app/controllers/projects/vulnerability_feedback_controller.rb
View file @
e617c946
...
...
@@ -14,12 +14,12 @@ class Projects::VulnerabilityFeedbackController < Projects::ApplicationControlle
@vulnerability_feedback
=
@project
.
vulnerability_feedback
.
with_associations
if
params
[
:category
].
present?
@vulnerability_feedback
=
@vulnerability_feedback
.
where
(
category:
Vulnerabilit
y
Feedback
.
categories
[
params
[
:category
]])
.
where
(
category:
Vulnerabilit
ies
::
Feedback
.
categories
[
params
[
:category
]])
end
if
params
[
:feedback_type
].
present?
@vulnerability_feedback
=
@vulnerability_feedback
.
where
(
feedback_type:
Vulnerabilit
y
Feedback
.
feedback_types
[
params
[
:feedback_type
]])
.
where
(
feedback_type:
Vulnerabilit
ies
::
Feedback
.
feedback_types
[
params
[
:feedback_type
]])
end
render
json:
serializer
.
represent
(
@vulnerability_feedback
)
...
...
@@ -51,7 +51,7 @@ class Projects::VulnerabilityFeedbackController < Projects::ApplicationControlle
end
def
serializer
Vulnerabilit
y
FeedbackSerializer
.
new
(
current_user:
current_user
,
project:
project
)
Vulnerabilit
ies
::
FeedbackSerializer
.
new
(
current_user:
current_user
,
project:
project
)
end
def
vulnerability_feedback
...
...
ee/app/models/ee/project.rb
View file @
e617c946
...
...
@@ -36,7 +36,7 @@ module EE
has_many
:approver_groups
,
as: :target
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:audit_events
,
as: :entity
has_many
:path_locks
has_many
:vulnerability_feedback
has_many
:vulnerability_feedback
,
class_name:
'Vulnerabilities::Feedback'
has_many
:vulnerabilities
,
class_name:
'Vulnerabilities::Occurrence'
has_many
:vulnerability_identifiers
,
class_name:
'Vulnerabilities::Identifier'
has_many
:vulnerability_scanners
,
class_name:
'Vulnerabilities::Scanner'
...
...
ee/app/models/ee/user.rb
View file @
e617c946
...
...
@@ -28,7 +28,7 @@ module EE
has_many
:epics
,
foreign_key: :author_id
has_many
:assigned_epics
,
foreign_key: :assignee_id
,
class_name:
"Epic"
has_many
:path_locks
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
has_many
:vulnerability_feedback
,
foreign_key: :author_id
has_many
:vulnerability_feedback
,
foreign_key: :author_id
,
class_name:
'Vulnerabilities::Feedback'
has_many
:approvals
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
has_many
:approvers
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
...
...
ee/app/models/vulnerabilities/feedback.rb
0 → 100644
View file @
e617c946
# frozen_string_literal: true
module
Vulnerabilities
class
Feedback
<
ActiveRecord
::
Base
self
.
table_name
=
'vulnerability_feedback'
belongs_to
:project
belongs_to
:author
,
class_name:
"User"
belongs_to
:issue
belongs_to
:pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :pipeline_id
attr_accessor
:vulnerability_data
enum
feedback_type:
{
dismissal:
0
,
issue:
1
}
enum
category:
{
sast:
0
,
dependency_scanning:
1
,
container_scanning:
2
,
dast:
3
}
validates
:project
,
presence:
true
validates
:author
,
presence:
true
validates
:issue
,
presence:
true
,
if: :issue?
validates
:vulnerability_data
,
presence:
true
,
if: :issue?
validates
:feedback_type
,
presence:
true
validates
:category
,
presence:
true
validates
:project_fingerprint
,
presence:
true
,
uniqueness:
{
scope:
[
:project_id
,
:category
,
:feedback_type
]
}
scope
:with_associations
,
->
{
includes
(
:pipeline
,
:issue
,
:author
)
}
scope
:all_preloaded
,
->
do
preload
(
:author
,
:project
,
:issue
,
:pipeline
)
end
end
end
ee/app/models/vulnerabilities/occurrence.rb
View file @
e617c946
...
...
@@ -86,7 +86,7 @@ module Vulnerabilities
categories
=
items
.
group_by
{
|
i
|
i
[
:category
]
}
fingerprints
=
items
.
group_by
{
|
i
|
i
[
:project_fingerprint
]
}
Vulnerabilit
y
Feedback
.
all_preloaded
.
where
(
Vulnerabilit
ies
::
Feedback
.
all_preloaded
.
where
(
project_id:
project_ids
.
keys
,
category:
categories
.
keys
,
project_fingerprint:
fingerprints
.
keys
).
find_each
do
|
feedback
|
...
...
ee/app/models/vulnerability_feedback.rb
deleted
100644 → 0
View file @
22ff93e5
class
VulnerabilityFeedback
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:author
,
class_name:
"User"
belongs_to
:issue
belongs_to
:pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :pipeline_id
attr_accessor
:vulnerability_data
enum
feedback_type:
{
dismissal:
0
,
issue:
1
}
enum
category:
{
sast:
0
,
dependency_scanning:
1
,
container_scanning:
2
,
dast:
3
}
validates
:project
,
presence:
true
validates
:author
,
presence:
true
validates
:issue
,
presence:
true
,
if: :issue?
validates
:vulnerability_data
,
presence:
true
,
if: :issue?
validates
:feedback_type
,
presence:
true
validates
:category
,
presence:
true
validates
:project_fingerprint
,
presence:
true
,
uniqueness:
{
scope:
[
:project_id
,
:category
,
:feedback_type
]
}
scope
:with_associations
,
->
{
includes
(
:pipeline
,
:issue
,
:author
)
}
scope
:all_preloaded
,
->
do
preload
(
:author
,
:project
,
:issue
,
:pipeline
)
end
end
ee/app/serializers/vulnerabilit
y_
feedback_entity.rb
→
ee/app/serializers/vulnerabilit
ies/
feedback_entity.rb
View file @
e617c946
class
VulnerabilityFeedbackEntity
<
Grape
::
Entity
# frozen_string_literal: true
class
Vulnerabilities::FeedbackEntity
<
Grape
::
Entity
include
Gitlab
::
Routing
include
GitlabRoutingHelper
...
...
ee/app/serializers/vulnerabilities/feedback_serializer.rb
0 → 100644
View file @
e617c946
# frozen_string_literal: true
class
Vulnerabilities::FeedbackSerializer
<
BaseSerializer
entity
Vulnerabilities
::
FeedbackEntity
end
ee/app/serializers/vulnerabilities/occurrence_entity.rb
View file @
e617c946
...
...
@@ -9,8 +9,8 @@ class Vulnerabilities::OccurrenceEntity < Grape::Entity
expose
:project_fingerprint
expose
:vulnerability_feedback_url
,
if:
->
(
*
)
{
can_admin_vulnerability_feedback?
}
expose
:project
,
using:
::
ProjectEntity
expose
:dismissal_feedback
,
using:
Vulnerabilit
y
FeedbackEntity
expose
:issue_feedback
,
using:
Vulnerabilit
y
FeedbackEntity
expose
:dismissal_feedback
,
using:
Vulnerabilit
ies
::
FeedbackEntity
expose
:issue_feedback
,
using:
Vulnerabilit
ies
::
FeedbackEntity
expose
:metadata
,
merge:
true
,
if:
->
(
occurrence
,
_
)
{
occurrence
.
raw_metadata
}
do
expose
:description
...
...
ee/app/serializers/vulnerability_feedback_serializer.rb
deleted
100644 → 0
View file @
22ff93e5
class
VulnerabilityFeedbackSerializer
<
BaseSerializer
entity
VulnerabilityFeedbackEntity
end
ee/app/services/ee/users/migrate_to_ghost_user_service.rb
View file @
e617c946
...
...
@@ -5,7 +5,7 @@ module EE
def
migrate_records
migrate_epics
migrate_vulnerabilit
y
_feedback
migrate_vulnerabilit
ies
_feedback
super
end
...
...
@@ -16,7 +16,7 @@ module EE
end
# rubocop: enable CodeReuse/ActiveRecord
def
migrate_vulnerabilit
y
_feedback
def
migrate_vulnerabilit
ies
_feedback
user
.
vulnerability_feedback
.
update_all
(
author_id:
ghost_user
.
id
)
end
end
...
...
ee/spec/factories/vulnerabilit
y_
feedback.rb
→
ee/spec/factories/vulnerabilit
ies/
feedback.rb
View file @
e617c946
...
...
@@ -5,7 +5,7 @@ FactoryBot.define do
Digest
::
SHA1
.
hexdigest
n
.
to_s
end
factory
:vulnerability_feedback
do
factory
:vulnerability_feedback
,
class:
Vulnerabilities
::
Feedback
do
project
author
issue
nil
...
...
ee/spec/models/vulnerabilities/feedback_spec.rb
0 → 100644
View file @
e617c946
# frozen_string_literal: true
require
'spec_helper'
describe
Vulnerabilities
::
Feedback
do
it
{
is_expected
.
to
define_enum_for
(
:feedback_type
)
}
it
{
is_expected
.
to
define_enum_for
(
:category
)
}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:author
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
belong_to
(
:issue
)
}
it
{
is_expected
.
to
belong_to
(
:pipeline
).
class_name
(
'Ci::Pipeline'
).
with_foreign_key
(
'pipeline_id'
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:author
)
}
it
{
is_expected
.
to
validate_presence_of
(
:feedback_type
)
}
it
{
is_expected
.
to
validate_presence_of
(
:category
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_fingerprint
)
}
end
end
ee/spec/models/vulnerabilities/scanner_spec.rb
View file @
e617c946
...
...
@@ -13,7 +13,7 @@ describe Vulnerabilities::Scanner do
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:
project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:
external_id
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:external_id
).
scoped_to
(
:project_id
)
}
end
...
...
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
0 → 100644
View file @
e617c946
# frozen_string_literal: true
require
'spec_helper'
describe
Vulnerabilities
::
FeedbackEntity
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
)
}
let
(
:entity
)
{
described_class
.
represent
(
feedback
)
}
describe
'#as_json'
do
subject
{
entity
.
as_json
}
it
{
is_expected
.
to
include
(
:project_id
,
:author
,
:category
,
:feedback_type
)
}
end
end
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
View file @
e617c946
...
...
@@ -24,7 +24,7 @@ describe Users::MigrateToGhostUserService do
let!
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
user
)
}
include_examples
"migrating a deleted user's associated records to the ghost user"
,
Vulnerabilit
y
Feedback
,
[
:author
]
do
include_examples
"migrating a deleted user's associated records to the ghost user"
,
Vulnerabilit
ies
::
Feedback
,
[
:author
]
do
let
(
:created_record
)
{
create
(
:vulnerability_feedback
,
author:
user
)
}
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment