ci_toolkit 1.6.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 160688a62bc8bfc33855fbdff7cdad68442b2f889d2b61ff097072db98c65e6c
4
- data.tar.gz: a67225ba9ad09394dabe6f5069dfe080bde1a3765c71b1694f1197a32cc1b613
3
+ metadata.gz: bf8748ff0d666c907fac0f8bb328531e6536c49b19cd39fd99662d8aea067d8a
4
+ data.tar.gz: 79caaeae3543c703d77c8f239c3b7f37e0d86aae44f78a22c542e7694855a11a
5
5
  SHA512:
6
- metadata.gz: aa002219f7cbaf57a8677e567ef16651037a86fd7cdc127e979bcb70d625940b586ceff489f92f37655014d7b7d565c25901bd85ae5b048da2f53bd68771efee
7
- data.tar.gz: 8fc239ad0866169020e73e5b396d6fb51a9e8aa257a9b75b8727b91292041e606cc74dc80df1432e7dc90953b83be2ecf03ef3fbe57e701ca52167133640e29a
6
+ metadata.gz: 88c8227691bc19dac3d5b6c7b79a785067780d1021488035b355dcbd9f02c70250196db31410c6ff245187ab7fa1376dd98f4f07117c8a2aa208eaf60c93a261
7
+ data.tar.gz: fb4df2fe415536e4a61872a93f507da43e0378b47af051050e35b4b82fc10413c153ad065e87c6f17a3d40b2463a722f2de7a472062115b347b325d497267951
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.6.3)
4
+ ci_toolkit (1.6.4)
5
5
  faraday
6
6
  faraday-multipart
7
7
  faraday_middleware
data/RELEASING.md CHANGED
@@ -3,5 +3,5 @@
3
3
  - Bump the version number in `Gemfile.lock` to the new version.
4
4
  - Bump the version number in `ci_toolkit.gemspec` to the new version.
5
5
  - `git commit -am "Version X.Y.Z."` (where X.Y.Z is the new version).
6
- - `git tag -a X.Y.X -m "Version X.Y.Z"` (where X.Y.Z is the new version).
6
+ - `git tag -a vX.Y.X -m "Version X.Y.Z"` (where X.Y.Z is the new version).
7
7
  - `git push && git push --tags`.
data/ci_toolkit.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ci_toolkit"
5
- spec.version = "1.6.3"
5
+ spec.version = "1.6.4"
6
6
  spec.authors = ["Gero Keller"]
7
7
  spec.email = ["gero.f.keller@gmail.com"]
8
8
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CiToolkit
4
+ # util class to get actual valid list of build types
5
+ class BuildTypes
6
+ # get actual valid list of build types
7
+ def get_build_types(build_types_arr, comments, labels)
8
+ types = []
9
+ build_types_arr.each do |type|
10
+ if comments.include?("#{type} build") || labels.include?("#{type} build") ||
11
+ comments.include?(type) || labels.include?(type)
12
+ types.push(type)
13
+ end
14
+ end
15
+ types
16
+ end
17
+ end
18
+ end
@@ -98,6 +98,10 @@ module CiToolkit
98
98
  CiToolkit::DvcsPr.api_not_implemented(self)
99
99
  end
100
100
 
101
+ def certificate_pinning_logic_modified?
102
+ CiToolkit::DvcsPr.api_not_implemented(self)
103
+ end
104
+
101
105
  def get_status_description(_context)
102
106
  CiToolkit::DvcsPr.api_not_implemented(self)
103
107
  end
@@ -18,6 +18,8 @@ module CiToolkit
18
18
  @_client = client
19
19
  @build_types = build_types
20
20
  @bot = CiToolkit::GithubBot.new
21
+ @changes_detector = GithubSpecificFilesChangesDetector.new
22
+ @build_types_getter = CiToolkit::BuildTypes.new
21
23
  end
22
24
 
23
25
  def title
@@ -83,14 +85,7 @@ module CiToolkit
83
85
  end
84
86
 
85
87
  def build_types
86
- types = []
87
- @build_types.each do |type|
88
- if comments.include?("#{type} build") || labels.include?("#{type} build") ||
89
- comments.include?(type) || labels.include?(type)
90
- types.push(type)
91
- end
92
- end
93
- types
88
+ @build_types_getter.get_build_types(@build_types, comments, labels)
94
89
  end
95
90
 
96
91
  def infrastructure_work?
@@ -106,8 +101,11 @@ module CiToolkit
106
101
  end
107
102
 
108
103
  def realm_module_modified?
109
- modified_files = files.select { |file| file[:filename]&.start_with? "cache/" }
110
- modified_files.length.positive?
104
+ @changes_detector.realm_module_modified(files)
105
+ end
106
+
107
+ def certificate_pinning_logic_modified?
108
+ @changes_detector.certificate_pinning_logic_modified(files)
111
109
  end
112
110
 
113
111
  def get_status_description(context)
@@ -126,4 +124,30 @@ module CiToolkit
126
124
  @_client
127
125
  end
128
126
  end
127
+
128
+ # util class to verify modifications in app files that may have been broken in the past
129
+ class GithubSpecificFilesChangesDetector
130
+ def realm_module_modified(files)
131
+ modified_files = files.select { |file| file[:filename]&.start_with? "cache/" }
132
+ modified_files.length.positive?
133
+ end
134
+
135
+ def certificate_pinning_logic_modified(files)
136
+ modified_files = files.select do |file|
137
+ contains_substring(file[:filename],
138
+ %w[HttpClientFactory SecurePreferences CertificatePinningConfiguration SSLPinner
139
+ CertificateDateChecker])
140
+ end
141
+ modified_files.length.positive?
142
+ end
143
+
144
+ private
145
+
146
+ def contains_substring(input_string, substrings)
147
+ return false if input_string.nil?
148
+
149
+ regex = Regexp.union(substrings.map { |s| Regexp.new(s, Regexp::IGNORECASE) })
150
+ !!(input_string =~ regex)
151
+ end
152
+ end
129
153
  end
@@ -20,6 +20,8 @@ module CiToolkit
20
20
  @_client = bot.client
21
21
  @build_types = build_types
22
22
  @bot = bot
23
+ @changes_detector = GitlabSpecificFilesChangesDetector.new
24
+ @build_types_getter = CiToolkit::BuildTypes.new
23
25
  end
24
26
 
25
27
  def title
@@ -86,14 +88,7 @@ module CiToolkit
86
88
  end
87
89
 
88
90
  def build_types
89
- types = []
90
- @build_types.each do |type|
91
- if comments.include?("#{type} build") || labels.include?("#{type} build") ||
92
- comments.include?(type) || labels.include?(type)
93
- types.push(type)
94
- end
95
- end
96
- types
91
+ @build_types_getter.get_build_types(@build_types, comments, labels)
97
92
  end
98
93
 
99
94
  def infrastructure_work?
@@ -109,8 +104,11 @@ module CiToolkit
109
104
  end
110
105
 
111
106
  def realm_module_modified?
112
- modified_files = files.select { |file| file&.old_path&.start_with? "cache/" }
113
- modified_files.length.positive?
107
+ @changes_detector.realm_module_modified(files)
108
+ end
109
+
110
+ def certificate_pinning_logic_modified?
111
+ @changes_detector.certificate_pinning_logic_modified(files)
114
112
  end
115
113
 
116
114
  def get_status_description(context)
@@ -127,4 +125,30 @@ module CiToolkit
127
125
  @_client
128
126
  end
129
127
  end
128
+
129
+ # util class to verify modifications in app files that may have been broken in the past
130
+ class GitlabSpecificFilesChangesDetector
131
+ def realm_module_modified(files)
132
+ modified_files = files.select { |file| file&.old_path&.start_with? "cache/" }
133
+ modified_files.length.positive?
134
+ end
135
+
136
+ def certificate_pinning_logic_modified(files)
137
+ modified_files = files.select do |file|
138
+ contains_substring(file&.old_path,
139
+ %w[HttpClientFactory SecurePreferences CertificatePinningConfiguration SSLPinner
140
+ CertificateDateChecker])
141
+ end
142
+ modified_files.length.positive?
143
+ end
144
+
145
+ private
146
+
147
+ def contains_substring(input_string, substrings)
148
+ return false if input_string.nil?
149
+
150
+ regex = Regexp.union(substrings.map { |s| Regexp.new(s, Regexp::IGNORECASE) })
151
+ !!(input_string =~ regex)
152
+ end
153
+ end
130
154
  end
@@ -55,6 +55,15 @@ module CiToolkit
55
55
  delete(@messenger_text.realm_modified_warning_title)
56
56
  end
57
57
 
58
+ def send_certificate_pinning_modified_android_warning
59
+ delete_certificate_pinning_modified_android_warning
60
+ send(@messenger_text.certificate_pinning_logic_modified_android_title)
61
+ end
62
+
63
+ def delete_certificate_pinning_modified_android_warning
64
+ delete(@messenger_text.certificate_pinning_logic_modified_android_title)
65
+ end
66
+
58
67
  def send_big_pr_warning
59
68
  delete_big_pr_warning
60
69
  send(@messenger_text.big_pr_warning_title)
@@ -45,6 +45,13 @@ module CiToolkit
45
45
  warning_with_message("Realm module modified. Did you remember to add migrations?")
46
46
  end
47
47
 
48
+ def certificate_pinning_logic_modified_android_title
49
+ warning_with_message("Detected modifications in Certificate pinning related files " \
50
+ "(HttpClientFactory / SecurePreferences / CertificatePinningConfiguration / " \
51
+ "SSLPinner / CertificateDateChecker). If you are doing temporary changes " \
52
+ "to pinning, do not merge this MR until you revert them!")
53
+ end
54
+
48
55
  def big_pr_warning_title
49
56
  warning_with_message("Big PR")
50
57
  end
data/lib/ci_toolkit.rb CHANGED
@@ -18,6 +18,7 @@ require "ci_toolkit/jira"
18
18
  require "ci_toolkit/pr_messenger"
19
19
  require "ci_toolkit/pr_messenger_text"
20
20
  require "ci_toolkit/bitrise_client"
21
+ require "ci_toolkit/build_types"
21
22
 
22
23
  module CiToolkit
23
24
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gero Keller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-25 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -238,6 +238,7 @@ files:
238
238
  - lib/ci_toolkit/bitrise_env.rb
239
239
  - lib/ci_toolkit/build.rb
240
240
  - lib/ci_toolkit/build_status.rb
241
+ - lib/ci_toolkit/build_types.rb
241
242
  - lib/ci_toolkit/duplicate_files_finder.rb
242
243
  - lib/ci_toolkit/dvcs_pr.rb
243
244
  - lib/ci_toolkit/dvcs_pr_factory.rb
@@ -277,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
278
  - !ruby/object:Gem::Version
278
279
  version: '0'
279
280
  requirements: []
280
- rubygems_version: 3.4.10
281
+ rubygems_version: 3.4.19
281
282
  signing_key:
282
283
  specification_version: 4
283
284
  summary: Set of CI utilities