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
3848f504
Commit
3848f504
authored
Sep 17, 2019
by
mo khan
Committed by
Rémy Coutable
Sep 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for software license compliance violations after license management report is generated.
parent
b784b387
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
1 deletion
+29
-1
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+1
-1
ee/app/services/security/sync_reports_to_approval_rules_service.rb
...rvices/security/sync_reports_to_approval_rules_service.rb
+1
-0
ee/changelogs/unreleased/13067-check-for-generated-report.yml
...hangelogs/unreleased/13067-check-for-generated-report.yml
+5
-0
ee/lib/gitlab/ci/reports/license_management/report.rb
ee/lib/gitlab/ci/reports/license_management/report.rb
+4
-0
ee/spec/lib/gitlab/ci/reports/license_management/report_spec.rb
...c/lib/gitlab/ci/reports/license_management/report_spec.rb
+8
-0
ee/spec/services/security/sync_reports_to_approval_rules_service_spec.rb
...s/security/sync_reports_to_approval_rules_service_spec.rb
+10
-0
No files found.
ee/app/models/ee/ci/pipeline.rb
View file @
3848f504
...
...
@@ -54,7 +54,7 @@ module EE
state_machine
:status
do
after_transition
any
=>
::
Ci
::
Pipeline
.
completed_statuses
do
|
pipeline
|
next
unless
pipeline
.
has_reports?
(
::
Ci
::
JobArtifact
.
security_reports
)
next
unless
pipeline
.
has_reports?
(
::
Ci
::
JobArtifact
.
security_reports
.
or
(
::
Ci
::
JobArtifact
.
license_management_reports
)
)
pipeline
.
run_after_commit
do
StoreSecurityReportsWorker
.
perform_async
(
pipeline
.
id
)
if
pipeline
.
default_branch?
...
...
ee/app/services/security/sync_reports_to_approval_rules_service.rb
View file @
3848f504
...
...
@@ -30,6 +30,7 @@ module Security
def
sync_license_management_rules
project
=
pipeline
.
project
report
=
pipeline
.
license_management_report
return
if
report
.
empty?
&&
!
pipeline
.
complete?
return
if
report
.
violates?
(
project
.
software_license_policies
)
remove_required_approvals_for
(
ApprovalMergeRequestRule
.
report_approver
.
license_management
)
...
...
ee/changelogs/unreleased/13067-check-for-generated-report.yml
0 → 100644
View file @
3848f504
---
title
:
Wait until pipeline is completed before checking for software license violations
merge_request
:
16853
author
:
type
:
fixed
ee/lib/gitlab/ci/reports/license_management/report.rb
View file @
3848f504
...
...
@@ -45,6 +45,10 @@ module Gitlab
licenses
.
select
{
|
license
|
names
.
include?
(
canonicalize
(
license
.
name
))
}
end
def
empty?
found_licenses
.
empty?
end
private
def
canonicalize
(
name
)
...
...
ee/spec/lib/gitlab/ci/reports/license_management/report_spec.rb
View file @
3848f504
...
...
@@ -60,4 +60,12 @@ describe Gitlab::Ci::Reports::LicenseManagement::Report do
it
{
expect
(
names_from
(
subject
[
:unchanged
])).
to
contain_exactly
(
'MIT'
,
'BSD'
)
}
it
{
expect
(
names_from
(
subject
[
:removed
])).
to
contain_exactly
(
'WTFPL'
)
}
end
describe
"#empty?"
do
let
(
:completed_report
)
{
build
(
:ci_reports_license_management_report
,
:report_1
)
}
let
(
:empty_report
)
{
build
(
:ci_reports_license_management_report
)
}
it
{
expect
(
empty_report
).
to
be_empty
}
it
{
expect
(
completed_report
).
not_to
be_empty
}
end
end
ee/spec/services/security/sync_reports_to_approval_rules_service_spec.rb
View file @
3848f504
...
...
@@ -139,5 +139,15 @@ describe Security::SyncReportsToApprovalRulesService, '#execute' do
expect
{
subject
}
.
not_to
change
{
report_approver_rule
.
reload
.
approvals_required
}
end
context
"license compliance policy"
do
let
(
:pipeline
)
{
create
(
:ee_ci_pipeline
,
:running
,
project:
project
,
merge_requests_as_head_pipeline:
[
merge_request
])
}
let!
(
:software_license_policy
)
{
create
(
:software_license_policy
,
:blacklist
,
project:
project
,
software_license:
blacklisted_license
)
}
let!
(
:license_compliance_rule
)
{
create
(
:report_approver_rule
,
:license_management
,
merge_request:
merge_request
,
approvals_required:
1
)
}
let!
(
:blacklisted_license
)
{
create
(
:software_license
)
}
specify
{
expect
{
subject
}.
not_to
change
{
license_compliance_rule
.
reload
.
approvals_required
}
}
specify
{
expect
(
subject
[
:status
]).
to
be
(
:success
)
}
end
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