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
59d45d87
Commit
59d45d87
authored
Apr 15, 2022
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace onboarding action for license scanning
Changelog: added EE: true
parent
1b5ea408
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
3 deletions
+37
-3
app/models/onboarding_progress.rb
app/models/onboarding_progress.rb
+2
-1
db/migrate/20220405061122_add_license_scanning_action_to_onboarding_progresses.rb
...2_add_license_scanning_action_to_onboarding_progresses.rb
+7
-0
db/schema_migrations/20220405061122
db/schema_migrations/20220405061122
+1
-0
db/structure.sql
db/structure.sql
+2
-1
ee/app/models/sca/license_compliance.rb
ee/app/models/sca/license_compliance.rb
+8
-0
ee/spec/models/sca/license_compliance_spec.rb
ee/spec/models/sca/license_compliance_spec.rb
+17
-1
No files found.
app/models/onboarding_progress.rb
View file @
59d45d87
...
@@ -27,7 +27,8 @@ class OnboardingProgress < ApplicationRecord
...
@@ -27,7 +27,8 @@ class OnboardingProgress < ApplicationRecord
:secure_secret_detection_run
,
:secure_secret_detection_run
,
:secure_coverage_fuzzing_run
,
:secure_coverage_fuzzing_run
,
:secure_api_fuzzing_run
,
:secure_api_fuzzing_run
,
:secure_cluster_image_scanning_run
:secure_cluster_image_scanning_run
,
:license_scanning_run
].
freeze
].
freeze
scope
:incomplete_actions
,
->
(
actions
)
do
scope
:incomplete_actions
,
->
(
actions
)
do
...
...
db/migrate/20220405061122_add_license_scanning_action_to_onboarding_progresses.rb
0 → 100644
View file @
59d45d87
# frozen_string_literal: true
class
AddLicenseScanningActionToOnboardingProgresses
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
add_column
:onboarding_progresses
,
:license_scanning_run_at
,
:datetime_with_timezone
end
end
db/schema_migrations/20220405061122
0 → 100644
View file @
59d45d87
2b20f2c3bb8dd5d3ba27dcb8854108763a40be9393f4799f16e9c10daf9fff75
\ No newline at end of file
db/structure.sql
View file @
59d45d87
...
@@ -17697,7 +17697,8 @@ CREATE TABLE onboarding_progresses (
...
@@ -17697,7 +17697,8 @@ CREATE TABLE onboarding_progresses (
secure_secret_detection_run_at timestamp with time zone,
secure_secret_detection_run_at timestamp with time zone,
secure_coverage_fuzzing_run_at timestamp with time zone,
secure_coverage_fuzzing_run_at timestamp with time zone,
secure_cluster_image_scanning_run_at timestamp with time zone,
secure_cluster_image_scanning_run_at timestamp with time zone,
secure_api_fuzzing_run_at timestamp with time zone
secure_api_fuzzing_run_at timestamp with time zone,
license_scanning_run_at timestamp with time zone
);
);
CREATE SEQUENCE onboarding_progresses_id_seq
CREATE SEQUENCE onboarding_progresses_id_seq
ee/app/models/sca/license_compliance.rb
View file @
59d45d87
...
@@ -21,6 +21,8 @@ module SCA
...
@@ -21,6 +21,8 @@ module SCA
end
end
def
find_policies
(
detected_only:
false
,
classification:
[],
sort:
{
by: :name
,
direction: :asc
})
def
find_policies
(
detected_only:
false
,
classification:
[],
sort:
{
by: :name
,
direction: :asc
})
record_onboarding_progress
classifications
=
Array
(
classification
||
[])
classifications
=
Array
(
classification
||
[])
matching_policies
=
policies
.
reject
do
|
policy
|
matching_policies
=
policies
.
reject
do
|
policy
|
(
detected_only
&&
policy
.
dependencies
.
none?
)
||
(
detected_only
&&
policy
.
dependencies
.
none?
)
||
...
@@ -102,5 +104,11 @@ module SCA
...
@@ -102,5 +104,11 @@ module SCA
direction
=
SORT_DIRECTION
[
direction
]
||
SORT_DIRECTION
[
:asc
]
direction
=
SORT_DIRECTION
[
direction
]
||
SORT_DIRECTION
[
:asc
]
direction
.
call
(
items
.
sort_by
{
|
item
|
attribute
.
call
(
item
)
})
direction
.
call
(
items
.
sort_by
{
|
item
|
attribute
.
call
(
item
)
})
end
end
def
record_onboarding_progress
return
unless
pipeline
OnboardingProgress
.
register
(
pipeline
.
project
.
root_namespace
,
:license_scanning_run
)
end
end
end
end
end
ee/spec/models/sca/license_compliance_spec.rb
View file @
59d45d87
...
@@ -206,7 +206,23 @@ RSpec.describe SCA::LicenseCompliance do
...
@@ -206,7 +206,23 @@ RSpec.describe SCA::LicenseCompliance do
expect
(
actual
).
to
eql
(
expected
)
expect
(
actual
).
to
eql
(
expected
)
end
end
context
"when searching for policies for licenses that were detected in a scan report"
do
it
'records an onboarding progress action for license scanning'
do
expect
(
OnboardingProgress
).
to
receive
(
:register
).
with
(
pipeline
.
project
.
root_namespace
,
:license_scanning_run
).
and_call_original
license_compliance
.
find_policies
end
context
'when pipeline is not present'
do
let!
(
:pipeline
)
{
nil
}
it
'records an onboarding progress action for license scanning'
do
expect
(
OnboardingProgress
).
not_to
receive
(
:register
).
with
(
anything
)
license_compliance
.
find_policies
end
end
context
'when searching for policies for licenses that were detected in a scan report'
do
let
(
:results
)
{
license_compliance
.
find_policies
(
detected_only:
true
)
}
let
(
:results
)
{
license_compliance
.
find_policies
(
detected_only:
true
)
}
it
'only includes licenses that appear in the latest license scan report'
do
it
'only includes licenses that appear in the latest license scan report'
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