smplkit 3.0.91 → 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 +63 -1
- data/lib/smplkit/audit/resource_types.rb +8 -1
- data/lib/smplkit/management/audit.rb +8 -0
- 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
|
|
@@ -401,6 +447,16 @@ module Smplkit
|
|
|
401
447
|
# the server.
|
|
402
448
|
attr_accessor :enabled
|
|
403
449
|
|
|
450
|
+
# @return [Boolean] When +true+, this forwarder also receives platform
|
|
451
|
+
# change events that smplkit records about your own resources (flag,
|
|
452
|
+
# configuration, and similar changes). Each such event is delivered
|
|
453
|
+
# through every environment this forwarder is enabled in, using that
|
|
454
|
+
# environment's resolved configuration. Defaults to +false+ — platform
|
|
455
|
+
# change events are not forwarded unless you opt in. Independent of the
|
|
456
|
+
# per-environment +enabled+ settings, since platform change events are
|
|
457
|
+
# not tied to a deployment environment.
|
|
458
|
+
attr_accessor :forward_smplkit_events
|
|
459
|
+
|
|
404
460
|
# @return [Hash{String => ForwarderEnvironment}] Per-environment overrides
|
|
405
461
|
# keyed by environment key (e.g. +"production"+, +"staging"+). A
|
|
406
462
|
# forwarder delivers in an environment only when
|
|
@@ -445,7 +501,8 @@ module Smplkit
|
|
|
445
501
|
attr_accessor :version
|
|
446
502
|
|
|
447
503
|
def initialize(client = nil, name:, forwarder_type:, configuration:,
|
|
448
|
-
id: nil, enabled: false,
|
|
504
|
+
id: nil, enabled: false, forward_smplkit_events: false,
|
|
505
|
+
environments: nil, description: nil,
|
|
449
506
|
filter: nil, transform: nil, transform_type: nil,
|
|
450
507
|
created_at: nil, updated_at: nil, deleted_at: nil, version: nil)
|
|
451
508
|
@client = client
|
|
@@ -457,6 +514,7 @@ module Smplkit
|
|
|
457
514
|
# round-trip the server value, but enablement is driven by
|
|
458
515
|
# ``environments`` (see the class docstring).
|
|
459
516
|
@enabled = enabled
|
|
517
|
+
@forward_smplkit_events = forward_smplkit_events
|
|
460
518
|
@environments = environments || {}
|
|
461
519
|
@description = description
|
|
462
520
|
@filter = filter
|
|
@@ -507,6 +565,7 @@ module Smplkit
|
|
|
507
565
|
@forwarder_type = other.forwarder_type
|
|
508
566
|
@configuration = other.configuration
|
|
509
567
|
@enabled = other.enabled
|
|
568
|
+
@forward_smplkit_events = other.forward_smplkit_events
|
|
510
569
|
@environments = other.environments
|
|
511
570
|
@description = other.description
|
|
512
571
|
@filter = other.filter
|
|
@@ -553,6 +612,9 @@ module Smplkit
|
|
|
553
612
|
# the server returned (always false) without assuming a default of
|
|
554
613
|
# true.
|
|
555
614
|
enabled: a.enabled.nil? ? false : a.enabled,
|
|
615
|
+
# ``forward_smplkit_events`` defaults to false; a forwarder persisted
|
|
616
|
+
# before the field landed reads back as not opted in.
|
|
617
|
+
forward_smplkit_events: a.forward_smplkit_events.nil? ? false : a.forward_smplkit_events,
|
|
556
618
|
environments: environments,
|
|
557
619
|
filter: a.filter.nil? ? nil : Smplkit::Helpers.deep_stringify_keys(a.filter),
|
|
558
620
|
transform_type: a.transform_type,
|
|
@@ -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) }
|
|
@@ -48,6 +48,11 @@ module Smplkit
|
|
|
48
48
|
# {Smplkit::Audit::HttpConfiguration} override). Omit to create a
|
|
49
49
|
# forwarder that delivers nowhere until enabled per environment.
|
|
50
50
|
# @param description [String, nil] Optional free-text description.
|
|
51
|
+
# @param forward_smplkit_events [Boolean] When +true+, the forwarder also
|
|
52
|
+
# receives platform change events that smplkit records about the
|
|
53
|
+
# account's own resources (flag, configuration, and similar changes),
|
|
54
|
+
# delivered through every environment the forwarder is enabled in.
|
|
55
|
+
# Defaults to +false+ — omit to leave platform change events unforwarded.
|
|
51
56
|
# @param filter [Hash, nil] Optional JSON Logic filter; events that don't
|
|
52
57
|
# match are recorded as +filtered_out+ deliveries.
|
|
53
58
|
# @param transform [Object, nil] Optional template applied to each event
|
|
@@ -65,6 +70,7 @@ module Smplkit
|
|
|
65
70
|
# @return [Smplkit::Audit::Forwarder]
|
|
66
71
|
def new_forwarder(id, forwarder_type:, configuration:, name: nil,
|
|
67
72
|
environments: nil, description: nil,
|
|
73
|
+
forward_smplkit_events: false,
|
|
68
74
|
filter: nil, transform: nil, transform_type: nil)
|
|
69
75
|
Smplkit::Audit::Forwarder.send(:validate_transform_pair!, transform, transform_type)
|
|
70
76
|
Smplkit::Audit::Forwarder.new(
|
|
@@ -75,6 +81,7 @@ module Smplkit
|
|
|
75
81
|
configuration: configuration,
|
|
76
82
|
environments: normalize_environments(environments),
|
|
77
83
|
description: description,
|
|
84
|
+
forward_smplkit_events: forward_smplkit_events,
|
|
78
85
|
filter: filter,
|
|
79
86
|
transform: transform,
|
|
80
87
|
transform_type: transform_type
|
|
@@ -191,6 +198,7 @@ module Smplkit
|
|
|
191
198
|
name: forwarder.name,
|
|
192
199
|
description: forwarder.description,
|
|
193
200
|
forwarder_type: Smplkit::Audit::ForwarderType.coerce(forwarder.forwarder_type),
|
|
201
|
+
forward_smplkit_events: forwarder.forward_smplkit_events,
|
|
194
202
|
environments: environments_to_wire(forwarder.environments),
|
|
195
203
|
filter: forwarder.filter,
|
|
196
204
|
transform_type: Smplkit::Audit::TransformType.coerce(forwarder.transform_type),
|
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
|