smplkit 3.0.101 → 3.0.102
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 +10 -6
- data/lib/smplkit/audit/client.rb +24 -15
- data/lib/smplkit/audit/event_types.rb +10 -6
- data/lib/smplkit/audit/events.rb +20 -4
- data/lib/smplkit/audit/models.rb +23 -1
- data/lib/smplkit/audit/resource_types.rb +10 -6
- data/lib/smplkit/client.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 047e3fc0922ee25b1441a22a33addbba76e885b486414ac3ca99b31d07b17277
|
|
4
|
+
data.tar.gz: 5ce032781cecf99066afb73359af216000039d158318dc427dfc456f159d35b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c5a05ff1932b11b194a3405bb6f361763810c935e3e7bc924afb6431dfd201b6447020b117f14161dc209525a072e4a4afb9d6b467eb086bfd177c5f3f6400c
|
|
7
|
+
data.tar.gz: cebda2b16e66a59fac937a6f135fdaeff3cdd727ff009637a77627efefc0eb2738a411dead73ccaf60d3f30edbd1416a6f55602bcfe4da2d00c891c14effefcc
|
|
@@ -8,16 +8,19 @@ module Smplkit
|
|
|
8
8
|
# Response time is independent of how many years of events the account has
|
|
9
9
|
# accumulated. Sorted alphabetically; offset paginated.
|
|
10
10
|
class Categories
|
|
11
|
-
def initialize(api)
|
|
11
|
+
def initialize(api, environment: nil)
|
|
12
12
|
@api = api
|
|
13
|
+
@environment = environment
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
# List the distinct +category+ values seen in the account.
|
|
16
17
|
#
|
|
17
18
|
# +environments+ scopes the listing to a set of environments: pass an
|
|
18
19
|
# array of environment keys and/or the reserved +"smplkit"+ control-plane
|
|
19
|
-
# bucket; the values are comma-joined into +filter[environment]+.
|
|
20
|
-
#
|
|
20
|
+
# bucket; the values are comma-joined into +filter[environment]+. Omit it
|
|
21
|
+
# (the default) to scope the listing to the client's configured
|
|
22
|
+
# environment; with no configured environment the filter is left off
|
|
23
|
+
# entirely.
|
|
21
24
|
#
|
|
22
25
|
# @param page_number [Integer, nil] 1-based page index. Omit for the first
|
|
23
26
|
# page.
|
|
@@ -28,7 +31,8 @@ module Smplkit
|
|
|
28
31
|
# count server-side). Omit to skip it.
|
|
29
32
|
# @param environments [Array<String>, nil] Environment keys and/or the
|
|
30
33
|
# reserved +"smplkit"+ control-plane bucket to scope the listing to. Omit
|
|
31
|
-
# to
|
|
34
|
+
# to fall back to the client's configured environment; with no configured
|
|
35
|
+
# environment the filter is left off entirely.
|
|
32
36
|
# @return [Smplkit::Audit::CategoryListPage] A page of the matching
|
|
33
37
|
# category values.
|
|
34
38
|
def list(page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
@@ -36,8 +40,8 @@ module Smplkit
|
|
|
36
40
|
opts[:page_number] = page_number if page_number
|
|
37
41
|
opts[:page_size] = page_size if page_size
|
|
38
42
|
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
39
|
-
|
|
40
|
-
opts[:filter_environment] =
|
|
43
|
+
resolved_environment = Smplkit::Audit.resolve_environment_filter(environments, @environment)
|
|
44
|
+
opts[:filter_environment] = resolved_environment if resolved_environment
|
|
41
45
|
|
|
42
46
|
resp = Smplkit::Audit.call_api { @api.list_categories(opts) }
|
|
43
47
|
rows = (resp.data || []).map { |r| Category.from_resource(r) }
|
data/lib/smplkit/audit/client.rb
CHANGED
|
@@ -21,9 +21,13 @@ module Smplkit
|
|
|
21
21
|
# from +base_domain+/+scheme+; supplied directly by the top-level clients
|
|
22
22
|
# which have already computed it.
|
|
23
23
|
# @param environment [String, nil] Deployment environment to scope recording
|
|
24
|
-
# and reads to.
|
|
25
|
-
# environment
|
|
26
|
-
#
|
|
24
|
+
# and reads to. Sent on the event request body when recording and as the
|
|
25
|
+
# default +filter[environment]+ on the read surfaces (events list and the
|
|
26
|
+
# resource_type / event_type / category discovery lists). Optional —
|
|
27
|
+
# forwarder CRUD is environment-agnostic, and reads accept an explicit
|
|
28
|
+
# +environments: [...]+ filter that overrides this default. With no
|
|
29
|
+
# configured environment, recording falls back to the server-side default
|
|
30
|
+
# environment and the read filter is left off.
|
|
27
31
|
# @param profile [String, nil] Named +~/.smplkit+ profile section.
|
|
28
32
|
# @param base_domain [String, nil] Base domain for API requests (default
|
|
29
33
|
# +"smplkit.com"+).
|
|
@@ -64,21 +68,26 @@ module Smplkit
|
|
|
64
68
|
HttpPool.configure(cfg)
|
|
65
69
|
api_client = SmplkitGeneratedClient::Audit::ApiClient.new(cfg)
|
|
66
70
|
api_client.default_headers["User-Agent"] = "smplkit-ruby-sdk/#{Smplkit::VERSION}"
|
|
67
|
-
# Runtime audit ops are environment-scoped
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
api_client.default_headers["X-Smplkit-Environment"] = environment unless environment.nil?
|
|
71
|
+
# Runtime audit ops are environment-scoped, but the scoping is
|
|
72
|
+
# body-driven (ADR-055): +events.record+ stamps the configured
|
|
73
|
+
# environment onto the event request body, and the read surfaces
|
|
74
|
+
# (events list plus the resource_type / event_type / category discovery
|
|
75
|
+
# lists) default +filter[environment]+ to it. The transport therefore
|
|
76
|
+
# carries only auth plus any caller-supplied +extra_headers+ — no
|
|
77
|
+
# environment header. Forwarder CRUD is environment-agnostic.
|
|
75
78
|
extra_headers&.each do |k, v|
|
|
76
79
|
api_client.default_headers[k] = v unless SDK_OWNED_HEADERS.include?(k.downcase)
|
|
77
80
|
end
|
|
78
|
-
@events = Events.new(SmplkitGeneratedClient::Audit::EventsApi.new(api_client))
|
|
79
|
-
@resource_types = ResourceTypes.new(
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
@events = Events.new(SmplkitGeneratedClient::Audit::EventsApi.new(api_client), environment: environment)
|
|
82
|
+
@resource_types = ResourceTypes.new(
|
|
83
|
+
SmplkitGeneratedClient::Audit::ResourceTypesApi.new(api_client), environment: environment
|
|
84
|
+
)
|
|
85
|
+
@event_types = EventTypes.new(
|
|
86
|
+
SmplkitGeneratedClient::Audit::EventTypesApi.new(api_client), environment: environment
|
|
87
|
+
)
|
|
88
|
+
@categories = Categories.new(
|
|
89
|
+
SmplkitGeneratedClient::Audit::CategoriesApi.new(api_client), environment: environment
|
|
90
|
+
)
|
|
82
91
|
@forwarders = ForwardersClient.new(SmplkitGeneratedClient::Audit::ForwardersApi.new(api_client))
|
|
83
92
|
end
|
|
84
93
|
|
|
@@ -13,16 +13,19 @@ module Smplkit
|
|
|
13
13
|
#
|
|
14
14
|
# Sorted alphabetically; offset paginated.
|
|
15
15
|
class EventTypes
|
|
16
|
-
def initialize(api)
|
|
16
|
+
def initialize(api, environment: nil)
|
|
17
17
|
@api = api
|
|
18
|
+
@environment = environment
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
# List the distinct +event_type+ slugs seen in the account.
|
|
21
22
|
#
|
|
22
23
|
# +environments+ scopes the listing to a set of environments: pass an
|
|
23
24
|
# array of environment keys and/or the reserved +"smplkit"+ control-plane
|
|
24
|
-
# bucket; the values are comma-joined into +filter[environment]+.
|
|
25
|
-
#
|
|
25
|
+
# bucket; the values are comma-joined into +filter[environment]+. Omit it
|
|
26
|
+
# (the default) to scope the listing to the client's configured
|
|
27
|
+
# environment; with no configured environment the filter is left off
|
|
28
|
+
# entirely.
|
|
26
29
|
#
|
|
27
30
|
# @param filter_resource_type [String, nil] Restrict the listing to
|
|
28
31
|
# event_types seen with this +resource_type+. Omit to list every distinct
|
|
@@ -36,7 +39,8 @@ module Smplkit
|
|
|
36
39
|
# count server-side). Omit to skip it.
|
|
37
40
|
# @param environments [Array<String>, nil] Environment keys and/or the
|
|
38
41
|
# reserved +"smplkit"+ control-plane bucket to scope the listing to. Omit
|
|
39
|
-
# to
|
|
42
|
+
# to fall back to the client's configured environment; with no configured
|
|
43
|
+
# environment the filter is left off entirely.
|
|
40
44
|
# @return [Smplkit::Audit::EventTypeListPage] A page of the matching
|
|
41
45
|
# event-type slugs.
|
|
42
46
|
def list(filter_resource_type: nil, page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
@@ -45,8 +49,8 @@ module Smplkit
|
|
|
45
49
|
opts[:page_number] = page_number if page_number
|
|
46
50
|
opts[:page_size] = page_size if page_size
|
|
47
51
|
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
48
|
-
|
|
49
|
-
opts[:filter_environment] =
|
|
52
|
+
resolved_environment = Smplkit::Audit.resolve_environment_filter(environments, @environment)
|
|
53
|
+
opts[:filter_environment] = resolved_environment if resolved_environment
|
|
50
54
|
|
|
51
55
|
resp = Smplkit::Audit.call_api { @api.list_event_types(opts) }
|
|
52
56
|
rows = (resp.data || []).map { |r| EventType.from_resource(r) }
|
data/lib/smplkit/audit/events.rb
CHANGED
|
@@ -9,8 +9,9 @@ module Smplkit
|
|
|
9
9
|
# +flush: true+ to block until the event is durable before continuing.
|
|
10
10
|
# +#list+ and +#get+ are synchronous reads.
|
|
11
11
|
class Events
|
|
12
|
-
def initialize(api)
|
|
12
|
+
def initialize(api, environment: nil)
|
|
13
13
|
@api = api
|
|
14
|
+
@environment = environment
|
|
14
15
|
@buffer = EventBuffer.new(api)
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -105,6 +106,13 @@ module Smplkit
|
|
|
105
106
|
data: data || {},
|
|
106
107
|
do_not_forward: do_not_forward
|
|
107
108
|
)
|
|
109
|
+
# Stamp the client's configured environment onto the event body — the
|
|
110
|
+
# body-driven replacement for the old +X-Smplkit-Environment+ header
|
|
111
|
+
# (ADR-055). Left off when nil so a single-environment credential
|
|
112
|
+
# resolves it server-side. Assigning conditionally (rather than passing
|
|
113
|
+
# +environment: nil+ through the constructor) keeps the field out of the
|
|
114
|
+
# serialized body entirely when unconfigured.
|
|
115
|
+
attrs.environment = @environment unless @environment.nil?
|
|
108
116
|
resource = SmplkitGeneratedClient::Audit::EventResource.new(
|
|
109
117
|
id: "",
|
|
110
118
|
type: "event",
|
|
@@ -141,6 +149,13 @@ module Smplkit
|
|
|
141
149
|
# +occurred_at_range+, or with both +resource_type+ and +resource_id+ —
|
|
142
150
|
# or the request is rejected.
|
|
143
151
|
#
|
|
152
|
+
# +environments+ scopes the read to a set of environments: pass an array
|
|
153
|
+
# of environment keys and/or the reserved +"smplkit"+ control-plane
|
|
154
|
+
# bucket; the values are sent comma-separated as +filter[environment]+.
|
|
155
|
+
# Omit it (the default) to scope the read to the client's configured
|
|
156
|
+
# environment; with no configured environment the filter is left off
|
|
157
|
+
# entirely.
|
|
158
|
+
#
|
|
144
159
|
# @param event_type [String, nil] Return only events with this
|
|
145
160
|
# +event_type+. Omit to match any.
|
|
146
161
|
# @param resource_type [String, nil] Return only events about this
|
|
@@ -160,7 +175,8 @@ module Smplkit
|
|
|
160
175
|
# or the request is rejected. Omit to disable text filtering.
|
|
161
176
|
# @param environments [Array<String>, nil] Environment keys (and/or the
|
|
162
177
|
# reserved +"smplkit"+ control-plane bucket) to scope the read to. Omit
|
|
163
|
-
# to
|
|
178
|
+
# to fall back to the client's configured environment; with no configured
|
|
179
|
+
# environment the filter is left off entirely.
|
|
164
180
|
# @param page_size [Integer, nil] Maximum number of events to return in
|
|
165
181
|
# this page.
|
|
166
182
|
# @param page_after [String, nil] Opaque cursor from a previous page's
|
|
@@ -183,8 +199,8 @@ module Smplkit
|
|
|
183
199
|
opts[:filter_actor_id] = actor_id if actor_id
|
|
184
200
|
opts[:filter_occurred_at] = occurred_at_range if occurred_at_range
|
|
185
201
|
opts[:filter_search] = search if search
|
|
186
|
-
|
|
187
|
-
opts[:filter_environment] =
|
|
202
|
+
resolved_environment = Smplkit::Audit.resolve_environment_filter(environments, @environment)
|
|
203
|
+
opts[:filter_environment] = resolved_environment if resolved_environment
|
|
188
204
|
opts[:page_size] = page_size if page_size
|
|
189
205
|
opts[:page_after] = page_after if page_after
|
|
190
206
|
|
data/lib/smplkit/audit/models.rb
CHANGED
|
@@ -79,6 +79,28 @@ module Smplkit
|
|
|
79
79
|
values.empty? ? nil : values.join(",")
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
# Resolve the +filter[environment]+ value for a read surface.
|
|
83
|
+
#
|
|
84
|
+
# An explicit, non-empty +environments+ list always wins and is comma-joined
|
|
85
|
+
# via {join_environments}. Otherwise the client's configured +default+
|
|
86
|
+
# environment scopes the read — the body-driven replacement for the old
|
|
87
|
+
# per-request +X-Smplkit-Environment+ header (ADR-055), which previously
|
|
88
|
+
# scoped every read to the client's environment. A client with no configured
|
|
89
|
+
# environment and no explicit list returns +nil+ so the caller omits the
|
|
90
|
+
# query param and the credential's own scoping applies server-side.
|
|
91
|
+
#
|
|
92
|
+
# @param environments [Array<String>, String, nil] Explicit per-call
|
|
93
|
+
# environment filter; an empty/blank value falls through to +default+.
|
|
94
|
+
# @param default [String, nil] The client's configured environment.
|
|
95
|
+
# @return [String, nil] The +filter[environment]+ value, or +nil+ to omit it.
|
|
96
|
+
# @api private
|
|
97
|
+
def self.resolve_environment_filter(environments, default)
|
|
98
|
+
joined = join_environments(environments)
|
|
99
|
+
return joined unless joined.nil?
|
|
100
|
+
|
|
101
|
+
default
|
|
102
|
+
end
|
|
103
|
+
|
|
82
104
|
# Supported SIEM forwarder destination types.
|
|
83
105
|
#
|
|
84
106
|
# Members are declared in alphabetical order. Customers pass these
|
|
@@ -204,7 +226,7 @@ module Smplkit
|
|
|
204
226
|
# Read-only and always present on reads — the audit service resolves it
|
|
205
227
|
# when the event is recorded (from a single-environment credential, or
|
|
206
228
|
# from the runtime SDK's configured environment, which the SDK sends on
|
|
207
|
-
#
|
|
229
|
+
# the recording request body).
|
|
208
230
|
AuditEvent = Struct.new(
|
|
209
231
|
:id, :event_type, :resource_type, :resource_id,
|
|
210
232
|
:occurred_at, :created_at,
|
|
@@ -8,16 +8,19 @@ module Smplkit
|
|
|
8
8
|
# Response time is independent of how many years of events the account has
|
|
9
9
|
# accumulated. Sorted alphabetically; offset paginated.
|
|
10
10
|
class ResourceTypes
|
|
11
|
-
def initialize(api)
|
|
11
|
+
def initialize(api, environment: nil)
|
|
12
12
|
@api = api
|
|
13
|
+
@environment = environment
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
# List the distinct +resource_type+ slugs seen in the account.
|
|
16
17
|
#
|
|
17
18
|
# +environments+ scopes the listing to a set of environments: pass an
|
|
18
19
|
# array of environment keys and/or the reserved +"smplkit"+ control-plane
|
|
19
|
-
# bucket; the values are comma-joined into +filter[environment]+.
|
|
20
|
-
#
|
|
20
|
+
# bucket; the values are comma-joined into +filter[environment]+. Omit it
|
|
21
|
+
# (the default) to scope the listing to the client's configured
|
|
22
|
+
# environment; with no configured environment the filter is left off
|
|
23
|
+
# entirely.
|
|
21
24
|
#
|
|
22
25
|
# @param page_number [Integer, nil] 1-based page index. Omit for the first
|
|
23
26
|
# page.
|
|
@@ -28,7 +31,8 @@ module Smplkit
|
|
|
28
31
|
# count server-side). Omit to skip it.
|
|
29
32
|
# @param environments [Array<String>, nil] Environment keys and/or the
|
|
30
33
|
# reserved +"smplkit"+ control-plane bucket to scope the listing to. Omit
|
|
31
|
-
# to
|
|
34
|
+
# to fall back to the client's configured environment; with no configured
|
|
35
|
+
# environment the filter is left off entirely.
|
|
32
36
|
# @return [Smplkit::Audit::ResourceTypeListPage] A page of the matching
|
|
33
37
|
# resource-type slugs.
|
|
34
38
|
def list(page_number: nil, page_size: nil, meta_total: nil, environments: nil)
|
|
@@ -36,8 +40,8 @@ module Smplkit
|
|
|
36
40
|
opts[:page_number] = page_number if page_number
|
|
37
41
|
opts[:page_size] = page_size if page_size
|
|
38
42
|
opts[:meta_total] = meta_total unless meta_total.nil?
|
|
39
|
-
|
|
40
|
-
opts[:filter_environment] =
|
|
43
|
+
resolved_environment = Smplkit::Audit.resolve_environment_filter(environments, @environment)
|
|
44
|
+
opts[:filter_environment] = resolved_environment if resolved_environment
|
|
41
45
|
|
|
42
46
|
resp = Smplkit::Audit.call_api { @api.list_resource_types(opts) }
|
|
43
47
|
rows = (resp.data || []).map { |r| ResourceType.from_resource(r) }
|
data/lib/smplkit/client.rb
CHANGED
|
@@ -124,9 +124,11 @@ module Smplkit
|
|
|
124
124
|
# borrows the shared logging transport and WebSocket. The two management
|
|
125
125
|
# sub-clients live at client.logging.loggers / client.logging.log_groups.
|
|
126
126
|
@logging = Logging::LoggingClient.new(parent: self, transport: @transports.logging_http, metrics: @metrics)
|
|
127
|
-
# Audit's full surface on one client; this runtime instance
|
|
128
|
-
# configured environment
|
|
129
|
-
#
|
|
127
|
+
# Audit's full surface on one client; this runtime instance scopes audit
|
|
128
|
+
# ops to the configured environment via the body-driven path (ADR-055):
|
|
129
|
+
# ``events.record`` stamps it on the event body and the read surfaces
|
|
130
|
+
# default ``filter[environment]`` to it. Owns its own transport (closed in
|
|
131
|
+
# ``close``).
|
|
130
132
|
@audit = Audit::AuditClient.new(
|
|
131
133
|
api_key: cfg.api_key, base_url: audit_url, environment: cfg.environment, extra_headers: extra_headers
|
|
132
134
|
)
|