smplkit 3.0.92 → 3.0.93
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.
- checksums.yaml +4 -4
- data/lib/smplkit/audit/categories.rb +39 -0
- data/lib/smplkit/audit/client.rb +5 -3
- data/lib/smplkit/audit/event_types.rb +8 -1
- data/lib/smplkit/audit/events.rb +9 -1
- data/lib/smplkit/audit/models.rb +46 -0
- data/lib/smplkit/audit/resource_types.rb +8 -1
- data/lib/smplkit.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 892be2c4c6e0ddaab8b5ad36cb4248c08243c9309f45740963adbe009f3af8e4
|
|
4
|
+
data.tar.gz: 7dcdf94dff55e949983960a66a2fb80134c34ff362e69a00af8ac7322c136b88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91f79728ddb170cd32dbc70b009a1efaa1360838d7863e8167a1cf4b57bedca985ff33222eb50712f5fcb388466504cf6d8ddac389924ac408324417caa3561d
|
|
7
|
+
data.tar.gz: 3e662575d14354902eace0bc5af02abc3ebbfdc1a2debd634cd3f36cfd84e9d214f34b547819d029622e07c5ff11f11f86d989f6c3ee1453fc2321fd048119d8
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smplkit
|
|
4
|
+
module Audit
|
|
5
|
+
# +client.audit.categories.list+ — distinct +category+ values seen for
|
|
6
|
+
# the account.
|
|
7
|
+
#
|
|
8
|
+
# Backed by a maintain-by-write side table populated whenever an event
|
|
9
|
+
# is recorded with a non-null +category+ (ADR-047 §2.5), so the response
|
|
10
|
+
# time is independent of how many years of events the account has
|
|
11
|
+
# accumulated. Sorted alphabetically; offset pagination (+page_number+ /
|
|
12
|
+
# +page_size+) per ADR-014.
|
|
13
|
+
class Categories
|
|
14
|
+
def initialize(api)
|
|
15
|
+
@api = api
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# +environments+ is an optional array of environment keys (and/or the
|
|
19
|
+
# reserved +"smplkit"+ control-plane bucket) used to scope the read;
|
|
20
|
+
# the values are comma-joined into +filter[environment]+. Omitting it
|
|
21
|
+
# (or passing an empty array) leaves the filter unset — identical to
|
|
22
|
+
# the prior behavior on the wire.
|
|
23
|
+
def list(page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
24
|
+
opts = {}
|
|
25
|
+
opts[:page_number] = page_number if page_number
|
|
26
|
+
opts[:page_size] = page_size if page_size
|
|
27
|
+
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
28
|
+
joined_environments = Smplkit::Audit.join_environments(environments)
|
|
29
|
+
opts[:filter_environment] = joined_environments if joined_environments
|
|
30
|
+
|
|
31
|
+
resp = Smplkit::Audit.call_api { @api.list_categories(opts) }
|
|
32
|
+
rows = (resp.data || []).map { |r| Category.from_resource(r) }
|
|
33
|
+
CategoryListPage.new(rows, Smplkit::Audit.extract_pagination(resp.meta))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
CategoryListPage = Struct.new(:categories, :pagination)
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/smplkit/audit/client.rb
CHANGED
|
@@ -6,13 +6,14 @@ module Smplkit
|
|
|
6
6
|
#
|
|
7
7
|
# Owns event recording and read-side queries: fire-and-forget
|
|
8
8
|
# +#events.record+, plus the audit-log +list+ / +get+ and the
|
|
9
|
-
# distinct-value listings
|
|
10
|
-
#
|
|
9
|
+
# distinct-value listings (+resource_types+, +event_types+,
|
|
10
|
+
# +categories+) that back the Activity tab filter dropdowns.
|
|
11
|
+
# ADR-047 §2.7.
|
|
11
12
|
#
|
|
12
13
|
# SIEM forwarder CRUD lives on {Smplkit::ManagementClient} under
|
|
13
14
|
# +mgmt.audit.forwarders.*+.
|
|
14
15
|
class AuditClient
|
|
15
|
-
attr_reader :events, :resource_types, :event_types
|
|
16
|
+
attr_reader :events, :resource_types, :event_types, :categories
|
|
16
17
|
|
|
17
18
|
SDK_OWNED_HEADERS = %w[authorization content-type user-agent].freeze
|
|
18
19
|
|
|
@@ -38,6 +39,7 @@ module Smplkit
|
|
|
38
39
|
@events = Events.new(SmplkitGeneratedClient::Audit::EventsApi.new(api_client))
|
|
39
40
|
@resource_types = ResourceTypes.new(SmplkitGeneratedClient::Audit::ResourceTypesApi.new(api_client))
|
|
40
41
|
@event_types = EventTypes.new(SmplkitGeneratedClient::Audit::EventTypesApi.new(api_client))
|
|
42
|
+
@categories = Categories.new(SmplkitGeneratedClient::Audit::CategoriesApi.new(api_client))
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def _close
|
|
@@ -18,12 +18,19 @@ module Smplkit
|
|
|
18
18
|
@api = api
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
# +environments+ is an optional array of environment keys (and/or the
|
|
22
|
+
# reserved +"smplkit"+ control-plane bucket) used to scope the read;
|
|
23
|
+
# the values are comma-joined into +filter[environment]+. Omitting it
|
|
24
|
+
# (or passing an empty array) leaves the filter unset — identical to
|
|
25
|
+
# the prior behavior on the wire.
|
|
26
|
+
def list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
22
27
|
opts = {}
|
|
23
28
|
opts[:filter_resource_type] = filter_resource_type if filter_resource_type
|
|
24
29
|
opts[:page_number] = page_number if page_number
|
|
25
30
|
opts[:page_size] = page_size if page_size
|
|
26
31
|
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
32
|
+
joined_environments = Smplkit::Audit.join_environments(environments)
|
|
33
|
+
opts[:filter_environment] = joined_environments if joined_environments
|
|
27
34
|
|
|
28
35
|
resp = Smplkit::Audit.call_api { @api.list_event_types(opts) }
|
|
29
36
|
rows = (resp.data || []).map { |r| EventType.from_resource(r) }
|
data/lib/smplkit/audit/events.rb
CHANGED
|
@@ -79,9 +79,15 @@ module Smplkit
|
|
|
79
79
|
# List events with filters and cursor pagination. Returns a
|
|
80
80
|
# +Smplkit::Audit::ListEventsPage+ whose +#events+ is the page and
|
|
81
81
|
# +#next_cursor+ is the opaque token for the next page (or nil).
|
|
82
|
+
#
|
|
83
|
+
# +environments+ is an optional array of environment keys (and/or the
|
|
84
|
+
# reserved +"smplkit"+ control-plane bucket) used to scope the read; the
|
|
85
|
+
# values are comma-joined into +filter[environment]+. Omitting it (or
|
|
86
|
+
# passing an empty array) leaves the filter unset — identical to the
|
|
87
|
+
# prior behavior on the wire.
|
|
82
88
|
def list(event_type: nil, resource_type: nil, resource_id: nil,
|
|
83
89
|
actor_type: nil, actor_id: nil, occurred_at_range: nil,
|
|
84
|
-
search: nil, page_size: nil, page_after: nil)
|
|
90
|
+
search: nil, environments: nil, page_size: nil, page_after: nil)
|
|
85
91
|
# Generated client opts use snake_case keys that internally map
|
|
86
92
|
# to the JSON:API ``filter[*]`` / ``page[*]`` query-string format
|
|
87
93
|
# (see default_api.rb#list_events_with_http_info). Without the
|
|
@@ -95,6 +101,8 @@ module Smplkit
|
|
|
95
101
|
opts[:filter_actor_id] = actor_id if actor_id
|
|
96
102
|
opts[:filter_occurred_at] = occurred_at_range if occurred_at_range
|
|
97
103
|
opts[:filter_search] = search if search
|
|
104
|
+
joined_environments = Smplkit::Audit.join_environments(environments)
|
|
105
|
+
opts[:filter_environment] = joined_environments if joined_environments
|
|
98
106
|
opts[:page_size] = page_size if page_size
|
|
99
107
|
opts[:page_after] = page_after if page_after
|
|
100
108
|
|
data/lib/smplkit/audit/models.rb
CHANGED
|
@@ -49,6 +49,28 @@ module Smplkit
|
|
|
49
49
|
out
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
# Coerce a caller-supplied +environments+ value into the comma-separated
|
|
53
|
+
# string the audit read endpoints expect for +filter[environment]+, or
|
|
54
|
+
# +nil+ when no filter should be sent.
|
|
55
|
+
#
|
|
56
|
+
# The audit read endpoints (events list, the resource_type / event_type /
|
|
57
|
+
# category discovery lists) accept an optional comma-separated
|
|
58
|
+
# +filter[environment]+ of real environment keys and/or the reserved
|
|
59
|
+
# +"smplkit"+ control-plane bucket (ADR-055). The wrapper takes an
|
|
60
|
+
# array of keys for an ergonomic surface and joins it here.
|
|
61
|
+
#
|
|
62
|
+
# +nil+ or an empty array (or one whose entries are all blank) returns
|
|
63
|
+
# +nil+ so the caller omits the query param entirely and behaves exactly
|
|
64
|
+
# as before — existing callers are byte-for-byte unchanged on the wire.
|
|
65
|
+
# +"smplkit"+ is passed through like any other key; it carries no special
|
|
66
|
+
# handling in the SDK.
|
|
67
|
+
def self.join_environments(environments)
|
|
68
|
+
return nil if environments.nil?
|
|
69
|
+
|
|
70
|
+
values = Array(environments).map { |e| e.to_s.strip }.reject(&:empty?)
|
|
71
|
+
values.empty? ? nil : values.join(",")
|
|
72
|
+
end
|
|
73
|
+
|
|
52
74
|
# Supported SIEM forwarder destination types (ADR-047 §2.12).
|
|
53
75
|
#
|
|
54
76
|
# Members are declared in alphabetical order. Customers pass these
|
|
@@ -246,6 +268,30 @@ module Smplkit
|
|
|
246
268
|
end
|
|
247
269
|
end
|
|
248
270
|
|
|
271
|
+
# A distinct +category+ value seen for the account.
|
|
272
|
+
#
|
|
273
|
+
# Same shape as {ResourceType}/{EventType} — +id+ and +category+ are the
|
|
274
|
+
# same value (JSON:API surfaces the customer-facing key as the resource
|
|
275
|
+
# id, ADR-014). +created_at+ is the earliest sighting of this category
|
|
276
|
+
# for the account.
|
|
277
|
+
#
|
|
278
|
+
# @!attribute [rw] id
|
|
279
|
+
# @return [String] JSON:API resource id (same as +category+).
|
|
280
|
+
# @!attribute [rw] category
|
|
281
|
+
# @return [String] The distinct category value.
|
|
282
|
+
# @!attribute [rw] created_at
|
|
283
|
+
# @return [String] ISO-8601 timestamp of the earliest sighting for this value.
|
|
284
|
+
Category = Struct.new(:id, :category, :created_at, keyword_init: true) do
|
|
285
|
+
def self.from_resource(resource)
|
|
286
|
+
attrs = resource.attributes
|
|
287
|
+
new(
|
|
288
|
+
id: resource.id,
|
|
289
|
+
category: attrs.category || resource.id,
|
|
290
|
+
created_at: attrs.created_at
|
|
291
|
+
)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
249
295
|
# A single name/value HTTP header on a forwarder destination.
|
|
250
296
|
#
|
|
251
297
|
# @!attribute [rw] name
|
|
@@ -14,11 +14,18 @@ module Smplkit
|
|
|
14
14
|
@api = api
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
# +environments+ is an optional array of environment keys (and/or the
|
|
18
|
+
# reserved +"smplkit"+ control-plane bucket) used to scope the read;
|
|
19
|
+
# the values are comma-joined into +filter[environment]+. Omitting it
|
|
20
|
+
# (or passing an empty array) leaves the filter unset — identical to
|
|
21
|
+
# the prior behavior on the wire.
|
|
22
|
+
def list(page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
18
23
|
opts = {}
|
|
19
24
|
opts[:page_number] = page_number if page_number
|
|
20
25
|
opts[:page_size] = page_size if page_size
|
|
21
26
|
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
27
|
+
joined_environments = Smplkit::Audit.join_environments(environments)
|
|
28
|
+
opts[:filter_environment] = joined_environments if joined_environments
|
|
22
29
|
|
|
23
30
|
resp = Smplkit::Audit.call_api { @api.list_resource_types(opts) }
|
|
24
31
|
rows = (resp.data || []).map { |r| ResourceType.from_resource(r) }
|
data/lib/smplkit.rb
CHANGED
|
@@ -64,6 +64,7 @@ require_relative "smplkit/audit/buffer"
|
|
|
64
64
|
require_relative "smplkit/audit/events"
|
|
65
65
|
require_relative "smplkit/audit/resource_types"
|
|
66
66
|
require_relative "smplkit/audit/event_types"
|
|
67
|
+
require_relative "smplkit/audit/categories"
|
|
67
68
|
require_relative "smplkit/audit/client"
|
|
68
69
|
require_relative "smplkit/jobs/models"
|
|
69
70
|
require_relative "smplkit/management/types"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smplkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.93
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Smpl Solutions LLC
|
|
@@ -860,6 +860,7 @@ files:
|
|
|
860
860
|
- lib/smplkit/_generated/logging/spec/models/usage_resource_spec.rb
|
|
861
861
|
- lib/smplkit/_generated/logging/spec/spec_helper.rb
|
|
862
862
|
- lib/smplkit/audit/buffer.rb
|
|
863
|
+
- lib/smplkit/audit/categories.rb
|
|
863
864
|
- lib/smplkit/audit/client.rb
|
|
864
865
|
- lib/smplkit/audit/event_types.rb
|
|
865
866
|
- lib/smplkit/audit/events.rb
|