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
ddb1e2f9
Commit
ddb1e2f9
authored
Jul 08, 2020
by
Sam Kerr
Committed by
Markus Koller
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report all unique users for Secure scanners
Review comments
parent
26c00c8e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
6 deletions
+63
-6
changelogs/unreleased/update-secure-smau-metric.yml
changelogs/unreleased/update-secure-smau-metric.yml
+5
-0
db/post_migrate/20200618152212_update_secure_smau_index.rb
db/post_migrate/20200618152212_update_secure_smau_index.rb
+23
-0
db/structure.sql
db/structure.sql
+3
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+2
-0
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+30
-6
No files found.
changelogs/unreleased/update-secure-smau-metric.yml
0 → 100644
View file @
ddb1e2f9
---
title
:
Report all unique users for Secure scanners
merge_request
:
33881
author
:
type
:
changed
db/post_migrate/20200618152212_update_secure_smau_index.rb
0 → 100644
View file @
ddb1e2f9
# frozen_string_literal: true
class
UpdateSecureSmauIndex
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
INDEX_NAME
=
'index_secure_ci_builds_on_user_id_created_at'
disable_ddl_transaction!
def
up
add_concurrent_index
(
:ci_builds
,
[
:user_id
,
:created_at
],
where:
"(((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text])))"
,
name:
INDEX_NAME
)
end
def
down
remove_concurrent_index_by_name
:ci_builds
,
INDEX_NAME
end
end
db/structure.sql
View file @
ddb1e2f9
...
...
@@ -20079,6 +20079,8 @@ CREATE UNIQUE INDEX index_scim_identities_on_user_id_and_group_id ON public.scim
CREATE
UNIQUE
INDEX
index_scim_oauth_access_tokens_on_group_id_and_token_encrypted
ON
public
.
scim_oauth_access_tokens
USING
btree
(
group_id
,
token_encrypted
);
CREATE
INDEX
index_secure_ci_builds_on_user_id_created_at
ON
public
.
ci_builds
USING
btree
(
user_id
,
created_at
)
WHERE
(((
type
)::
text
=
'Ci::Build'
::
text
)
AND
((
name
)::
text
=
ANY
(
ARRAY
[(
'container_scanning'
::
character
varying
)::
text
,
(
'dast'
::
character
varying
)::
text
,
(
'dependency_scanning'
::
character
varying
)::
text
,
(
'license_management'
::
character
varying
)::
text
,
(
'license_scanning'
::
character
varying
)::
text
,
(
'sast'
::
character
varying
)::
text
,
(
'secret_detection'
::
character
varying
)::
text
])));
CREATE
INDEX
index_security_ci_builds_on_name_and_id
ON
public
.
ci_builds
USING
btree
(
name
,
id
)
WHERE
(((
name
)::
text
=
ANY
(
ARRAY
[(
'container_scanning'
::
character
varying
)::
text
,
(
'dast'
::
character
varying
)::
text
,
(
'dependency_scanning'
::
character
varying
)::
text
,
(
'license_management'
::
character
varying
)::
text
,
(
'sast'
::
character
varying
)::
text
,
(
'secret_detection'
::
character
varying
)::
text
,
(
'license_scanning'
::
character
varying
)::
text
]))
AND
((
type
)::
text
=
'Ci::Build'
::
text
));
CREATE
INDEX
index_self_managed_prometheus_alert_events_on_environment_id
ON
public
.
self_managed_prometheus_alert_events
USING
btree
(
environment_id
);
...
...
@@ -23560,6 +23562,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200618105638
20200618134223
20200618134723
20200618152212
20200619000316
20200619154527
20200619154528
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
ddb1e2f9
...
...
@@ -330,6 +330,8 @@ module EE
finish:
user_maximum_id
)
end
results
[
:"
#{
prefix
}
unique_users_all_secure_scanners"
]
=
distinct_count
(
::
Ci
::
Build
.
where
(
name:
SECURE_PRODUCT_TYPES
.
keys
).
where
(
time_period
),
:user_id
)
# handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
combined_license_key
=
"
#{
prefix
}
license_management_jobs"
.
to_sym
license_scan_count
=
results
.
delete
(
"
#{
prefix
}
license_scanning_jobs"
.
to_sym
)
...
...
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
ddb1e2f9
...
...
@@ -526,6 +526,8 @@ RSpec.describe Gitlab::UsageData do
context
'for secure'
do
let_it_be
(
:user
)
{
create
(
:user
,
group_view: :security_dashboard
)
}
let_it_be
(
:user2
)
{
create
(
:user
,
group_view: :security_dashboard
)
}
let_it_be
(
:user3
)
{
create
(
:user
,
group_view: :security_dashboard
)
}
before
do
for_defined_days_back
do
...
...
@@ -540,13 +542,33 @@ RSpec.describe Gitlab::UsageData do
it
'includes accurate usage_activity_by_stage data'
do
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:secure
]).
to
eq
(
user_preferences_group_overview_security_dashboard:
1
,
user_preferences_group_overview_security_dashboard:
3
,
user_container_scanning_jobs:
1
,
user_dast_jobs:
1
,
user_dependency_scanning_jobs:
1
,
user_license_management_jobs:
1
,
user_sast_jobs:
1
,
user_secret_detection_jobs:
1
user_secret_detection_jobs:
1
,
user_unique_users_all_secure_scanners:
1
)
end
it
'counts unique users correctly across multiple scanners'
do
for_defined_days_back
do
create
(
:ci_build
,
name:
'sast'
,
user:
user2
)
create
(
:ci_build
,
name:
'dast'
,
user:
user2
)
create
(
:ci_build
,
name:
'dast'
,
user:
user3
)
end
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:secure
]).
to
eq
(
user_preferences_group_overview_security_dashboard:
3
,
user_container_scanning_jobs:
1
,
user_dast_jobs:
3
,
user_dependency_scanning_jobs:
1
,
user_license_management_jobs:
1
,
user_sast_jobs:
2
,
user_secret_detection_jobs:
1
,
user_unique_users_all_secure_scanners:
3
)
end
...
...
@@ -556,13 +578,14 @@ RSpec.describe Gitlab::UsageData do
end
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:secure
]).
to
eq
(
user_preferences_group_overview_security_dashboard:
1
,
user_preferences_group_overview_security_dashboard:
3
,
user_container_scanning_jobs:
1
,
user_dast_jobs:
1
,
user_dependency_scanning_jobs:
1
,
user_license_management_jobs:
2
,
user_sast_jobs:
1
,
user_secret_detection_jobs:
1
user_secret_detection_jobs:
1
,
user_unique_users_all_secure_scanners:
1
)
end
...
...
@@ -571,13 +594,14 @@ RSpec.describe Gitlab::UsageData do
allow
(
::
Ci
::
Build
).
to
receive
(
:distinct_count_by
).
and_raise
(
ActiveRecord
::
StatementInvalid
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:secure
]).
to
eq
(
user_preferences_group_overview_security_dashboard:
1
,
user_preferences_group_overview_security_dashboard:
3
,
user_container_scanning_jobs:
-
1
,
user_dast_jobs:
-
1
,
user_dependency_scanning_jobs:
-
1
,
user_license_management_jobs:
-
1
,
user_sast_jobs:
-
1
,
user_secret_detection_jobs:
-
1
user_secret_detection_jobs:
-
1
,
user_unique_users_all_secure_scanners:
-
1
)
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