dbotquery 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +10 -0
  3. data/.idea/dbotquery.iml +130 -0
  4. data/.idea/dictionaries/project.xml +9 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/runConfigurations/Specs.xml +33 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.reek.yml +8 -0
  9. data/CHANGELOG.md +5 -0
  10. data/CODE_OF_CONDUCT.md +10 -0
  11. data/LICENSE.txt +21 -0
  12. data/NOTES.md +38 -0
  13. data/README.md +34 -0
  14. data/Rakefile +32 -0
  15. data/Steepfile +25 -0
  16. data/exe/dbotquery +8 -0
  17. data/lib/d_bot_query/cli.rb +74 -0
  18. data/lib/d_bot_query/commands/command_base.rb +51 -0
  19. data/lib/d_bot_query/commands/package_search_command.rb +40 -0
  20. data/lib/d_bot_query/commands/repo_sla_statistics_command.rb +52 -0
  21. data/lib/d_bot_query/commands/sla_statistics_command.rb +62 -0
  22. data/lib/d_bot_query/commands/summary_command.rb +51 -0
  23. data/lib/d_bot_query/models/alert.rb +40 -0
  24. data/lib/d_bot_query/models/alert_collection.rb +89 -0
  25. data/lib/d_bot_query/models/base.rb +128 -0
  26. data/lib/d_bot_query/models/cvss.rb +11 -0
  27. data/lib/d_bot_query/models/cwe.rb +8 -0
  28. data/lib/d_bot_query/models/data_file.rb +30 -0
  29. data/lib/d_bot_query/models/dependency.rb +12 -0
  30. data/lib/d_bot_query/models/package.rb +23 -0
  31. data/lib/d_bot_query/models/reference.rb +11 -0
  32. data/lib/d_bot_query/models/repository.rb +42 -0
  33. data/lib/d_bot_query/models/security_advisory.rb +22 -0
  34. data/lib/d_bot_query/models/security_vulnerability.rb +19 -0
  35. data/lib/d_bot_query/models/vulnerability_identifier.rb +14 -0
  36. data/lib/d_bot_query/version.rb +6 -0
  37. data/lib/dbotquery.rb +79 -0
  38. data/lib/schema.json +1255 -0
  39. data/rbs_collection.lock.yaml +316 -0
  40. data/rbs_collection.yaml +19 -0
  41. data/sig/d_bot_query/cli.rbs +26 -0
  42. data/sig/d_bot_query/commands/command_base.rbs +18 -0
  43. data/sig/d_bot_query/commands/package_search_command.rbs +11 -0
  44. data/sig/d_bot_query/commands/repo_sla_statistics_command.rbs +9 -0
  45. data/sig/d_bot_query/commands/sla_statistics_command.rbs +11 -0
  46. data/sig/d_bot_query/commands/summary_command.rbs +15 -0
  47. data/sig/d_bot_query/models/alert.rbs +17 -0
  48. data/sig/d_bot_query/models/alert_collection.rbs +41 -0
  49. data/sig/d_bot_query/models/base.rbs +39 -0
  50. data/sig/d_bot_query/models/data_file.rbs +21 -0
  51. data/sig/d_bot_query/models/dependency.rbs +7 -0
  52. data/sig/d_bot_query/models/package.rbs +10 -0
  53. data/sig/d_bot_query/models/repository.rbs +11 -0
  54. data/sig/d_bot_query/models/security_advisory.rbs +9 -0
  55. data/sig/d_bot_query.rbs +14 -0
  56. data/sig/gems/json-schema.rbs +5 -0
  57. metadata +157 -0
@@ -0,0 +1,316 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: activemodel
5
+ version: '7.1'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: activesupport
13
+ version: '7.0'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: addressable
21
+ version: '2.8'
22
+ source:
23
+ type: git
24
+ name: ruby/gem_rbs_collection
25
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
26
+ remote: https://github.com/ruby/gem_rbs_collection.git
27
+ repo_dir: gems
28
+ - name: ast
29
+ version: '2.4'
30
+ source:
31
+ type: git
32
+ name: ruby/gem_rbs_collection
33
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
34
+ remote: https://github.com/ruby/gem_rbs_collection.git
35
+ repo_dir: gems
36
+ - name: base64
37
+ version: 0.3.0
38
+ source:
39
+ type: rubygems
40
+ - name: bigdecimal
41
+ version: 4.1.2
42
+ source:
43
+ type: rubygems
44
+ - name: concurrent-ruby
45
+ version: '1.1'
46
+ source:
47
+ type: git
48
+ name: ruby/gem_rbs_collection
49
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
50
+ remote: https://github.com/ruby/gem_rbs_collection.git
51
+ repo_dir: gems
52
+ - name: connection_pool
53
+ version: '2.4'
54
+ source:
55
+ type: git
56
+ name: ruby/gem_rbs_collection
57
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
58
+ remote: https://github.com/ruby/gem_rbs_collection.git
59
+ repo_dir: gems
60
+ - name: csv
61
+ version: '3.3'
62
+ source:
63
+ type: git
64
+ name: ruby/gem_rbs_collection
65
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
66
+ remote: https://github.com/ruby/gem_rbs_collection.git
67
+ repo_dir: gems
68
+ - name: date
69
+ version: '0'
70
+ source:
71
+ type: stdlib
72
+ - name: diff-lcs
73
+ version: '1.5'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: digest
81
+ version: '0'
82
+ source:
83
+ type: stdlib
84
+ - name: erb
85
+ version: '0'
86
+ source:
87
+ type: stdlib
88
+ - name: ffi
89
+ version: 1.17.4
90
+ source:
91
+ type: rubygems
92
+ - name: fileutils
93
+ version: '0'
94
+ source:
95
+ type: stdlib
96
+ - name: forwardable
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: i18n
101
+ version: '1.10'
102
+ source:
103
+ type: git
104
+ name: ruby/gem_rbs_collection
105
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
106
+ remote: https://github.com/ruby/gem_rbs_collection.git
107
+ repo_dir: gems
108
+ - name: io-console
109
+ version: '0'
110
+ source:
111
+ type: stdlib
112
+ - name: json
113
+ version: '0'
114
+ source:
115
+ type: stdlib
116
+ - name: language_server-protocol
117
+ version: 3.17.0.6
118
+ source:
119
+ type: rubygems
120
+ - name: lint_roller
121
+ version: '1.1'
122
+ source:
123
+ type: git
124
+ name: ruby/gem_rbs_collection
125
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
126
+ remote: https://github.com/ruby/gem_rbs_collection.git
127
+ repo_dir: gems
128
+ - name: listen
129
+ version: '3.9'
130
+ source:
131
+ type: git
132
+ name: ruby/gem_rbs_collection
133
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
134
+ remote: https://github.com/ruby/gem_rbs_collection.git
135
+ repo_dir: gems
136
+ - name: logger
137
+ version: '1.7'
138
+ source:
139
+ type: git
140
+ name: ruby/gem_rbs_collection
141
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
142
+ remote: https://github.com/ruby/gem_rbs_collection.git
143
+ repo_dir: gems
144
+ - name: minitest
145
+ version: '5.25'
146
+ source:
147
+ type: git
148
+ name: ruby/gem_rbs_collection
149
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
150
+ remote: https://github.com/ruby/gem_rbs_collection.git
151
+ repo_dir: gems
152
+ - name: monitor
153
+ version: '0'
154
+ source:
155
+ type: stdlib
156
+ - name: openssl
157
+ version: '0'
158
+ source:
159
+ type: stdlib
160
+ - name: optparse
161
+ version: '0'
162
+ source:
163
+ type: stdlib
164
+ - name: parallel
165
+ version: '1.20'
166
+ source:
167
+ type: git
168
+ name: ruby/gem_rbs_collection
169
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
170
+ remote: https://github.com/ruby/gem_rbs_collection.git
171
+ repo_dir: gems
172
+ - name: parser
173
+ version: '3.2'
174
+ source:
175
+ type: git
176
+ name: ruby/gem_rbs_collection
177
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
178
+ remote: https://github.com/ruby/gem_rbs_collection.git
179
+ repo_dir: gems
180
+ - name: prism
181
+ version: 1.9.0
182
+ source:
183
+ type: rubygems
184
+ - name: rainbow
185
+ version: '3.0'
186
+ source:
187
+ type: git
188
+ name: ruby/gem_rbs_collection
189
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
190
+ remote: https://github.com/ruby/gem_rbs_collection.git
191
+ repo_dir: gems
192
+ - name: rake
193
+ version: '13.0'
194
+ source:
195
+ type: git
196
+ name: ruby/gem_rbs_collection
197
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
198
+ remote: https://github.com/ruby/gem_rbs_collection.git
199
+ repo_dir: gems
200
+ - name: random-formatter
201
+ version: '0'
202
+ source:
203
+ type: stdlib
204
+ - name: rbs
205
+ version: 4.0.3
206
+ source:
207
+ type: rubygems
208
+ - name: rbs-inline
209
+ version: 0.14.0
210
+ source:
211
+ type: rubygems
212
+ - name: rdoc
213
+ version: '0'
214
+ source:
215
+ type: stdlib
216
+ - name: regexp_parser
217
+ version: '2.8'
218
+ source:
219
+ type: git
220
+ name: ruby/gem_rbs_collection
221
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
222
+ remote: https://github.com/ruby/gem_rbs_collection.git
223
+ repo_dir: gems
224
+ - name: ripper
225
+ version: '0'
226
+ source:
227
+ type: stdlib
228
+ - name: rubocop
229
+ version: '1.57'
230
+ source:
231
+ type: git
232
+ name: ruby/gem_rbs_collection
233
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
234
+ remote: https://github.com/ruby/gem_rbs_collection.git
235
+ repo_dir: gems
236
+ - name: rubocop-ast
237
+ version: '1.46'
238
+ source:
239
+ type: git
240
+ name: ruby/gem_rbs_collection
241
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
242
+ remote: https://github.com/ruby/gem_rbs_collection.git
243
+ repo_dir: gems
244
+ - name: rubocop-yard
245
+ version: 1.3.0
246
+ source:
247
+ type: rubygems
248
+ - name: securerandom
249
+ version: '0'
250
+ source:
251
+ type: stdlib
252
+ - name: simplecov
253
+ version: '0.22'
254
+ source:
255
+ type: git
256
+ name: ruby/gem_rbs_collection
257
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
258
+ remote: https://github.com/ruby/gem_rbs_collection.git
259
+ repo_dir: gems
260
+ - name: singleton
261
+ version: '0'
262
+ source:
263
+ type: stdlib
264
+ - name: socket
265
+ version: '0'
266
+ source:
267
+ type: stdlib
268
+ - name: stringio
269
+ version: '0'
270
+ source:
271
+ type: stdlib
272
+ - name: strscan
273
+ version: '0'
274
+ source:
275
+ type: stdlib
276
+ - name: thor
277
+ version: '1.2'
278
+ source:
279
+ type: git
280
+ name: ruby/gem_rbs_collection
281
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
282
+ remote: https://github.com/ruby/gem_rbs_collection.git
283
+ repo_dir: gems
284
+ - name: time
285
+ version: '0'
286
+ source:
287
+ type: stdlib
288
+ - name: timeout
289
+ version: '0'
290
+ source:
291
+ type: stdlib
292
+ - name: tsort
293
+ version: '0'
294
+ source:
295
+ type: stdlib
296
+ - name: tzinfo
297
+ version: '2.0'
298
+ source:
299
+ type: git
300
+ name: ruby/gem_rbs_collection
301
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
302
+ remote: https://github.com/ruby/gem_rbs_collection.git
303
+ repo_dir: gems
304
+ - name: uri
305
+ version: '0'
306
+ source:
307
+ type: stdlib
308
+ - name: yard
309
+ version: '0.9'
310
+ source:
311
+ type: git
312
+ name: ruby/gem_rbs_collection
313
+ revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
314
+ remote: https://github.com/ruby/gem_rbs_collection.git
315
+ repo_dir: gems
316
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,19 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ # gems:
17
+ # # If you want to avoid installing rbs files for gems, you can specify them here.
18
+ # - name: GEM_NAME
19
+ # ignore: true
@@ -0,0 +1,26 @@
1
+ module DBotQuery
2
+ class CLI < Thor
3
+ # These are fixups for Thor missing annotations
4
+ def self.long_desc: (String) -> void
5
+
6
+ def self.exit_on_failure?: -> bool
7
+
8
+ @command: Commands::CommandBase
9
+
10
+ def package_search: -> void
11
+
12
+ def repo_sla_stats: -> void
13
+
14
+ def sla_stats: -> void
15
+
16
+ def summary: -> void
17
+
18
+ private
19
+
20
+ def color_enabled?: -> bool
21
+
22
+ def parse_time: (String?) -> Time
23
+
24
+ def run!: (Commands::CommandBase) -> void
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module DBotQuery
2
+ module Commands
3
+ class CommandBase
4
+ type output = Hash[String, untyped] | Array[String] | Hash[Symbol, untyped]
5
+
6
+ @result: output
7
+
8
+ attr_reader result: output
9
+
10
+ def initialize: () -> void
11
+
12
+ def execute!: (String file) -> void
13
+
14
+ def perform: (Models::DataFile) -> untyped
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,11 @@
1
+ module DBotQuery
2
+ module Commands
3
+ class PackageSearchCommand < CommandBase
4
+ attr_reader package: String
5
+
6
+ def initialize: (package: String) -> void
7
+
8
+ def perform: (Models::DataFile) -> Array[String]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module DBotQuery
2
+ module Commands
3
+ class RepoSLAStatisticsCommand < CommandBase
4
+ @time: Time
5
+
6
+ def initialize: (?time: Time?) -> void
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module DBotQuery
2
+ module Commands
3
+ class SLAStatisticsCommand < CommandBase
4
+ @time: Time
5
+
6
+ def initialize: (?time: Time?) -> void
7
+
8
+ def perform: (Models::DataFile) -> ActiveSupport::HashWithIndifferentAccess[Models::AlertCollection::sum_type, Integer]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module DBotQuery
2
+ module Commands
3
+ class SummaryCommand < CommandBase
4
+ attr_reader severity: Models::SecurityAdvisory::severity?
5
+ attr_reader state: Models::Alert::state?
6
+
7
+ @severity: Models::SecurityAdvisory::severity?
8
+ @state: Models::Alert::state?
9
+
10
+ def initialize: (state: Models::Alert::state?, severity: Models::SecurityAdvisory::severity?) -> void
11
+
12
+ def perform: (Models::DataFile) -> { count: Integer }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module DBotQuery
2
+ module Models
3
+ class Alert < Base
4
+ type state = :open | :fixed | :dismissed
5
+
6
+ def days_open: (Time?) -> Integer
7
+
8
+ attr_accessor created_at: Time
9
+ attr_accessor fixed_at: Time?
10
+ attr_accessor state: state
11
+ attr_accessor dependency: Dependency
12
+ attr_accessor security_advisory: SecurityAdvisory
13
+ attr_accessor repository: Repository
14
+ attr_reader severity: SecurityAdvisory::severity
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ module DBotQuery
2
+ module Models
3
+ class AlertCollection
4
+ include Enumerable[Alert]
5
+ type sum_type = Models::SecurityAdvisory::severity | :total
6
+
7
+ @alerts: Array[Models::Alert]
8
+
9
+ def self.from_data: (untyped, ?Symbol) -> instance
10
+
11
+ def self.load: (String) -> instance
12
+
13
+ def self.load_file: (String) -> instance
14
+
15
+ def initialize: (Enumerable[Alert] | DataFile::data) -> void
16
+
17
+ def package_search: (String) -> Array[String]
18
+
19
+ def select: () { (Alert) -> bool } -> AlertCollection
20
+ def each: () { (Alert) -> void } -> void
21
+
22
+ def severity_filter: (SecurityAdvisory::severity?) -> AlertCollection
23
+
24
+ def state_filter: (Alert::state?) -> AlertCollection
25
+
26
+ def sum_repo: (Repository, Array[Alert]) -> untyped
27
+
28
+ def summary: (Alert::state?, SecurityAdvisory::severity?) -> { count: Integer }
29
+
30
+ def sla_stats: (Time?) -> ActiveSupport::HashWithIndifferentAccess[sum_type, ::Integer]
31
+
32
+ def repo_sla_stats: (Time?) -> ActiveSupport::HashWithIndifferentAccess[String, Hash[sum_type, Integer]]
33
+
34
+ def sla_violations: (Time?) -> Array[Alert]
35
+
36
+ private
37
+
38
+ def where_package: (String) -> AlertCollection
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ module DBotQuery
2
+ module Models
3
+ class Base
4
+ include ActiveModel::Model
5
+ include ActiveModel::Attributes
6
+ include ActiveModel::Validations
7
+
8
+ def self.assert_valid_value: (untyped) -> bool?
9
+
10
+ def self.attribute: (::Symbol, ?Symbol | Class, ?of: Class) -> void
11
+ def self.attributes: (Symbol, *Symbol) -> void
12
+
13
+ def self.attribute_names: () -> Array[String]
14
+
15
+ def self.cast: (Hash[untyped, untyped]) -> instance
16
+
17
+ def self.mutable?: -> bool
18
+
19
+ def self.validate_hash_attributes: (Hash[String, untyped]) -> Array[String]
20
+
21
+ interface _HashConstructable[T]
22
+ def new: (Hash[untyped, untyped]) -> T
23
+ def ===: (untyped) -> bool
24
+ end
25
+
26
+ class ObjectArray[T < _HashConstructable[T]] < ActiveModel::Type::Value
27
+ def initialize: (of: _HashConstructable[T]) -> void
28
+
29
+ attr_accessor target_class: _HashConstructable[T]
30
+
31
+ def cast: (Array[Hash[untyped, untyped]]) -> Array[T]
32
+
33
+ private
34
+
35
+ def materialize: (Hash[untyped, untyped] | T) -> T
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ module DBotQuery
2
+ module Models
3
+ class DataFile
4
+ type data = Array[Hash[untyped, untyped]]
5
+
6
+ @data: data
7
+ @alerts: AlertCollection
8
+
9
+ attr_reader alerts: AlertCollection
10
+ attr_reader data: data
11
+
12
+ def initialize: (data) -> void
13
+
14
+ def self.from_data: (String | Pathname, ?loader_method: Symbol) -> instance
15
+
16
+ def self.load: (String) -> instance
17
+
18
+ def self.load_file: (String | Pathname) -> instance
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module DBotQuery
2
+ module Models
3
+ class Dependency < Base
4
+ attr_accessor package: Package
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module DBotQuery
2
+ module Models
3
+ class Package < Base
4
+ attr_accessor name: String
5
+ attr_accessor ecosystem: String
6
+
7
+ def ==: (untyped) -> bool
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module DBotQuery
2
+ module Models
3
+ class Repository < Base
4
+ attr_accessor full_name: String
5
+
6
+ def ==: (untyped) -> bool
7
+
8
+ def to_s: -> String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module DBotQuery
2
+ module Models
3
+ class SecurityAdvisory < Base
4
+ type severity = :low | :medium | :high | :critical
5
+
6
+ attr_accessor severity: severity
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module DBotQuery
2
+ VERSION: String
3
+
4
+ SLA_DEFINITION: Hash[Models::SecurityAdvisory::severity, Integer]
5
+
6
+ SCHEMA_PATH: String
7
+
8
+ SCHEMA: Hash[untyped, untyped]
9
+
10
+ class Error < StandardError
11
+ end
12
+
13
+ def self.schema: () -> Hash[untyped, untyped]
14
+ end
@@ -0,0 +1,5 @@
1
+ module JSON
2
+ class Validator
3
+ def self.validate!: (untyped, untyped) -> void
4
+ end
5
+ end