summaryrefslogtreecommitdiff
path: root/tooling
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-02 09:11:05 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-02 09:11:05 +0000
commit3256c55b0f188227e27a4863532feee84e654911 (patch)
tree3bd6c8fa06179fd396b589c949198b98c3321e55 /tooling
parent347c7a75172d5f1e14728950fd6ce7819dfc62ab (diff)
downloadgitlab-ce-3256c55b0f188227e27a4863532feee84e654911.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rw-r--r--tooling/config/CODEOWNERS.yml21
-rw-r--r--tooling/lib/tooling/find_codeowners.rb92
2 files changed, 80 insertions, 33 deletions
diff --git a/tooling/config/CODEOWNERS.yml b/tooling/config/CODEOWNERS.yml
index 18f3abfc97b..9a3a7e8e5be 100644
--- a/tooling/config/CODEOWNERS.yml
+++ b/tooling/config/CODEOWNERS.yml
@@ -55,3 +55,24 @@
- '/lib/gitlab/conan_token.rb'
patterns:
- '%{keyword}'
+
+'[Compliance]':
+ '@gitlab-org/manage/compliance':
+ entries:
+ - '/ee/app/services/audit_events/build_service.rb'
+ - '/ee/spec/services/audit_events/custom_audit_event_service_spec.rb'
+ allow:
+ keywords:
+ - audit
+ patterns:
+ - '**%{keyword}**'
+ deny:
+ keywords:
+ - '*.png'
+ - '*bundler-audit*'
+ - '/ee/app/services/audit_events/*'
+ - '/ee/spec/services/audit_events/*'
+ - '/ee/spec/services/ci/*'
+ - '/ee/spec/services/personal_access_tokens/*'
+ patterns:
+ - '%{keyword}'
diff --git a/tooling/lib/tooling/find_codeowners.rb b/tooling/lib/tooling/find_codeowners.rb
index 3b50b33d85c..6a90f86eecc 100644
--- a/tooling/lib/tooling/find_codeowners.rb
+++ b/tooling/lib/tooling/find_codeowners.rb
@@ -9,37 +9,10 @@ module Tooling
puts section
group_defintions.each do |group, list|
- matched_files = git_ls_files.each_line.select do |line|
- list[:allow].find do |pattern|
- path = "/#{line.chomp}"
+ print_entries(group, list[:entries]) if list[:entries]
+ print_expanded_entries(group, list) if list[:allow]
- path_matches?(pattern, path) &&
- list[:deny].none? { |pattern| path_matches?(pattern, path) }
- end
- end
-
- consolidated = consolidate_paths(matched_files)
- consolidated_again = consolidate_paths(consolidated)
-
- # Consider the directory structure is a tree structure:
- # https://en.wikipedia.org/wiki/Tree_(data_structure)
- # After we consolidated the leaf entries, it could be possible that
- # we can consolidate further for the new leaves. Repeat this
- # process until we see no improvements.
- while consolidated_again.size < consolidated.size
- consolidated = consolidated_again
- consolidated_again = consolidate_paths(consolidated)
- end
-
- consolidated.each do |line|
- path = line.chomp
-
- if File.directory?(path)
- puts "/#{path}/ #{group}"
- else
- puts "/#{path} #{group}"
- end
- end
+ puts
end
end
end
@@ -50,10 +23,20 @@ module Tooling
result.each do |section, group_defintions|
group_defintions.each do |group, definitions|
definitions.transform_values! do |rules|
- rules[:keywords].flat_map do |keyword|
- rules[:patterns].map do |pattern|
- pattern % { keyword: keyword }
+ case rules
+ when Hash
+ case rules[:keywords]
+ when Array
+ rules[:keywords].flat_map do |keyword|
+ rules[:patterns].map do |pattern|
+ pattern % { keyword: keyword }
+ end
+ end
+ else
+ rules[:patterns]
end
+ when Array
+ rules
end
end
end
@@ -118,6 +101,49 @@ module Tooling
private
+ def print_entries(group, entries)
+ entries.each do |entry|
+ puts "#{entry} #{group}"
+ end
+ end
+
+ def print_expanded_entries(group, list)
+ matched_files = git_ls_files.each_line.select do |line|
+ list[:allow].find do |pattern|
+ path = "/#{line.chomp}"
+
+ path_matches?(pattern, path) &&
+ (
+ list[:deny].nil? ||
+ list[:deny].none? { |pattern| path_matches?(pattern, path) }
+ )
+ end
+ end
+
+ consolidated = consolidate_paths(matched_files)
+ consolidated_again = consolidate_paths(consolidated)
+
+ # Consider the directory structure is a tree structure:
+ # https://en.wikipedia.org/wiki/Tree_(data_structure)
+ # After we consolidated the leaf entries, it could be possible that
+ # we can consolidate further for the new leaves. Repeat this
+ # process until we see no improvements.
+ while consolidated_again.size < consolidated.size
+ consolidated = consolidated_again
+ consolidated_again = consolidate_paths(consolidated)
+ end
+
+ consolidated.each do |line|
+ path = line.chomp
+
+ if File.directory?(path)
+ puts "/#{path}/ #{group}"
+ else
+ puts "/#{path} #{group}"
+ end
+ end
+ end
+
def find_dir_maxdepth_1(dir)
`find #{dir} -maxdepth 1`
end