gitlab-username_bot_identifier 1.0.4 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gitlab-username_bot_identifier.gemspec +1 -1
- data/lib/gitlab/username_bot_identifier.rb +20 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0810c40de2bcbf8e926752377d842353154e34d7c666571cad926b5289bc7c6a'
|
4
|
+
data.tar.gz: 8353de435d72394df7b10d14907276c64eb8ac64477ad2f1b03ef1098eba4cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b102e2ce6232f88c722cbcbc2c9d3ef7bf25a01320c8ee198cabf10ee354a511acb9bdaa89b44fdc29488ba40289e1a69631339cb5ba8d0652380e4c1aa9395a
|
7
|
+
data.tar.gz: 1385b9106b4428e9b65d2fa2d936963d2451a264bb3a2976251df360a94ff8e78c91625c1503534bca485f2492ae6ec52ed084677cd19751dbe551a50c11e6e9
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
17
|
spec.metadata['source_code_uri'] = 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-username-bot-identifier'
|
18
|
-
spec.metadata['changelog_uri'] = 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-
|
18
|
+
spec.metadata['changelog_uri'] = 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-username_bot_identifier/-/releases'
|
19
19
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
20
|
|
21
21
|
spec.files = [
|
@@ -32,9 +32,10 @@ module Gitlab
|
|
32
32
|
# Can be spoofed (e.g. someone can register project_1_bot, project_2_bot_abc123)
|
33
33
|
PROJECT_ACCESS_TOKEN_REGEX = /^project_\d+_bot_?\w*$/.freeze
|
34
34
|
GROUP_ACCESS_TOKEN_REGEX = /^group_\d+_bot_?\w*$/.freeze
|
35
|
+
SERVICE_ACCOUNT_REGEX = /^service_account_group_\d+_?\w*$/.freeze
|
35
36
|
|
36
|
-
# Used as best
|
37
|
-
|
37
|
+
# Used as best practice by GitLab team members when creating "service accounts"
|
38
|
+
KNOWN_SERVICE_ACCOUNT_REGEX = /^gl-service-[-\w]+$/.freeze
|
38
39
|
|
39
40
|
def initialize(username)
|
40
41
|
@username = username
|
@@ -52,8 +53,11 @@ module Gitlab
|
|
52
53
|
username == GHOST_ACCOUNT
|
53
54
|
end
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
# "known service accounts" are accounts that match the naming convention of service accounts
|
57
|
+
# registered by GitLab team members. These accounts are regular user accounts that are used
|
58
|
+
# in automations.
|
59
|
+
def known_service_account?
|
60
|
+
username.match?(KNOWN_SERVICE_ACCOUNT_REGEX)
|
57
61
|
end
|
58
62
|
|
59
63
|
def project_access_token?
|
@@ -64,6 +68,12 @@ module Gitlab
|
|
64
68
|
username.match?(GROUP_ACCESS_TOKEN_REGEX)
|
65
69
|
end
|
66
70
|
|
71
|
+
# "service accounts" are accounts that were created through the service accounts feature.
|
72
|
+
# See https://docs.gitlab.com/ee/user/profile/service_accounts.html
|
73
|
+
def service_account?
|
74
|
+
username.match?(SERVICE_ACCOUNT_REGEX)
|
75
|
+
end
|
76
|
+
|
67
77
|
def project_or_group_access_token?
|
68
78
|
project_access_token? ||
|
69
79
|
group_access_token?
|
@@ -71,15 +81,17 @@ module Gitlab
|
|
71
81
|
|
72
82
|
def bot?
|
73
83
|
known_bot? ||
|
74
|
-
|
75
|
-
project_or_group_access_token?
|
84
|
+
known_service_account? ||
|
85
|
+
project_or_group_access_token? ||
|
86
|
+
service_account?
|
76
87
|
end
|
77
88
|
|
78
89
|
def ignorable_account?
|
79
90
|
known_bot? ||
|
80
91
|
ghost? ||
|
81
|
-
|
82
|
-
project_or_group_access_token?
|
92
|
+
known_service_account? ||
|
93
|
+
project_or_group_access_token? ||
|
94
|
+
service_account?
|
83
95
|
end
|
84
96
|
end
|
85
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-username_bot_identifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Tickett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -25,7 +25,7 @@ licenses:
|
|
25
25
|
metadata:
|
26
26
|
homepage_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-username_bot_identifier
|
27
27
|
source_code_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-username-bot-identifier
|
28
|
-
changelog_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-
|
28
|
+
changelog_uri: https://gitlab.com/gitlab-org/ruby/gems/gitlab-username_bot_identifier/-/releases
|
29
29
|
rubygems_mfa_required: 'true'
|
30
30
|
post_install_message:
|
31
31
|
rdoc_options: []
|
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.3.
|
45
|
+
rubygems_version: 3.3.27
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Parse GitLab usernames to determine whether they appear to be bots.
|