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
7ce3da53
Commit
7ce3da53
authored
Feb 10, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
dcaada67
54dd0ddb
Changes
69
Hide whitespace changes
Inline
Side-by-side
Showing
69 changed files
with
542 additions
and
270 deletions
+542
-270
changelogs/unreleased/improve_vuln_tracking-db_add_tracking_table.yml
...nreleased/improve_vuln_tracking-db_add_tracking_table.yml
+5
-0
changelogs/unreleased/rf-update-brakeman-rules.yml
changelogs/unreleased/rf-update-brakeman-rules.yml
+5
-0
db/migrate/20201108134919_add_finding_fingerprint_table.rb
db/migrate/20201108134919_add_finding_fingerprint_table.rb
+40
-0
db/migrate/20201109080646_create_vulnerability_findings_remediations_join_table.rb
..._create_vulnerability_findings_remediations_join_table.rb
+2
-0
db/schema_migrations/20201108134919
db/schema_migrations/20201108134919
+1
-0
db/structure.sql
db/structure.sql
+32
-0
doc/administration/logs.md
doc/administration/logs.md
+4
-1
ee/app/controllers/concerns/security_and_compliance_permissions.rb
...ntrollers/concerns/security_and_compliance_permissions.rb
+15
-0
ee/app/controllers/ee/admin/application_settings_controller.rb
...p/controllers/ee/admin/application_settings_controller.rb
+1
-1
ee/app/controllers/ee/projects/security/configuration_controller.rb
...trollers/ee/projects/security/configuration_controller.rb
+2
-0
ee/app/controllers/projects/audit_events_controller.rb
ee/app/controllers/projects/audit_events_controller.rb
+1
-0
ee/app/controllers/projects/dependencies_controller.rb
ee/app/controllers/projects/dependencies_controller.rb
+2
-0
ee/app/controllers/projects/licenses_controller.rb
ee/app/controllers/projects/licenses_controller.rb
+2
-0
ee/app/controllers/projects/on_demand_scans_controller.rb
ee/app/controllers/projects/on_demand_scans_controller.rb
+2
-0
ee/app/controllers/projects/security/api_fuzzing_configuration_controller.rb
...projects/security/api_fuzzing_configuration_controller.rb
+1
-0
ee/app/controllers/projects/security/corpus_management_controller.rb
...rollers/projects/security/corpus_management_controller.rb
+2
-0
ee/app/controllers/projects/security/dashboard_controller.rb
ee/app/controllers/projects/security/dashboard_controller.rb
+1
-0
ee/app/controllers/projects/security/dast_profiles_controller.rb
...controllers/projects/security/dast_profiles_controller.rb
+2
-0
ee/app/controllers/projects/security/dast_scanner_profiles_controller.rb
...ers/projects/security/dast_scanner_profiles_controller.rb
+2
-0
ee/app/controllers/projects/security/dast_site_profiles_controller.rb
...ollers/projects/security/dast_site_profiles_controller.rb
+2
-0
ee/app/controllers/projects/security/discover_controller.rb
ee/app/controllers/projects/security/discover_controller.rb
+2
-0
ee/app/controllers/projects/security/network_policies_controller.rb
...trollers/projects/security/network_policies_controller.rb
+2
-0
ee/app/controllers/projects/security/sast_configuration_controller.rb
...ollers/projects/security/sast_configuration_controller.rb
+1
-0
ee/app/controllers/projects/security/scanned_resources_controller.rb
...rollers/projects/security/scanned_resources_controller.rb
+2
-0
ee/app/controllers/projects/security/vulnerabilities/notes_controller.rb
...ers/projects/security/vulnerabilities/notes_controller.rb
+1
-0
ee/app/controllers/projects/security/vulnerabilities_controller.rb
...ntrollers/projects/security/vulnerabilities_controller.rb
+1
-0
ee/app/controllers/projects/security/vulnerability_report_controller.rb
...lers/projects/security/vulnerability_report_controller.rb
+1
-0
ee/app/controllers/projects/security/waf_anomalies_controller.rb
...controllers/projects/security/waf_anomalies_controller.rb
+2
-0
ee/app/controllers/projects/threat_monitoring_controller.rb
ee/app/controllers/projects/threat_monitoring_controller.rb
+2
-0
ee/app/helpers/ee/user_callouts_helper.rb
ee/app/helpers/ee/user_callouts_helper.rb
+0
-1
ee/app/models/ee/application_setting.rb
ee/app/models/ee/application_setting.rb
+1
-2
ee/app/models/instance_security_dashboard.rb
ee/app/models/instance_security_dashboard.rb
+1
-0
ee/app/services/ee/application_settings/update_service.rb
ee/app/services/ee/application_settings/update_service.rb
+0
-1
ee/app/views/admin/application_settings/_new_user_signups_cap.html.haml
...dmin/application_settings/_new_user_signups_cap.html.haml
+0
-2
ee/config/feature_flags/development/admin_new_user_signups_cap.yml
.../feature_flags/development/admin_new_user_signups_cap.yml
+0
-8
ee/spec/controllers/ee/registrations_controller_spec.rb
ee/spec/controllers/ee/registrations_controller_spec.rb
+4
-26
ee/spec/controllers/projects/dependencies_controller_spec.rb
ee/spec/controllers/projects/dependencies_controller_spec.rb
+10
-16
ee/spec/controllers/projects/licenses_controller_spec.rb
ee/spec/controllers/projects/licenses_controller_spec.rb
+28
-4
ee/spec/controllers/projects/security/api_fuzzing_configuration_controller_spec.rb
...cts/security/api_fuzzing_configuration_controller_spec.rb
+11
-2
ee/spec/controllers/projects/security/configuration_controller_spec.rb
...ollers/projects/security/configuration_controller_spec.rb
+12
-3
ee/spec/controllers/projects/security/dashboard_controller_spec.rb
...ontrollers/projects/security/dashboard_controller_spec.rb
+13
-5
ee/spec/controllers/projects/security/network_policies_controller_spec.rb
...ers/projects/security/network_policies_controller_spec.rb
+45
-5
ee/spec/controllers/projects/security/sast_configuration_controller_spec.rb
...s/projects/security/sast_configuration_controller_spec.rb
+34
-27
ee/spec/controllers/projects/security/scanned_resources_controller_spec.rb
...rs/projects/security/scanned_resources_controller_spec.rb
+6
-1
ee/spec/controllers/projects/security/vulnerabilities/notes_controller_spec.rb
...rojects/security/vulnerabilities/notes_controller_spec.rb
+25
-9
ee/spec/controllers/projects/security/vulnerabilities_controller_spec.rb
...lers/projects/security/vulnerabilities_controller_spec.rb
+9
-9
ee/spec/controllers/projects/security/vulnerability_report_controller_spec.rb
...projects/security/vulnerability_report_controller_spec.rb
+13
-5
ee/spec/controllers/projects/security/waf_anomalies_controller_spec.rb
...ollers/projects/security/waf_anomalies_controller_spec.rb
+9
-1
ee/spec/features/admin/admin_settings_spec.rb
ee/spec/features/admin/admin_settings_spec.rb
+26
-44
ee/spec/features/projects/audit_events_spec.rb
ee/spec/features/projects/audit_events_spec.rb
+4
-0
ee/spec/features/promotion_spec.rb
ee/spec/features/promotion_spec.rb
+4
-0
ee/spec/helpers/ee/user_callouts_helper_spec.rb
ee/spec/helpers/ee/user_callouts_helper_spec.rb
+0
-9
ee/spec/models/application_setting_spec.rb
ee/spec/models/application_setting_spec.rb
+9
-19
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+0
-12
ee/spec/models/instance_security_dashboard_spec.rb
ee/spec/models/instance_security_dashboard_spec.rb
+36
-4
ee/spec/requests/callout_spec.rb
ee/spec/requests/callout_spec.rb
+0
-8
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
+9
-0
ee/spec/requests/projects/security/corpus_management_controller_spec.rb
...ts/projects/security/corpus_management_controller_spec.rb
+15
-10
ee/spec/requests/projects/security/dast_profiles_controller_spec.rb
...quests/projects/security/dast_profiles_controller_spec.rb
+14
-10
ee/spec/requests/projects/security/dast_scanner_profiles_controller_spec.rb
...rojects/security/dast_scanner_profiles_controller_spec.rb
+9
-0
ee/spec/requests/projects/security/dast_site_profiles_controller_spec.rb
...s/projects/security/dast_site_profiles_controller_spec.rb
+9
-0
ee/spec/requests/projects/security/scanned_resources_controller_spec.rb
...ts/projects/security/scanned_resources_controller_spec.rb
+9
-1
ee/spec/services/application_settings/update_service_spec.rb
ee/spec/services/application_settings/update_service_spec.rb
+0
-10
ee/spec/services/ee/users/build_service_spec.rb
ee/spec/services/ee/users/build_service_spec.rb
+0
-12
ee/spec/support/shared_contexts/security_and_compliance_permissions_shared_context.rb
...xts/security_and_compliance_permissions_shared_context.rb
+33
-0
lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
+2
-1
rubocop/rubocop-migrations.yml
rubocop/rubocop-migrations.yml
+1
-0
spec/controllers/projects/security/configuration_controller_spec.rb
...ollers/projects/security/configuration_controller_spec.rb
+2
-0
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+1
-1
No files found.
changelogs/unreleased/improve_vuln_tracking-db_add_tracking_table.yml
0 → 100644
View file @
7ce3da53
---
title
:
'
Improve
Vulnerability
Tracking:
Add
fingerprints
table'
merge_request
:
52720
author
:
type
:
added
changelogs/unreleased/rf-update-brakeman-rules.yml
0 → 100644
View file @
7ce3da53
---
title
:
Update Ruby detection rules for SAST
merge_request
:
53414
author
:
type
:
changed
db/migrate/20201108134919_add_finding_fingerprint_table.rb
0 → 100644
View file @
7ce3da53
# frozen_string_literal: true
class
AddFindingFingerprintTable
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
FINGERPRINT_IDX
=
:idx_vuln_fingerprints_on_occurrences_id_and_fingerprint
UNIQ_IDX
=
:idx_vuln_fingerprints_uniqueness
def
up
with_lock_retries
do
create_table
:vulnerability_finding_fingerprints
do
|
t
|
t
.
references
:finding
,
index:
true
,
null:
false
,
foreign_key:
{
to_table: :vulnerability_occurrences
,
column: :finding_id
,
on_delete: :cascade
}
t
.
timestamps_with_timezone
null:
false
t
.
integer
:algorithm_type
,
null:
false
t
.
binary
:fingerprint_sha256
,
null:
false
t
.
index
%i[finding_id fingerprint_sha256]
,
name:
FINGERPRINT_IDX
,
unique:
true
# only one link should exist between occurrence and the fingerprint
t
.
index
%i[finding_id algorithm_type fingerprint_sha256]
,
name:
UNIQ_IDX
,
unique:
true
# these should be unique
end
end
end
def
down
with_lock_retries
do
drop_table
:vulnerability_finding_fingerprints
end
end
end
db/migrate/20201109080646_create_vulnerability_findings_remediations_join_table.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
class
CreateVulnerabilityFindingsRemediationsJoinTable
<
ActiveRecord
::
Migration
[
6.0
]
class
CreateVulnerabilityFindingsRemediationsJoinTable
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
DOWNTIME
=
false
# rubocop:disable Migration/CreateTableWithForeignKeys
def
change
def
change
create_table
:vulnerability_findings_remediations
do
|
t
|
create_table
:vulnerability_findings_remediations
do
|
t
|
t
.
references
:vulnerability_occurrence
,
index:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:vulnerability_occurrence
,
index:
false
,
foreign_key:
{
on_delete: :cascade
}
...
@@ -13,4 +14,5 @@ class CreateVulnerabilityFindingsRemediationsJoinTable < ActiveRecord::Migration
...
@@ -13,4 +14,5 @@ class CreateVulnerabilityFindingsRemediationsJoinTable < ActiveRecord::Migration
t
.
index
[
:vulnerability_occurrence_id
,
:vulnerability_remediation_id
],
unique:
true
,
name:
'index_vulnerability_findings_remediations_on_unique_keys'
t
.
index
[
:vulnerability_occurrence_id
,
:vulnerability_remediation_id
],
unique:
true
,
name:
'index_vulnerability_findings_remediations_on_unique_keys'
end
end
end
end
# rubocop:enable Migration/CreateTableWithForeignKeys
end
end
db/schema_migrations/20201108134919
0 → 100644
View file @
7ce3da53
6643e5b4c5597d92c94115f392bfbd5cfce9884eb0bcb18f9629855f3711eed0
\ No newline at end of file
db/structure.sql
View file @
7ce3da53
...
@@ -18142,6 +18142,24 @@ CREATE SEQUENCE vulnerability_feedback_id_seq
...
@@ -18142,6 +18142,24 @@ CREATE SEQUENCE vulnerability_feedback_id_seq
ALTER
SEQUENCE
vulnerability_feedback_id_seq
OWNED
BY
vulnerability_feedback
.
id
;
ALTER
SEQUENCE
vulnerability_feedback_id_seq
OWNED
BY
vulnerability_feedback
.
id
;
CREATE
TABLE
vulnerability_finding_fingerprints
(
id
bigint
NOT
NULL
,
finding_id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
updated_at
timestamp
with
time
zone
NOT
NULL
,
algorithm_type
integer
NOT
NULL
,
fingerprint_sha256
bytea
NOT
NULL
);
CREATE
SEQUENCE
vulnerability_finding_fingerprints_id_seq
START
WITH
1
INCREMENT
BY
1
NO
MINVALUE
NO
MAXVALUE
CACHE
1
;
ALTER
SEQUENCE
vulnerability_finding_fingerprints_id_seq
OWNED
BY
vulnerability_finding_fingerprints
.
id
;
CREATE
TABLE
vulnerability_finding_links
(
CREATE
TABLE
vulnerability_finding_links
(
id
bigint
NOT
NULL
,
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
...
@@ -19383,6 +19401,8 @@ ALTER TABLE ONLY vulnerability_external_issue_links ALTER COLUMN id SET DEFAULT
...
@@ -19383,6 +19401,8 @@ ALTER TABLE ONLY vulnerability_external_issue_links ALTER COLUMN id SET DEFAULT
ALTER
TABLE
ONLY
vulnerability_feedback
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_feedback_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_feedback
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_feedback_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_finding_fingerprints
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_finding_fingerprints_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_finding_links
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_finding_links_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_finding_links
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_finding_links_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_findings_remediations
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_findings_remediations_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
vulnerability_findings_remediations
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'vulnerability_findings_remediations_id_seq'
::
regclass
);
...
@@ -20958,6 +20978,9 @@ ALTER TABLE ONLY vulnerability_external_issue_links
...
@@ -20958,6 +20978,9 @@ ALTER TABLE ONLY vulnerability_external_issue_links
ALTER
TABLE
ONLY
vulnerability_feedback
ALTER
TABLE
ONLY
vulnerability_feedback
ADD
CONSTRAINT
vulnerability_feedback_pkey
PRIMARY
KEY
(
id
);
ADD
CONSTRAINT
vulnerability_feedback_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
vulnerability_finding_fingerprints
ADD
CONSTRAINT
vulnerability_finding_fingerprints_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
vulnerability_finding_links
ALTER
TABLE
ONLY
vulnerability_finding_links
ADD
CONSTRAINT
vulnerability_finding_links_pkey
PRIMARY
KEY
(
id
);
ADD
CONSTRAINT
vulnerability_finding_links_pkey
PRIMARY
KEY
(
id
);
...
@@ -21295,6 +21318,10 @@ CREATE INDEX idx_security_scans_on_scan_type ON security_scans USING btree (scan
...
@@ -21295,6 +21318,10 @@ CREATE INDEX idx_security_scans_on_scan_type ON security_scans USING btree (scan
CREATE
UNIQUE
INDEX
idx_serverless_domain_cluster_on_clusters_applications_knative
ON
serverless_domain_cluster
USING
btree
(
clusters_applications_knative_id
);
CREATE
UNIQUE
INDEX
idx_serverless_domain_cluster_on_clusters_applications_knative
ON
serverless_domain_cluster
USING
btree
(
clusters_applications_knative_id
);
CREATE
UNIQUE
INDEX
idx_vuln_fingerprints_on_occurrences_id_and_fingerprint
ON
vulnerability_finding_fingerprints
USING
btree
(
finding_id
,
fingerprint_sha256
);
CREATE
UNIQUE
INDEX
idx_vuln_fingerprints_uniqueness
ON
vulnerability_finding_fingerprints
USING
btree
(
finding_id
,
algorithm_type
,
fingerprint_sha256
);
CREATE
UNIQUE
INDEX
idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue
ON
vulnerability_external_issue_links
USING
btree
(
vulnerability_id
,
external_type
,
external_project_key
,
external_issue_key
);
CREATE
UNIQUE
INDEX
idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue
ON
vulnerability_external_issue_links
USING
btree
(
vulnerability_id
,
external_type
,
external_project_key
,
external_issue_key
);
CREATE
UNIQUE
INDEX
idx_vulnerability_ext_issue_links_on_vulne_id_and_link_type
ON
vulnerability_external_issue_links
USING
btree
(
vulnerability_id
,
link_type
)
WHERE
(
link_type
=
1
);
CREATE
UNIQUE
INDEX
idx_vulnerability_ext_issue_links_on_vulne_id_and_link_type
ON
vulnerability_external_issue_links
USING
btree
(
vulnerability_id
,
link_type
)
WHERE
(
link_type
=
1
);
...
@@ -23597,6 +23624,8 @@ CREATE INDEX index_vulnerability_feedback_on_merge_request_id ON vulnerability_f
...
@@ -23597,6 +23624,8 @@ CREATE INDEX index_vulnerability_feedback_on_merge_request_id ON vulnerability_f
CREATE
INDEX
index_vulnerability_feedback_on_pipeline_id
ON
vulnerability_feedback
USING
btree
(
pipeline_id
);
CREATE
INDEX
index_vulnerability_feedback_on_pipeline_id
ON
vulnerability_feedback
USING
btree
(
pipeline_id
);
CREATE
INDEX
index_vulnerability_finding_fingerprints_on_finding_id
ON
vulnerability_finding_fingerprints
USING
btree
(
finding_id
);
CREATE
INDEX
index_vulnerability_findings_remediations_on_remediation_id
ON
vulnerability_findings_remediations
USING
btree
(
vulnerability_remediation_id
);
CREATE
INDEX
index_vulnerability_findings_remediations_on_remediation_id
ON
vulnerability_findings_remediations
USING
btree
(
vulnerability_remediation_id
);
CREATE
UNIQUE
INDEX
index_vulnerability_findings_remediations_on_unique_keys
ON
vulnerability_findings_remediations
USING
btree
(
vulnerability_occurrence_id
,
vulnerability_remediation_id
);
CREATE
UNIQUE
INDEX
index_vulnerability_findings_remediations_on_unique_keys
ON
vulnerability_findings_remediations
USING
btree
(
vulnerability_occurrence_id
,
vulnerability_remediation_id
);
...
@@ -26120,6 +26149,9 @@ ALTER TABLE ONLY merge_trains
...
@@ -26120,6 +26149,9 @@ ALTER TABLE ONLY merge_trains
ALTER
TABLE
ONLY
ci_runner_namespaces
ALTER
TABLE
ONLY
ci_runner_namespaces
ADD
CONSTRAINT
fk_rails_f9d9ed3308
FOREIGN
KEY
(
namespace_id
)
REFERENCES
namespaces
(
id
)
ON
DELETE
CASCADE
;
ADD
CONSTRAINT
fk_rails_f9d9ed3308
FOREIGN
KEY
(
namespace_id
)
REFERENCES
namespaces
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
vulnerability_finding_fingerprints
ADD
CONSTRAINT
fk_rails_fa411253b2
FOREIGN
KEY
(
finding_id
)
REFERENCES
vulnerability_occurrences
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
requirements_management_test_reports
ALTER
TABLE
ONLY
requirements_management_test_reports
ADD
CONSTRAINT
fk_rails_fb3308ad55
FOREIGN
KEY
(
requirement_id
)
REFERENCES
requirements
(
id
)
ON
DELETE
CASCADE
;
ADD
CONSTRAINT
fk_rails_fb3308ad55
FOREIGN
KEY
(
requirement_id
)
REFERENCES
requirements
(
id
)
ON
DELETE
CASCADE
;
...
...
doc/administration/logs.md
View file @
7ce3da53
...
@@ -413,11 +413,14 @@ For example:
...
@@ -413,11 +413,14 @@ For example:
## Sidekiq Logs
## Sidekiq Logs
NOTE:
In Omnibus GitLab
`12.10`
or earlier, the Sidekiq log lives in
`/var/log/gitlab/gitlab-rails/sidekiq.log`
.
For Omnibus installations, some Sidekiq logs reside in
`/var/log/gitlab/sidekiq/current`
and as follows.
For Omnibus installations, some Sidekiq logs reside in
`/var/log/gitlab/sidekiq/current`
and as follows.
### `sidekiq.log`
### `sidekiq.log`
This file lives in
`/var/log/gitlab/
gitlab-rails/sidekiq.log
`
for
This file lives in
`/var/log/gitlab/
sidekiq/current
`
for
Omnibus GitLab packages or in
`/home/git/gitlab/log/sidekiq.log`
for
Omnibus GitLab packages or in
`/home/git/gitlab/log/sidekiq.log`
for
installations from source.
installations from source.
...
...
ee/app/controllers/concerns/security_and_compliance_permissions.rb
0 → 100644
View file @
7ce3da53
# frozen_string_literal: true
module
SecurityAndCompliancePermissions
extend
ActiveSupport
::
Concern
included
do
before_action
:ensure_security_and_compliance_enabled!
end
private
def
ensure_security_and_compliance_enabled!
render_404
unless
can?
(
current_user
,
:access_security_and_compliance
,
project
)
end
end
ee/app/controllers/ee/admin/application_settings_controller.rb
View file @
7ce3da53
...
@@ -62,7 +62,7 @@ module EE
...
@@ -62,7 +62,7 @@ module EE
attrs
<<
:maintenance_mode_message
attrs
<<
:maintenance_mode_message
end
end
attrs
<<
:new_user_signups_cap
if
::
Feature
.
enabled?
(
:admin_new_user_signups_cap
,
default_enabled:
true
)
attrs
<<
:new_user_signups_cap
attrs
attrs
end
end
...
...
ee/app/controllers/ee/projects/security/configuration_controller.rb
View file @
7ce3da53
...
@@ -7,6 +7,8 @@ module EE
...
@@ -7,6 +7,8 @@ module EE
extend
::
Gitlab
::
Utils
::
Override
extend
::
Gitlab
::
Utils
::
Override
prepended
do
prepended
do
include
SecurityAndCompliancePermissions
alias_method
:vulnerable
,
:project
alias_method
:vulnerable
,
:project
before_action
:ensure_security_dashboard_feature_enabled!
,
except:
[
:show
]
before_action
:ensure_security_dashboard_feature_enabled!
,
except:
[
:show
]
...
...
ee/app/controllers/projects/audit_events_controller.rb
View file @
7ce3da53
# frozen_string_literal: true
# frozen_string_literal: true
class
Projects::AuditEventsController
<
Projects
::
ApplicationController
class
Projects::AuditEventsController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
Utils
::
StrongMemoize
include
LicenseHelper
include
LicenseHelper
include
AuditEvents
::
EnforcesValidDateParams
include
AuditEvents
::
EnforcesValidDateParams
...
...
ee/app/controllers/projects/dependencies_controller.rb
View file @
7ce3da53
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
Projects
module
Projects
class
DependenciesController
<
Projects
::
ApplicationController
class
DependenciesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
:authorize_read_dependency_list!
before_action
:authorize_read_dependency_list!
feature_category
:dependency_scanning
feature_category
:dependency_scanning
...
...
ee/app/controllers/projects/licenses_controller.rb
View file @
7ce3da53
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
Projects
module
Projects
class
LicensesController
<
Projects
::
ApplicationController
class
LicensesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
:authorize_read_licenses!
,
only:
[
:index
]
before_action
:authorize_read_licenses!
,
only:
[
:index
]
before_action
:authorize_admin_software_license_policy!
,
only:
[
:create
,
:update
]
before_action
:authorize_admin_software_license_policy!
,
only:
[
:create
,
:update
]
...
...
ee/app/controllers/projects/on_demand_scans_controller.rb
View file @
7ce3da53
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
Projects
module
Projects
class
OnDemandScansController
<
Projects
::
ApplicationController
class
OnDemandScansController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
do
before_action
do
push_frontend_feature_flag
(
:security_on_demand_scans_site_validation
,
@project
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:security_on_demand_scans_site_validation
,
@project
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:security_dast_site_profiles_additional_fields
,
@project
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:security_dast_site_profiles_additional_fields
,
@project
,
default_enabled: :yaml
)
...
...
ee/app/controllers/projects/security/api_fuzzing_configuration_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Projects
module
Projects
module
Security
module
Security
class
ApiFuzzingConfigurationController
<
Projects
::
ApplicationController
class
ApiFuzzingConfigurationController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
alias_method
:vulnerable
,
:project
alias_method
:vulnerable
,
:project
...
...
ee/app/controllers/projects/security/corpus_management_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
CorpusManagementController
<
Projects
::
ApplicationController
class
CorpusManagementController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
do
before_action
do
render_404
unless
Feature
.
enabled?
(
:corpus_management
,
@project
,
default_enabled: :yaml
)
render_404
unless
Feature
.
enabled?
(
:corpus_management
,
@project
,
default_enabled: :yaml
)
authorize_read_coverage_fuzzing!
authorize_read_coverage_fuzzing!
...
...
ee/app/controllers/projects/security/dashboard_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Projects
module
Projects
module
Security
module
Security
class
DashboardController
<
Projects
::
ApplicationController
class
DashboardController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
alias_method
:vulnerable
,
:project
alias_method
:vulnerable
,
:project
...
...
ee/app/controllers/projects/security/dast_profiles_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
DastProfilesController
<
Projects
::
ApplicationController
class
DastProfilesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
do
before_action
do
authorize_read_on_demand_scans!
authorize_read_on_demand_scans!
push_frontend_feature_flag
(
:security_on_demand_scans_site_validation
,
@project
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:security_on_demand_scans_site_validation
,
@project
,
default_enabled: :yaml
)
...
...
ee/app/controllers/projects/security/dast_scanner_profiles_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
DastScannerProfilesController
<
Projects
::
ApplicationController
class
DastScannerProfilesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
:authorize_read_on_demand_scans!
before_action
:authorize_read_on_demand_scans!
feature_category
:dynamic_application_security_testing
feature_category
:dynamic_application_security_testing
...
...
ee/app/controllers/projects/security/dast_site_profiles_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
DastSiteProfilesController
<
Projects
::
ApplicationController
class
DastSiteProfilesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
do
before_action
do
authorize_read_on_demand_scans!
authorize_read_on_demand_scans!
push_frontend_feature_flag
(
:security_dast_site_profiles_additional_fields
,
@project
,
default_enabled: :yaml
)
push_frontend_feature_flag
(
:security_dast_site_profiles_additional_fields
,
@project
,
default_enabled: :yaml
)
...
...
ee/app/controllers/projects/security/discover_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
DiscoverController
<
Projects
::
ApplicationController
class
DiscoverController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
feature_category
:navigation
feature_category
:navigation
def
show
def
show
...
...
ee/app/controllers/projects/security/network_policies_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
NetworkPoliciesController
<
Projects
::
ApplicationController
class
NetworkPoliciesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
POLLING_INTERVAL
=
5_000
POLLING_INTERVAL
=
5_000
before_action
:authorize_read_threat_monitoring!
before_action
:authorize_read_threat_monitoring!
...
...
ee/app/controllers/projects/security/sast_configuration_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Projects
module
Projects
module
Security
module
Security
class
SastConfigurationController
<
Projects
::
ApplicationController
class
SastConfigurationController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
CreatesCommit
include
CreatesCommit
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
...
...
ee/app/controllers/projects/security/scanned_resources_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
ScannedResourcesController
<
::
Projects
::
ApplicationController
class
ScannedResourcesController
<
::
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
:authorize_read_vulnerability!
before_action
:authorize_read_vulnerability!
before_action
:scanned_resources
before_action
:scanned_resources
...
...
ee/app/controllers/projects/security/vulnerabilities/notes_controller.rb
View file @
7ce3da53
...
@@ -6,6 +6,7 @@ module Projects
...
@@ -6,6 +6,7 @@ module Projects
class
NotesController
<
Projects
::
ApplicationController
class
NotesController
<
Projects
::
ApplicationController
extend
::
Gitlab
::
Utils
::
Override
extend
::
Gitlab
::
Utils
::
Override
include
SecurityAndCompliancePermissions
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
include
NotesActions
include
NotesActions
include
NotesHelper
include
NotesHelper
...
...
ee/app/controllers/projects/security/vulnerabilities_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Projects
module
Projects
module
Security
module
Security
class
VulnerabilitiesController
<
Projects
::
ApplicationController
class
VulnerabilitiesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
include
IssuableActions
include
IssuableActions
include
RendersNotes
include
RendersNotes
...
...
ee/app/controllers/projects/security/vulnerability_report_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
module
Projects
module
Projects
module
Security
module
Security
class
VulnerabilityReportController
<
Projects
::
ApplicationController
class
VulnerabilityReportController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
include
SecurityDashboardsPermissions
include
SecurityDashboardsPermissions
before_action
do
before_action
do
...
...
ee/app/controllers/projects/security/waf_anomalies_controller.rb
View file @
7ce3da53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
module
Projects
module
Projects
module
Security
module
Security
class
WafAnomaliesController
<
Projects
::
ApplicationController
class
WafAnomaliesController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
POLLING_INTERVAL
=
5_000
POLLING_INTERVAL
=
5_000
before_action
:authorize_read_waf_anomalies!
before_action
:authorize_read_waf_anomalies!
...
...
ee/app/controllers/projects/threat_monitoring_controller.rb
View file @
7ce3da53
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
Projects
module
Projects
class
ThreatMonitoringController
<
Projects
::
ApplicationController
class
ThreatMonitoringController
<
Projects
::
ApplicationController
include
SecurityAndCompliancePermissions
before_action
:authorize_read_threat_monitoring!
before_action
:authorize_read_threat_monitoring!
before_action
do
before_action
do
push_frontend_feature_flag
(
:threat_monitoring_alerts
,
project
)
push_frontend_feature_flag
(
:threat_monitoring_alerts
,
project
)
...
...
ee/app/helpers/ee/user_callouts_helper.rb
View file @
7ce3da53
...
@@ -84,7 +84,6 @@ module EE
...
@@ -84,7 +84,6 @@ module EE
end
end
def
show_new_user_signups_cap_reached?
def
show_new_user_signups_cap_reached?
return
false
unless
::
Feature
.
enabled?
(
:admin_new_user_signups_cap
,
default_enabled:
true
)
return
false
unless
current_user
&
.
admin?
return
false
unless
current_user
&
.
admin?
return
false
if
user_dismissed?
(
NEW_USER_SIGNUPS_CAP_REACHED
)
return
false
if
user_dismissed?
(
NEW_USER_SIGNUPS_CAP_REACHED
)
...
...
ee/app/models/ee/application_setting.rb
View file @
7ce3da53
...
@@ -358,8 +358,7 @@ module EE
...
@@ -358,8 +358,7 @@ module EE
end
end
def
should_apply_user_signup_cap?
def
should_apply_user_signup_cap?
::
Feature
.
enabled?
(
:admin_new_user_signups_cap
,
default_enabled:
true
)
&&
::
Gitlab
::
CurrentSettings
.
new_user_signups_cap
.
present?
::
Gitlab
::
CurrentSettings
.
new_user_signups_cap
.
present?
end
end
private
private
...
...
ee/app/models/instance_security_dashboard.rb
View file @
7ce3da53
...
@@ -24,6 +24,7 @@ class InstanceSecurityDashboard
...
@@ -24,6 +24,7 @@ class InstanceSecurityDashboard
def
projects
def
projects
Project
.
where
(
id:
visible_users_security_dashboard_projects
)
Project
.
where
(
id:
visible_users_security_dashboard_projects
)
.
with_feature_available_for_user
(
:security_and_compliance
,
user
)
end
end
def
vulnerabilities
def
vulnerabilities
...
...
ee/app/services/ee/application_settings/update_service.rb
View file @
7ce3da53
...
@@ -52,7 +52,6 @@ module EE
...
@@ -52,7 +52,6 @@ module EE
def
user_cap_increased?
def
user_cap_increased?
return
false
unless
application_setting
.
previous_changes
.
key?
(
:new_user_signups_cap
)
return
false
unless
application_setting
.
previous_changes
.
key?
(
:new_user_signups_cap
)
return
false
unless
::
Feature
.
enabled?
(
:admin_new_user_signups_cap
,
default_enabled:
true
)
previous_user_cap
,
current_user_cap
=
application_setting
.
previous_changes
[
:new_user_signups_cap
]
previous_user_cap
,
current_user_cap
=
application_setting
.
previous_changes
[
:new_user_signups_cap
]
...
...
ee/app/views/admin/application_settings/_new_user_signups_cap.html.haml
View file @
7ce3da53
-
return
unless
::
Feature
.
enabled?
(
:admin_new_user_signups_cap
,
default_enabled:
true
)
.form-group
.form-group
=
form
.
label
:new_user_signups_cap
,
s_
(
'AdminArea|User cap'
),
class:
'label-bold'
=
form
.
label
:new_user_signups_cap
,
s_
(
'AdminArea|User cap'
),
class:
'label-bold'
=
form
.
number_field
:new_user_signups_cap
,
class:
'form-control gl-form-input'
,
max:
License
.
current
&
.
restricted_user_count
=
form
.
number_field
:new_user_signups_cap
,
class:
'form-control gl-form-input'
,
max:
License
.
current
&
.
restricted_user_count
...
...
ee/config/feature_flags/development/admin_new_user_signups_cap.yml
deleted
100644 → 0
View file @
dcaada67
---
name
:
admin_new_user_signups_cap
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45643
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/292600
milestone
:
'
13.6'
type
:
development
group
:
group::purchase
default_enabled
:
true
ee/spec/controllers/ee/registrations_controller_spec.rb
View file @
7ce3da53
...
@@ -74,39 +74,17 @@ RSpec.describe RegistrationsController do
...
@@ -74,39 +74,17 @@ RSpec.describe RegistrationsController do
end
end
end
end
context
'when user signup cap
setting is enabled
'
do
context
'when user signup cap
is set
'
do
before
do
before
do
stub_application_setting
(
new_user_signups_cap:
true
)
stub_application_setting
(
new_user_signups_cap:
1
)
end
end
it_behaves_like
'blocked user by default'
it_behaves_like
'blocked user by default'
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
context
'when require admin approval setting is disabled'
do
before
do
stub_application_setting
(
require_admin_approval_after_user_signup:
false
)
end
it_behaves_like
'active user by default'
end
context
'when require admin approval setting is enabled'
do
before
do
stub_application_setting
(
require_admin_approval_after_user_signup:
true
)
end
it_behaves_like
'blocked user by default'
end
end
end
end
context
'when user signup cap
setting is disabled
'
do
context
'when user signup cap
is not set
'
do
before
do
before
do
stub_application_setting
(
admin_new_user_signups_cap:
false
)
stub_application_setting
(
new_user_signups_cap:
nil
)
end
end
context
'when require admin approval setting is disabled'
do
context
'when require admin approval setting is disabled'
do
...
...
ee/spec/controllers/projects/dependencies_controller_spec.rb
View file @
7ce3da53
...
@@ -6,20 +6,23 @@ RSpec.describe Projects::DependenciesController do
...
@@ -6,20 +6,23 @@ RSpec.describe Projects::DependenciesController do
describe
'GET #index'
do
describe
'GET #index'
do
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:params
)
{
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
let
(
:params
)
{
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before
do
before
do
project
.
add_developer
(
developer
)
project
.
add_guest
(
guest
)
sign_in
(
user
)
sign_in
(
user
)
end
end
context
'with authorized user'
do
include_context
'"Security & Compliance" permissions'
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
let
(
:user
)
{
developer
}
let
(
:valid_request
)
{
get
:index
,
params:
params
}
before
do
end
project
.
add_developer
(
developer
)
project
.
add_guest
(
guest
)
end
context
'with authorized user'
do
context
'when feature is available'
do
context
'when feature is available'
do
before
do
before
do
stub_licensed_features
(
dependency_scanning:
true
,
license_scanning:
true
,
security_dashboard:
true
)
stub_licensed_features
(
dependency_scanning:
true
,
license_scanning:
true
,
security_dashboard:
true
)
...
@@ -138,14 +141,6 @@ RSpec.describe Projects::DependenciesController do
...
@@ -138,14 +141,6 @@ RSpec.describe Projects::DependenciesController do
expect
(
json_response
[
'dependencies'
].
length
).
to
eq
(
3
)
expect
(
json_response
[
'dependencies'
].
length
).
to
eq
(
3
)
end
end
end
end
context
'without authorized user to see vulnerabilities'
do
let
(
:user
)
{
guest
}
it
'return vulnerable dependencies'
do
expect
(
json_response
[
'dependencies'
]).
to
be_empty
end
end
end
end
context
'with pagination params'
do
context
'with pagination params'
do
...
@@ -247,7 +242,6 @@ RSpec.describe Projects::DependenciesController do
...
@@ -247,7 +242,6 @@ RSpec.describe Projects::DependenciesController do
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:user
)
{
guest
}
let
(
:user
)
{
guest
}
before
do
before
do
...
...
ee/spec/controllers/projects/licenses_controller_spec.rb
View file @
7ce3da53
...
@@ -13,6 +13,14 @@ RSpec.describe Projects::LicensesController do
...
@@ -13,6 +13,14 @@ RSpec.describe Projects::LicensesController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
:index
,
params:
params
}
before_request
do
project
.
add_reporter
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
context
'when feature is available'
do
context
'when feature is available'
do
before
do
before
do
...
@@ -347,6 +355,7 @@ RSpec.describe Projects::LicensesController do
...
@@ -347,6 +355,7 @@ RSpec.describe Projects::LicensesController do
end
end
describe
"POST #create"
do
describe
"POST #create"
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:mit_license
)
{
create
(
:software_license
,
:mit
)
}
let
(
:mit_license
)
{
create
(
:software_license
,
:mit
)
}
let
(
:default_params
)
do
let
(
:default_params
)
do
...
@@ -360,9 +369,16 @@ RSpec.describe Projects::LicensesController do
...
@@ -360,9 +369,16 @@ RSpec.describe Projects::LicensesController do
}
}
end
end
context
"when authenticated"
do
include_context
'"Security & Compliance" permissions'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:valid_request
)
{
post
:create
,
xhr:
true
,
params:
default_params
}
before_request
do
project
.
add_reporter
(
current_user
)
sign_in
(
current_user
)
end
end
context
"when authenticated"
do
before
do
before
do
stub_licensed_features
(
license_scanning:
true
)
stub_licensed_features
(
license_scanning:
true
)
sign_in
(
current_user
)
sign_in
(
current_user
)
...
@@ -465,6 +481,7 @@ RSpec.describe Projects::LicensesController do
...
@@ -465,6 +481,7 @@ RSpec.describe Projects::LicensesController do
end
end
describe
"PATCH #update"
do
describe
"PATCH #update"
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
let
(
:software_license_policy
)
{
create
(
:software_license_policy
,
project:
project
,
software_license:
mit_license
)
}
let
(
:software_license_policy
)
{
create
(
:software_license_policy
,
project:
project
,
software_license:
mit_license
)
}
let
(
:mit_license
)
{
create
(
:software_license
,
:mit
)
}
let
(
:mit_license
)
{
create
(
:software_license
,
:mit
)
}
...
@@ -478,9 +495,16 @@ RSpec.describe Projects::LicensesController do
...
@@ -478,9 +495,16 @@ RSpec.describe Projects::LicensesController do
}
}
end
end
context
"when authenticated"
do
include_context
'"Security & Compliance" permissions'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:valid_request
)
{
post
:create
,
xhr:
true
,
params:
default_params
}
before_request
do
project
.
add_reporter
(
current_user
)
sign_in
(
current_user
)
end
end
context
"when authenticated"
do
before
do
before
do
stub_licensed_features
(
license_scanning:
true
)
stub_licensed_features
(
license_scanning:
true
)
sign_in
(
current_user
)
sign_in
(
current_user
)
...
...
ee/spec/controllers/projects/security/api_fuzzing_configuration_controller_spec.rb
View file @
7ce3da53
...
@@ -8,14 +8,23 @@ RSpec.describe Projects::Security::ApiFuzzingConfigurationController do
...
@@ -8,14 +8,23 @@ RSpec.describe Projects::Security::ApiFuzzingConfigurationController do
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
subject
(
:request
)
{
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before_all
do
before_all
do
group
.
add_developer
(
developer
)
group
.
add_developer
(
developer
)
group
.
add_guest
(
guest
)
group
.
add_guest
(
guest
)
end
end
describe
'GET #show'
do
include_context
'"Security & Compliance" permissions'
do
subject
(
:request
)
{
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
let
(
:valid_request
)
{
request
}
before_request
do
stub_licensed_features
(
security_dashboard:
true
)
sign_in
(
developer
)
end
end
describe
'GET #show'
do
render_views
render_views
it_behaves_like
SecurityDashboardsPermissions
do
it_behaves_like
SecurityDashboardsPermissions
do
...
...
ee/spec/controllers/projects/security/configuration_controller_spec.rb
View file @
7ce3da53
...
@@ -3,8 +3,14 @@
...
@@ -3,8 +3,14 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Projects
::
Security
::
ConfigurationController
do
RSpec
.
describe
Projects
::
Security
::
ConfigurationController
do
let
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be_with_refind
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
before
do
stub_licensed_features
(
security_dashboard:
true
)
group
.
add_developer
(
user
)
end
describe
'GET #show'
do
describe
'GET #show'
do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
...
@@ -34,6 +40,10 @@ RSpec.describe Projects::Security::ConfigurationController do
...
@@ -34,6 +40,10 @@ RSpec.describe Projects::Security::ConfigurationController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
end
it
'responds with the correct status'
do
it
'responds with the correct status'
do
request
request
...
@@ -134,7 +144,6 @@ RSpec.describe Projects::Security::ConfigurationController do
...
@@ -134,7 +144,6 @@ RSpec.describe Projects::Security::ConfigurationController do
end
end
before
do
before
do
stub_licensed_features
(
security_dashboard:
true
)
project
.
add_maintainer
(
maintainer
)
project
.
add_maintainer
(
maintainer
)
project
.
add_developer
(
developer
)
project
.
add_developer
(
developer
)
sign_in
(
user
)
sign_in
(
user
)
...
...
ee/spec/controllers/projects/security/dashboard_controller_spec.rb
View file @
7ce3da53
...
@@ -7,6 +7,19 @@ RSpec.describe Projects::Security::DashboardController do
...
@@ -7,6 +7,19 @@ RSpec.describe Projects::Security::DashboardController do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_developer
(
user
)
stub_licensed_features
(
security_dashboard:
true
)
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before_request
do
sign_in
(
user
)
end
end
it_behaves_like
SecurityDashboardsPermissions
do
it_behaves_like
SecurityDashboardsPermissions
do
let
(
:vulnerable
)
{
project
}
let
(
:vulnerable
)
{
project
}
...
@@ -15,11 +28,6 @@ RSpec.describe Projects::Security::DashboardController do
...
@@ -15,11 +28,6 @@ RSpec.describe Projects::Security::DashboardController do
end
end
end
end
before
do
group
.
add_developer
(
user
)
stub_licensed_features
(
security_dashboard:
true
)
end
describe
'GET #index'
do
describe
'GET #index'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
...
...
ee/spec/controllers/projects/security/network_policies_controller_spec.rb
View file @
7ce3da53
...
@@ -54,10 +54,18 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -54,10 +54,18 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
end
end
describe
'GET #summary'
do
describe
'GET #summary'
do
subject
{
get
:summary
,
params:
action_params
,
format: :json
}
subject
(
:request
)
{
get
:summary
,
params:
action_params
,
format: :json
}
let_it_be
(
:kubernetes_namespace
)
{
environment
.
deployment_namespace
}
let_it_be
(
:kubernetes_namespace
)
{
environment
.
deployment_namespace
}
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
@@ -160,7 +168,15 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -160,7 +168,15 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
end
end
describe
'GET #index'
do
describe
'GET #index'
do
subject
{
get
:index
,
params:
action_params
,
format: :json
}
subject
(
:request
)
{
get
:index
,
params:
action_params
,
format: :json
}
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
let
(
:service
)
{
instance_double
(
'NetworkPolicies::ResourcesService'
,
execute:
ServiceResponse
.
success
(
payload:
[
policy
]))
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::ResourcesService'
,
execute:
ServiceResponse
.
success
(
payload:
[
policy
]))
}
...
@@ -198,7 +214,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -198,7 +214,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
end
end
describe
'POST #create'
do
describe
'POST #create'
do
subject
{
post
:create
,
params:
action_params
.
merge
(
manifest:
manifest
),
format: :json
}
subject
(
:request
)
{
post
:create
,
params:
action_params
.
merge
(
manifest:
manifest
),
format: :json
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeployResourceService'
,
execute:
ServiceResponse
.
success
(
payload:
policy
))
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeployResourceService'
,
execute:
ServiceResponse
.
success
(
payload:
policy
))
}
let
(
:policy
)
do
let
(
:policy
)
do
...
@@ -210,6 +226,14 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -210,6 +226,14 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
)
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
@@ -240,7 +264,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -240,7 +264,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
end
end
describe
'PUT #update'
do
describe
'PUT #update'
do
subject
{
put
:update
,
params:
action_params
.
merge
(
id:
'example-policy'
,
manifest:
manifest
,
enabled:
enabled
),
as: :json
}
subject
(
:request
)
{
put
:update
,
params:
action_params
.
merge
(
id:
'example-policy'
,
manifest:
manifest
,
enabled:
enabled
),
as: :json
}
let
(
:enabled
)
{
nil
}
let
(
:enabled
)
{
nil
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeployResourceService'
,
execute:
ServiceResponse
.
success
(
payload:
policy
))
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeployResourceService'
,
execute:
ServiceResponse
.
success
(
payload:
policy
))
}
...
@@ -253,6 +277,14 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -253,6 +277,14 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
)
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
@@ -283,10 +315,18 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
...
@@ -283,10 +315,18 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
end
end
describe
'DELETE #destroy'
do
describe
'DELETE #destroy'
do
subject
{
delete
:destroy
,
params:
action_params
.
merge
(
id:
'example-policy'
,
manifest:
manifest
),
format: :json
}
subject
(
:request
)
{
delete
:destroy
,
params:
action_params
.
merge
(
id:
'example-policy'
,
manifest:
manifest
),
format: :json
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeleteResourceService'
,
execute:
ServiceResponse
.
success
)
}
let
(
:service
)
{
instance_double
(
'NetworkPolicies::DeleteResourceService'
,
execute:
ServiceResponse
.
success
)
}
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
...
ee/spec/controllers/projects/security/sast_configuration_controller_spec.rb
View file @
7ce3da53
...
@@ -4,7 +4,7 @@ require 'spec_helper'
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
Security
::
SastConfigurationController
do
RSpec
.
describe
Projects
::
Security
::
SastConfigurationController
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
...
@@ -13,11 +13,23 @@ RSpec.describe Projects::Security::SastConfigurationController do
...
@@ -13,11 +13,23 @@ RSpec.describe Projects::Security::SastConfigurationController do
group
.
add_guest
(
guest
)
group
.
add_guest
(
guest
)
end
end
before
do
stub_licensed_features
(
security_dashboard:
true
)
end
describe
'GET #show'
do
describe
'GET #show'
do
subject
(
:request
)
{
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
subject
(
:request
)
{
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
render_views
render_views
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
sign_in
(
developer
)
end
end
it_behaves_like
SecurityDashboardsPermissions
do
it_behaves_like
SecurityDashboardsPermissions
do
let
(
:vulnerable
)
{
project
}
let
(
:vulnerable
)
{
project
}
let
(
:security_dashboard_action
)
{
request
}
let
(
:security_dashboard_action
)
{
request
}
...
@@ -25,8 +37,6 @@ RSpec.describe Projects::Security::SastConfigurationController do
...
@@ -25,8 +37,6 @@ RSpec.describe Projects::Security::SastConfigurationController do
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
stub_licensed_features
(
security_dashboard:
true
)
sign_in
(
developer
)
sign_in
(
developer
)
end
end
...
@@ -58,8 +68,6 @@ RSpec.describe Projects::Security::SastConfigurationController do
...
@@ -58,8 +68,6 @@ RSpec.describe Projects::Security::SastConfigurationController do
context
'with unauthorized user'
do
context
'with unauthorized user'
do
before
do
before
do
stub_licensed_features
(
security_dashboard:
true
)
sign_in
(
guest
)
sign_in
(
guest
)
end
end
...
@@ -72,39 +80,38 @@ RSpec.describe Projects::Security::SastConfigurationController do
...
@@ -72,39 +80,38 @@ RSpec.describe Projects::Security::SastConfigurationController do
end
end
describe
'POST #create'
do
describe
'POST #create'
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
group
)
}
let
(
:params
)
do
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
sast_configuration:
{
secure_analyzers_prefix:
'localhost:5000/analyzers'
,
sast_analyzer_image_tag:
'1'
,
sast_excluded_paths:
'docs'
,
stage:
'security'
,
search_max_depth:
11
},
format: :json
}
end
before
do
subject
(
:request
)
{
post
:create
,
params:
params
,
as: :json
}
stub_licensed_features
(
security_dashboard:
true
)
before
do
sign_in
(
developer
)
sign_in
(
developer
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
end
context
'with valid params'
do
context
'with valid params'
do
it
'returns the new merge request url'
do
it
'returns the new merge request url'
do
params
=
{
request
secure_analyzers_prefix:
'localhost:5000/analyzers'
,
sast_analyzer_image_tag:
'1'
,
sast_excluded_paths:
'docs'
,
stage:
'security'
,
search_max_depth:
11
}
create_sast_configuration
user:
developer
,
project:
project
,
params:
params
expect
(
json_response
[
"message"
]).
to
eq
(
"success"
)
expect
(
json_response
[
"message"
]).
to
eq
(
"success"
)
expect
(
json_response
[
"filePath"
]).
to
match
(
/
#{
Gitlab
::
Routing
.
url_helpers
.
project_new_merge_request_url
(
project
,
{
}
)}(.*)description(.*)source_branch/
)
expect
(
json_response
[
"filePath"
]).
to
match
(
/
#{
Gitlab
::
Routing
.
url_helpers
.
project_new_merge_request_url
(
project
,
{
}
)}(.*)description(.*)source_branch/
)
end
end
end
end
end
end
def
create_sast_configuration
(
user
:,
project
:,
params
:)
post_params
=
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
sast_configuration:
params
,
format: :json
}
post
:create
,
params:
post_params
,
as: :json
end
end
end
ee/spec/controllers/projects/security/scanned_resources_controller_spec.rb
View file @
7ce3da53
...
@@ -16,13 +16,18 @@ RSpec.describe Projects::Security::ScannedResourcesController do
...
@@ -16,13 +16,18 @@ RSpec.describe Projects::Security::ScannedResourcesController do
end
end
describe
'GET index'
do
describe
'GET index'
do
let
(
:subject
)
{
get
:index
,
params:
action_params
,
format: :csv
}
let
(
:parsed_csv_data
)
{
CSV
.
parse
(
subject
.
body
,
headers:
true
)
}
let
(
:parsed_csv_data
)
{
CSV
.
parse
(
subject
.
body
,
headers:
true
)
}
subject
(
:request
)
{
get
:index
,
params:
action_params
,
format: :csv
}
before
do
before
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
end
context
'when DAST security scan is found'
do
context
'when DAST security scan is found'
do
before
do
before
do
create
(
:ci_build
,
:success
,
name:
'dast_job'
,
pipeline:
pipeline
,
project:
project
)
do
|
job
|
create
(
:ci_build
,
:success
,
name:
'dast_job'
,
pipeline:
pipeline
,
project:
project
)
do
|
job
|
...
...
ee/spec/controllers/projects/security/vulnerabilities/notes_controller_spec.rb
View file @
7ce3da53
...
@@ -9,14 +9,6 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -9,14 +9,6 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
let!
(
:note
)
{
create
(
:note
,
noteable:
vulnerability
,
project:
project
)
}
let!
(
:note
)
{
create
(
:note
,
noteable:
vulnerability
,
project:
project
)
}
it_behaves_like
SecurityDashboardsPermissions
do
let
(
:vulnerable
)
{
project
}
let
(
:security_dashboard_action
)
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
vulnerability_id:
vulnerability
}
end
end
before
do
before
do
stub_licensed_features
(
security_dashboard:
true
)
stub_licensed_features
(
security_dashboard:
true
)
end
end
...
@@ -31,6 +23,15 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -31,6 +23,15 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
view_all_notes
}
end
it_behaves_like
SecurityDashboardsPermissions
do
let
(
:vulnerable
)
{
project
}
let
(
:security_dashboard_action
)
{
view_all_notes
}
end
it
'responds with array of notes'
do
it
'responds with array of notes'
do
view_all_notes
view_all_notes
...
@@ -63,6 +64,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -63,6 +64,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
create_note
}
end
context
'when note is empty'
do
context
'when note is empty'
do
let
(
:note_params
)
{
{
note:
''
}
}
let
(
:note_params
)
{
{
note:
''
}
}
...
@@ -156,6 +161,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -156,6 +161,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
update_note
}
end
context
'when user is not an author of the note'
do
context
'when user is not an author of the note'
do
it
'returns status 404'
do
it
'returns status 404'
do
update_note
update_note
...
@@ -201,6 +210,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -201,6 +210,10 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
delete_note
}
end
context
'when user is not an author of the note'
do
context
'when user is not an author of the note'
do
it
'does not delete the note'
do
it
'does not delete the note'
do
expect
{
delete_note
}.
not_to
change
{
Note
.
count
}
expect
{
delete_note
}.
not_to
change
{
Note
.
count
}
...
@@ -229,6 +242,7 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -229,6 +242,7 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
end
end
describe
'POST toggle_award_emoji'
do
describe
'POST toggle_award_emoji'
do
let
(
:emoji_name
)
{
'thumbsup'
}
let
(
:request_params
)
do
let
(
:request_params
)
do
{
{
id:
note
,
id:
note
,
...
@@ -246,7 +260,9 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
...
@@ -246,7 +260,9 @@ RSpec.describe Projects::Security::Vulnerabilities::NotesController do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
let
(
:emoji_name
)
{
'thumbsup'
}
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
toggle_award_emoji
}
end
it
'creates the award emoji'
do
it
'creates the award emoji'
do
expect
{
toggle_award_emoji
}.
to
change
{
note
.
award_emoji
.
count
}.
by
(
1
)
expect
{
toggle_award_emoji
}.
to
change
{
note
.
award_emoji
.
count
}.
by
(
1
)
...
...
ee/spec/controllers/projects/security/vulnerabilities_controller_spec.rb
View file @
7ce3da53
...
@@ -7,20 +7,22 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
...
@@ -7,20 +7,22 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
render_views
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
stub_licensed_features
(
security_dashboard:
true
)
stub_licensed_features
(
security_dashboard:
true
)
sign_in
(
user
)
end
end
describe
'GET #show'
do
describe
'GET #show'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
let_it_be
(
:vulnerability
)
{
create
(
:vulnerability
,
project:
project
)
}
let_it_be
(
:vulnerability
)
{
create
(
:vulnerability
,
project:
project
)
}
render_views
subject
(
:show_vulnerability
)
{
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
vulnerability
.
id
}
}
def
show_vulnerability
include_context
'"Security & Compliance" permissions'
do
sign_in
(
user
)
let
(
:valid_request
)
{
show_vulnerability
}
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
vulnerability
.
id
}
end
end
context
"when there's an attached pipeline"
do
context
"when there's an attached pipeline"
do
...
@@ -58,11 +60,10 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
...
@@ -58,11 +60,10 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
let_it_be
(
:vulnerability
)
{
create
(
:vulnerability
,
project:
project
,
author:
user
)
}
let_it_be
(
:vulnerability
)
{
create
(
:vulnerability
,
project:
project
,
author:
user
)
}
let_it_be
(
:discussion_note
)
{
create
(
:discussion_note_on_vulnerability
,
noteable:
vulnerability
,
project:
vulnerability
.
project
)
}
let_it_be
(
:discussion_note
)
{
create
(
:discussion_note_on_vulnerability
,
noteable:
vulnerability
,
project:
vulnerability
.
project
)
}
render_views
subject
(
:show_vulnerability_discussion_list
)
{
get
:discussions
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
vulnerability
}
}
def
show_vulnerability_discussion_list
include_context
'"Security & Compliance" permissions'
do
sign_in
(
user
)
let
(
:valid_request
)
{
show_vulnerability_discussion_list
}
get
:discussions
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
vulnerability
}
end
end
it
'renders discussions'
do
it
'renders discussions'
do
...
@@ -70,7 +71,6 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
...
@@ -70,7 +71,6 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'entities/discussions'
)
expect
(
response
).
to
match_response_schema
(
'entities/discussions'
)
expect
(
json_response
.
pluck
(
'id'
)).
to
eq
([
discussion_note
.
discussion_id
])
expect
(
json_response
.
pluck
(
'id'
)).
to
eq
([
discussion_note
.
discussion_id
])
end
end
end
end
...
...
ee/spec/controllers/projects/security/vulnerability_report_controller_spec.rb
View file @
7ce3da53
...
@@ -7,6 +7,19 @@ RSpec.describe Projects::Security::VulnerabilityReportController do
...
@@ -7,6 +7,19 @@ RSpec.describe Projects::Security::VulnerabilityReportController do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_developer
(
user
)
stub_licensed_features
(
security_dashboard:
true
)
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before_request
do
sign_in
(
user
)
end
end
it_behaves_like
SecurityDashboardsPermissions
do
it_behaves_like
SecurityDashboardsPermissions
do
let
(
:vulnerable
)
{
project
}
let
(
:vulnerable
)
{
project
}
...
@@ -15,11 +28,6 @@ RSpec.describe Projects::Security::VulnerabilityReportController do
...
@@ -15,11 +28,6 @@ RSpec.describe Projects::Security::VulnerabilityReportController do
end
end
end
end
before
do
group
.
add_developer
(
user
)
stub_licensed_features
(
security_dashboard:
true
)
end
describe
'GET #index'
do
describe
'GET #index'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
...
...
ee/spec/controllers/projects/security/waf_anomalies_controller_spec.rb
View file @
7ce3da53
...
@@ -15,7 +15,7 @@ RSpec.describe Projects::Security::WafAnomaliesController do
...
@@ -15,7 +15,7 @@ RSpec.describe Projects::Security::WafAnomaliesController do
let
(
:es_client
)
{
nil
}
let
(
:es_client
)
{
nil
}
describe
'GET #summary'
do
describe
'GET #summary'
do
subject
{
get
:summary
,
params:
action_params
,
format: :json
}
subject
(
:request
)
{
get
:summary
,
params:
action_params
,
format: :json
}
before
do
before
do
stub_licensed_features
(
threat_monitoring:
true
)
stub_licensed_features
(
threat_monitoring:
true
)
...
@@ -28,6 +28,14 @@ RSpec.describe Projects::Security::WafAnomaliesController do
...
@@ -28,6 +28,14 @@ RSpec.describe Projects::Security::WafAnomaliesController do
end
end
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
group
.
add_developer
(
user
)
end
end
context
'with authorized user'
do
context
'with authorized user'
do
before
do
before
do
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
...
...
ee/spec/features/admin/admin_settings_spec.rb
View file @
7ce3da53
...
@@ -281,70 +281,52 @@ RSpec.describe 'Admin updates EE-only settings' do
...
@@ -281,70 +281,52 @@ RSpec.describe 'Admin updates EE-only settings' do
end
end
context
'sign up settings'
do
context
'sign up settings'
do
context
'when feature flag is disabled'
do
context
'when license has active user count'
do
before
do
let
(
:license
)
{
create
(
:license
,
restrictions:
{
active_user_count:
1
})
}
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
it
'does not render user cap form group'
do
visit
general_admin_application_settings_path
expect
(
page
).
not_to
have_field
(
'User cap'
)
end
end
context
'when feature flag is enabled'
do
before
do
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
tru
e
)
allow
(
License
).
to
receive
(
:current
).
and_return
(
licens
e
)
end
end
context
'when license has active user count'
do
it
'disallows entering user cap greater then license allows'
,
:js
do
let
(
:license
)
{
create
(
:license
,
restrictions:
{
active_user_count:
1
})
}
visit
general_admin_application_settings_path
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
license
)
end
it
'disallows entering user cap greater then license allows'
,
:js
do
visit
general_admin_application_settings_path
page
.
within
(
'#js-signup-settings'
)
do
page
.
within
(
'#js-signup-settings'
)
do
fill_in
'User cap'
,
with:
5
fill_in
'User cap'
,
with:
5
click_button
'Save changes'
click_button
'Save changes'
message
=
message
=
page
.
find
(
'#application_setting_new_user_signups_cap'
).
native
.
attribute
(
'validationMessage'
)
page
.
find
(
'#application_setting_new_user_signups_cap'
).
native
.
attribute
(
'validationMessage'
)
expect
(
message
).
to
eq
(
'Value must be less than or equal to 1.'
)
expect
(
message
).
to
eq
(
'Value must be less than or equal to 1.'
)
end
end
end
end
end
end
it
'changes the user cap from unlimited to 5'
do
it
'changes the user cap from unlimited to 5'
do
visit
general_admin_application_settings_path
visit
general_admin_application_settings_path
expect
(
current_settings
.
new_user_signups_cap
).
to
be_nil
expect
(
current_settings
.
new_user_signups_cap
).
to
be_nil
page
.
within
(
'#js-signup-settings'
)
do
page
.
within
(
'#js-signup-settings'
)
do
fill_in
'User cap'
,
with:
5
fill_in
'User cap'
,
with:
5
click_button
'Save changes'
click_button
'Save changes'
expect
(
current_settings
.
new_user_signups_cap
).
to
eq
(
5
)
expect
(
current_settings
.
new_user_signups_cap
).
to
eq
(
5
)
end
end
end
end
it
'changes the user cap to unlimited'
do
it
'changes the user cap to unlimited'
do
visit
general_admin_application_settings_path
visit
general_admin_application_settings_path
page
.
within
(
'#js-signup-settings'
)
do
page
.
within
(
'#js-signup-settings'
)
do
fill_in
'User cap'
,
with:
nil
fill_in
'User cap'
,
with:
nil
click_button
'Save changes'
click_button
'Save changes'
expect
(
current_settings
.
new_user_signups_cap
).
to
be_nil
expect
(
current_settings
.
new_user_signups_cap
).
to
be_nil
end
end
end
end
end
end
end
...
...
ee/spec/features/projects/audit_events_spec.rb
View file @
7ce3da53
...
@@ -42,6 +42,10 @@ RSpec.describe 'Projects > Audit Events', :js do
...
@@ -42,6 +42,10 @@ RSpec.describe 'Projects > Audit Events', :js do
allow
(
LicenseHelper
).
to
receive
(
:show_promotions?
).
and_return
(
true
)
allow
(
LicenseHelper
).
to
receive
(
:show_promotions?
).
and_return
(
true
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:response
)
{
inspect_requests
{
visit
project_audit_events_path
(
project
)
}.
first
}
end
it
'returns 200'
do
it
'returns 200'
do
reqs
=
inspect_requests
do
reqs
=
inspect_requests
do
visit
project_audit_events_path
(
project
)
visit
project_audit_events_path
(
project
)
...
...
ee/spec/features/promotion_spec.rb
View file @
7ce3da53
...
@@ -266,6 +266,10 @@ RSpec.describe 'Promotions', :js do
...
@@ -266,6 +266,10 @@ RSpec.describe 'Promotions', :js do
sign_in
(
user
)
sign_in
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:response
)
{
inspect_requests
{
visit
project_audit_events_path
(
project
)
}.
first
}
end
it
'appears on the page'
do
it
'appears on the page'
do
visit
project_audit_events_path
(
project
)
visit
project_audit_events_path
(
project
)
...
...
ee/spec/helpers/ee/user_callouts_helper_spec.rb
View file @
7ce3da53
...
@@ -351,15 +351,6 @@ RSpec.describe EE::UserCalloutsHelper do
...
@@ -351,15 +351,6 @@ RSpec.describe EE::UserCalloutsHelper do
it
{
is_expected
.
to
eq
(
false
)
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
context
'when feature flag is disabled'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
it
{
is_expected
.
to
eq
(
false
)
}
end
context
'when feature flag is enabled'
do
context
'when feature flag is enabled'
do
where
(
:new_user_signups_cap
,
:active_user_count
,
:result
)
do
where
(
:new_user_signups_cap
,
:active_user_count
,
:result
)
do
nil
|
10
|
false
nil
|
10
|
false
...
...
ee/spec/models/application_setting_spec.rb
View file @
7ce3da53
...
@@ -766,30 +766,20 @@ RSpec.describe ApplicationSetting do
...
@@ -766,30 +766,20 @@ RSpec.describe ApplicationSetting do
describe
'#should_apply_user_signup_cap?'
do
describe
'#should_apply_user_signup_cap?'
do
subject
{
setting
.
should_apply_user_signup_cap?
}
subject
{
setting
.
should_apply_user_signup_cap?
}
context
'when feature admin_new_user_signups_cap is disabled'
do
before
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:new_user_signups_cap
).
and_return
(
new_user_signups_cap
)
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
it
{
is_expected
.
to
be
false
}
end
end
context
'when feature admin_new_user_signups_cap is enabled'
do
context
'when new_user_signups_cap setting is nil'
do
before
do
let
(
:new_user_signups_cap
)
{
nil
}
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:new_user_signups_cap
).
and_return
(
new_user_signups_cap
)
end
context
'when new_user_signups_cap setting is nil'
do
let
(
:new_user_signups_cap
)
{
nil
}
it
{
is_expected
.
to
be
false
}
it
{
is_expected
.
to
be
false
}
end
end
context
'when new_user_signups_cap setting is set to any number'
do
context
'when new_user_signups_cap setting is set to any number'
do
let
(
:new_user_signups_cap
)
{
10
}
let
(
:new_user_signups_cap
)
{
10
}
it
{
is_expected
.
to
be
true
}
it
{
is_expected
.
to
be
true
}
end
end
end
end
end
end
end
ee/spec/models/ee/user_spec.rb
View file @
7ce3da53
...
@@ -107,18 +107,6 @@ RSpec.describe User do
...
@@ -107,18 +107,6 @@ RSpec.describe User do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:new_user_signups_cap
).
and_return
(
new_user_signups_cap
)
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:new_user_signups_cap
).
and_return
(
new_user_signups_cap
)
end
end
context
'when feature is disabled'
do
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
it
'does not call SetUserStatusBasedOnUserCapSettingWorker'
do
expect
(
SetUserStatusBasedOnUserCapSettingWorker
).
not_to
receive
(
:perform_async
)
create
(
:user
,
state:
'blocked_pending_approval'
)
end
end
context
'when user cap is not set'
do
context
'when user cap is not set'
do
it
'does not call SetUserStatusBasedOnUserCapSettingWorker'
do
it
'does not call SetUserStatusBasedOnUserCapSettingWorker'
do
expect
(
SetUserStatusBasedOnUserCapSettingWorker
).
not_to
receive
(
:perform_async
)
expect
(
SetUserStatusBasedOnUserCapSettingWorker
).
not_to
receive
(
:perform_async
)
...
...
ee/spec/models/instance_security_dashboard_spec.rb
View file @
7ce3da53
...
@@ -85,8 +85,24 @@ RSpec.describe InstanceSecurityDashboard do
...
@@ -85,8 +85,24 @@ RSpec.describe InstanceSecurityDashboard do
describe
'#projects'
do
describe
'#projects'
do
context
'when the user cannot read all resources'
do
context
'when the user cannot read all resources'
do
it
'returns only projects on their dashboard that they can read'
do
context
'when the `security_and_compliance` is enabled for the project'
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
)
before
do
ProjectFeature
.
update_all
(
security_and_compliance_access_level:
Featurable
::
ENABLED
)
end
it
'returns only projects on their dashboard that they can read'
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
)
end
end
context
'when the `security_and_compliance` is disabled for the project'
do
before
do
project1
.
project_feature
.
update_column
(
:security_and_compliance_access_level
,
Featurable
::
DISABLED
)
end
it
'returns only projects on their dashboard that they can read'
do
expect
(
subject
.
projects
).
to
be_empty
end
end
end
end
end
...
@@ -94,8 +110,24 @@ RSpec.describe InstanceSecurityDashboard do
...
@@ -94,8 +110,24 @@ RSpec.describe InstanceSecurityDashboard do
let
(
:project_ids
)
{
[
project1
.
id
,
project2
.
id
]
}
let
(
:project_ids
)
{
[
project1
.
id
,
project2
.
id
]
}
let
(
:user
)
{
create
(
:auditor
)
}
let
(
:user
)
{
create
(
:auditor
)
}
it
"returns all projects on the user's dashboard"
do
context
'when the `security_and_compliance` is enabled for the project'
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
,
project2
,
project3
)
before
do
ProjectFeature
.
update_all
(
security_and_compliance_access_level:
Featurable
::
ENABLED
)
end
it
"returns all projects on the user's dashboard"
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project1
,
project2
,
project3
)
end
end
context
'when the `security_and_compliance` is disabled for the project'
do
before
do
project1
.
project_feature
.
update_column
(
:security_and_compliance_access_level
,
Featurable
::
DISABLED
)
end
it
"returns only the feature enabled projects on the user's dashboard"
do
expect
(
subject
.
projects
).
to
contain_exactly
(
project2
,
project3
)
end
end
end
end
end
end
end
...
...
ee/spec/requests/callout_spec.rb
View file @
7ce3da53
...
@@ -7,7 +7,6 @@ RSpec.describe 'callout alerts' do
...
@@ -7,7 +7,6 @@ RSpec.describe 'callout alerts' do
describe
'new_user_signups_cap_reached'
do
describe
'new_user_signups_cap_reached'
do
let_it_be
(
:user
)
{
create
(
:admin
)
}
let_it_be
(
:user
)
{
create
(
:admin
)
}
let
(
:enabled
)
{
true
}
let
(
:billable_users
)
{
[
double
(
:billable_user
)]
}
let
(
:billable_users
)
{
[
double
(
:billable_user
)]
}
let
(
:help_page_href
)
{
help_page_path
(
'user/admin_area/settings/sign_up_restrictions.md'
)
}
let
(
:help_page_href
)
{
help_page_path
(
'user/admin_area/settings/sign_up_restrictions.md'
)
}
let
(
:expected_content
)
{
'Your instance has reached its user cap'
}
let
(
:expected_content
)
{
'Your instance has reached its user cap'
}
...
@@ -30,7 +29,6 @@ RSpec.describe 'callout alerts' do
...
@@ -30,7 +29,6 @@ RSpec.describe 'callout alerts' do
end
end
before
do
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
enabled
)
stub_application_setting
(
new_user_signups_cap:
1
)
stub_application_setting
(
new_user_signups_cap:
1
)
allow
(
User
).
to
receive
(
:billable
).
and_return
(
billable_users
)
allow
(
User
).
to
receive
(
:billable
).
and_return
(
billable_users
)
...
@@ -47,12 +45,6 @@ RSpec.describe 'callout alerts' do
...
@@ -47,12 +45,6 @@ RSpec.describe 'callout alerts' do
it_behaves_like
'a hidden alert'
it_behaves_like
'a hidden alert'
end
end
context
'when feature disabled'
do
let
(
:enabled
)
{
false
}
it_behaves_like
'a hidden alert'
end
context
'when user is not admin'
do
context
'when user is not admin'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
...
...
ee/spec/requests/projects/on_demand_scans_controller_spec.rb
View file @
7ce3da53
...
@@ -9,6 +9,15 @@ RSpec.describe Projects::OnDemandScansController, type: :request do
...
@@ -9,6 +9,15 @@ RSpec.describe Projects::OnDemandScansController, type: :request do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
shared_examples
'on-demand scans page'
do
shared_examples
'on-demand scans page'
do
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
path
}
before_request
do
project
.
add_developer
(
user
)
login_as
(
user
)
end
end
context
'feature available'
do
context
'feature available'
do
before
do
before
do
stub_licensed_features
(
security_on_demand_scans:
true
)
stub_licensed_features
(
security_on_demand_scans:
true
)
...
...
ee/spec/requests/projects/security/corpus_management_controller_spec.rb
View file @
7ce3da53
...
@@ -7,16 +7,24 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
...
@@ -7,16 +7,24 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
'GET #show'
do
describe
'GET #show'
do
context
'feature available'
do
before
do
before
do
stub_licensed_features
(
coverage_fuzzing:
true
)
stub_licensed_features
(
coverage_fuzzing:
true
)
login_as
(
user
)
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
project_security_configuration_corpus_management_path
(
project
)
}
before_request
do
project
.
add_developer
(
user
)
end
end
end
context
'feature available'
do
context
'user authorized'
do
context
'user authorized'
do
before
do
before
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
login_as
(
user
)
end
end
it
'can access page'
do
it
'can access page'
do
...
@@ -29,8 +37,6 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
...
@@ -29,8 +37,6 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
context
'user not authorized'
do
context
'user not authorized'
do
before
do
before
do
project
.
add_guest
(
user
)
project
.
add_guest
(
user
)
login_as
(
user
)
end
end
it
'sees a 404 error'
do
it
'sees a 404 error'
do
...
@@ -43,14 +49,13 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
...
@@ -43,14 +49,13 @@ RSpec.describe Projects::Security::CorpusManagementController, type: :request do
context
'feature not available'
do
context
'feature not available'
do
before
do
before
do
project
.
add_developer
(
user
)
stub_licensed_features
(
coverage_fuzzing:
false
)
login_as
(
user
)
project
.
add_developer
(
user
)
end
end
context
'license doesnt\'t support the feature'
do
context
'license doesnt\'t support the feature'
do
it
'sees a 404 error'
do
it
'sees a 404 error'
do
stub_licensed_features
(
coverage_fuzzing:
false
)
get
project_security_configuration_corpus_management_path
(
project
)
get
project_security_configuration_corpus_management_path
(
project
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
...
...
ee/spec/requests/projects/security/dast_profiles_controller_spec.rb
View file @
7ce3da53
...
@@ -7,16 +7,24 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
...
@@ -7,16 +7,24 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
'GET #index'
do
describe
'GET #index'
do
context
'feature available'
do
before
do
before
do
stub_licensed_features
(
security_on_demand_scans:
true
)
stub_licensed_features
(
security_on_demand_scans:
true
)
login_as
(
user
)
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
project_security_configuration_dast_profiles_path
(
project
)
}
before_request
do
project
.
add_developer
(
user
)
end
end
end
context
'feature available'
do
context
'user authorized'
do
context
'user authorized'
do
before
do
before
do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
login_as
(
user
)
end
end
it
'can access page'
do
it
'can access page'
do
...
@@ -29,8 +37,6 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
...
@@ -29,8 +37,6 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
context
'user not authorized'
do
context
'user not authorized'
do
before
do
before
do
project
.
add_guest
(
user
)
project
.
add_guest
(
user
)
login_as
(
user
)
end
end
it
'sees a 404 error'
do
it
'sees a 404 error'
do
...
@@ -43,14 +49,12 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
...
@@ -43,14 +49,12 @@ RSpec.describe Projects::Security::DastProfilesController, type: :request do
context
'feature not available'
do
context
'feature not available'
do
before
do
before
do
stub_licensed_features
(
security_on_demand_scans:
false
)
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
login_as
(
user
)
end
end
context
'license doesnt\'t support the feature'
do
context
'license doesnt\'t support the feature'
do
it
'sees a 404 error'
do
it
'sees a 404 error'
do
stub_licensed_features
(
security_on_demand_scans:
false
)
get
project_security_configuration_dast_profiles_path
(
project
)
get
project_security_configuration_dast_profiles_path
(
project
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
...
...
ee/spec/requests/projects/security/dast_scanner_profiles_controller_spec.rb
View file @
7ce3da53
...
@@ -24,6 +24,15 @@ RSpec.describe Projects::Security::DastScannerProfilesController, type: :request
...
@@ -24,6 +24,15 @@ RSpec.describe Projects::Security::DastScannerProfilesController, type: :request
end
end
shared_examples
'a GET request'
do
shared_examples
'a GET request'
do
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
path
}
before_request
do
project
.
add_developer
(
user
)
login_as
(
user
)
end
end
context
'feature available'
do
context
'feature available'
do
include_context
'on-demand scans feature available'
include_context
'on-demand scans feature available'
...
...
ee/spec/requests/projects/security/dast_site_profiles_controller_spec.rb
View file @
7ce3da53
...
@@ -17,6 +17,15 @@ RSpec.describe Projects::Security::DastSiteProfilesController, type: :request do
...
@@ -17,6 +17,15 @@ RSpec.describe Projects::Security::DastSiteProfilesController, type: :request do
end
end
shared_examples
'a GET request'
do
shared_examples
'a GET request'
do
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
get
path
}
before_request
do
with_feature_available
with_user_authorized
end
end
context
'feature available'
do
context
'feature available'
do
before
do
before
do
with_feature_available
with_feature_available
...
...
ee/spec/requests/projects/security/scanned_resources_controller_spec.rb
View file @
7ce3da53
...
@@ -12,7 +12,7 @@ RSpec.describe Projects::Security::ScannedResourcesController, type: :request do
...
@@ -12,7 +12,7 @@ RSpec.describe Projects::Security::ScannedResourcesController, type: :request do
let_it_be
(
:pipeline_id
)
{
pipeline
.
id
}
let_it_be
(
:pipeline_id
)
{
pipeline
.
id
}
let
(
:parsed_csv_data
)
{
CSV
.
parse
(
response
.
body
,
headers:
true
)
}
let
(
:parsed_csv_data
)
{
CSV
.
parse
(
response
.
body
,
headers:
true
)
}
subject
{
get
project_security_scanned_resources_path
(
project
,
:csv
,
pipeline_id:
pipeline_id
)
}
subject
(
:request
)
{
get
project_security_scanned_resources_path
(
project
,
:csv
,
pipeline_id:
pipeline_id
)
}
before
do
before
do
stub_licensed_features
(
dast:
true
,
security_dashboard:
true
)
stub_licensed_features
(
dast:
true
,
security_dashboard:
true
)
...
@@ -20,6 +20,14 @@ RSpec.describe Projects::Security::ScannedResourcesController, type: :request do
...
@@ -20,6 +20,14 @@ RSpec.describe Projects::Security::ScannedResourcesController, type: :request do
login_as
(
user
)
login_as
(
user
)
end
end
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request
}
before_request
do
project
.
add_developer
(
user
)
end
end
shared_examples
'returns a 404'
do
shared_examples
'returns a 404'
do
it
'will return a 404'
do
it
'will return a 404'
do
subject
subject
...
...
ee/spec/services/application_settings/update_service_spec.rb
View file @
7ce3da53
...
@@ -234,16 +234,6 @@ RSpec.describe ApplicationSettings::UpdateService do
...
@@ -234,16 +234,6 @@ RSpec.describe ApplicationSettings::UpdateService do
include_examples
'worker is called'
include_examples
'worker is called'
end
end
end
end
context
'when feature is disabled'
do
let
(
:opts
)
{
{
new_user_signups_cap:
10
}
}
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
include_examples
'worker is not called'
end
end
end
end
end
end
end
ee/spec/services/ee/users/build_service_spec.rb
View file @
7ce3da53
...
@@ -110,18 +110,6 @@ RSpec.describe Users::BuildService do
...
@@ -110,18 +110,6 @@ RSpec.describe Users::BuildService do
expect
(
user
).
to
be_active
expect
(
user
).
to
be_active
end
end
end
end
context
'when feature is disabled'
do
before
do
stub_feature_flags
(
admin_new_user_signups_cap:
false
)
end
it
'does not set the user state to blocked_pending_approval'
do
user
=
service
.
execute
expect
(
user
).
to
be_active
end
end
end
end
end
end
end
end
...
...
ee/spec/support/shared_contexts/security_and_compliance_permissions_shared_context.rb
0 → 100644
View file @
7ce3da53
# frozen_string_literal: true
RSpec
.
shared_context
'"Security & Compliance" permissions'
do
let
(
:project_instance
)
{
an_instance_of
(
Project
)
}
let
(
:user_instance
)
{
an_instance_of
(
User
)
}
let
(
:before_request_defined
)
{
false
}
let
(
:valid_request
)
{}
def
self
.
before_request
(
&
block
)
return
unless
block
let
(
:before_request_call
)
{
instance_exec
(
&
block
)
}
let
(
:before_request_defined
)
{
true
}
end
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
and_call_original
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user_instance
,
:access_security_and_compliance
,
project_instance
).
and_return
(
true
)
end
context
'when the "Security & Compliance" feature is disabled'
do
subject
{
response
}
before
do
before_request_call
if
before_request_defined
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user_instance
,
:access_security_and_compliance
,
project_instance
).
and_return
(
false
)
valid_request
end
it
{
is_expected
.
to
have_gitlab_http_status
(
:not_found
)
}
end
end
lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
View file @
7ce3da53
...
@@ -66,7 +66,8 @@ brakeman-sast:
...
@@ -66,7 +66,8 @@ brakeman-sast:
-
if
:
$CI_COMMIT_BRANCH &&
-
if
:
$CI_COMMIT_BRANCH &&
$SAST_DEFAULT_ANALYZERS =~ /brakeman/
$SAST_DEFAULT_ANALYZERS =~ /brakeman/
exists
:
exists
:
-
'
config/routes.rb'
-
'
**/*.rb'
-
'
**/Gemfile'
eslint-sast
:
eslint-sast
:
extends
:
.sast-analyzer
extends
:
.sast-analyzer
...
...
rubocop/rubocop-migrations.yml
View file @
7ce3da53
...
@@ -38,6 +38,7 @@ Migration/UpdateLargeTable:
...
@@ -38,6 +38,7 @@ Migration/UpdateLargeTable:
-
:users
-
:users
-
:user_preferences
-
:user_preferences
-
:user_details
-
:user_details
-
:vulnerability_occurrences
-
:web_hook_logs
-
:web_hook_logs
DeniedMethods
:
DeniedMethods
:
-
:change_column_type_concurrently
-
:change_column_type_concurrently
...
...
spec/controllers/projects/security/configuration_controller_spec.rb
View file @
7ce3da53
...
@@ -7,6 +7,8 @@ RSpec.describe Projects::Security::ConfigurationController do
...
@@ -7,6 +7,8 @@ RSpec.describe Projects::Security::ConfigurationController do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
allow
(
controller
).
to
receive
(
:ensure_security_and_compliance_enabled!
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
7ce3da53
...
@@ -537,7 +537,7 @@ RSpec.describe Ci::CreatePipelineService do
...
@@ -537,7 +537,7 @@ RSpec.describe Ci::CreatePipelineService do
it
'pull it from Auto-DevOps'
do
it
'pull it from Auto-DevOps'
do
pipeline
=
execute_service
pipeline
=
execute_service
expect
(
pipeline
).
to
be_auto_devops_source
expect
(
pipeline
).
to
be_auto_devops_source
expect
(
pipeline
.
builds
.
map
(
&
:name
)).
to
match_array
(
%w[build code_quality eslint-sast secret_detection_default_branch test]
)
expect
(
pipeline
.
builds
.
map
(
&
:name
)).
to
match_array
(
%w[b
rakeman-sast b
uild code_quality eslint-sast secret_detection_default_branch test]
)
end
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