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
98f471c6
Commit
98f471c6
authored
Aug 28, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set inverse_of option for associations
parent
2dafb6f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
4 deletions
+6
-4
ee/app/models/security/finding.rb
ee/app/models/security/finding.rb
+2
-2
ee/app/models/security/scan.rb
ee/app/models/security/scan.rb
+1
-1
ee/app/models/vulnerabilities/scanner.rb
ee/app/models/vulnerabilities/scanner.rb
+1
-0
ee/spec/models/vulnerabilities/scanner_spec.rb
ee/spec/models/vulnerabilities/scanner_spec.rb
+2
-1
No files found.
ee/app/models/security/finding.rb
View file @
98f471c6
...
@@ -11,8 +11,8 @@ module Security
...
@@ -11,8 +11,8 @@ module Security
class
Finding
<
ApplicationRecord
class
Finding
<
ApplicationRecord
self
.
table_name
=
'security_findings'
self
.
table_name
=
'security_findings'
belongs_to
:scan
,
optional:
false
belongs_to
:scan
,
inverse_of: :findings
,
optional:
false
belongs_to
:scanner
,
class_name:
'Vulnerabilities::Scanner'
,
optional:
false
belongs_to
:scanner
,
class_name:
'Vulnerabilities::Scanner'
,
inverse_of: :security_findings
,
optional:
false
# TODO: These are duplicated between this model and Vulnerabilities::Finding,
# TODO: These are duplicated between this model and Vulnerabilities::Finding,
# we should create a shared module to encapculate this in one place.
# we should create a shared module to encapculate this in one place.
...
...
ee/app/models/security/scan.rb
View file @
98f471c6
...
@@ -11,7 +11,7 @@ module Security
...
@@ -11,7 +11,7 @@ module Security
has_one
:pipeline
,
class_name:
'Ci::Pipeline'
,
through: :build
has_one
:pipeline
,
class_name:
'Ci::Pipeline'
,
through: :build
has_many
:findings
has_many
:findings
,
inverse_of: :scan
enum
scan_type:
{
enum
scan_type:
{
sast:
1
,
sast:
1
,
...
...
ee/app/models/vulnerabilities/scanner.rb
View file @
98f471c6
...
@@ -5,6 +5,7 @@ module Vulnerabilities
...
@@ -5,6 +5,7 @@ module Vulnerabilities
self
.
table_name
=
"vulnerability_scanners"
self
.
table_name
=
"vulnerability_scanners"
has_many
:findings
,
class_name:
'Vulnerabilities::Finding'
,
inverse_of: :scanner
has_many
:findings
,
class_name:
'Vulnerabilities::Finding'
,
inverse_of: :scanner
has_many
:security_findings
,
class_name:
'Security::Finding'
,
inverse_of: :scanner
belongs_to
:project
belongs_to
:project
...
...
ee/spec/models/vulnerabilities/scanner_spec.rb
View file @
98f471c6
...
@@ -4,8 +4,9 @@ require 'spec_helper'
...
@@ -4,8 +4,9 @@ require 'spec_helper'
RSpec
.
describe
Vulnerabilities
::
Scanner
do
RSpec
.
describe
Vulnerabilities
::
Scanner
do
describe
'associations'
do
describe
'associations'
do
it
{
is_expected
.
to
have_many
(
:findings
).
class_name
(
'Vulnerabilities::Finding'
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
have_many
(
:findings
).
class_name
(
'Vulnerabilities::Finding'
)
}
it
{
is_expected
.
to
have_many
(
:security_findings
).
class_name
(
'Security::Finding'
)
}
end
end
describe
'validations'
do
describe
'validations'
do
...
...
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