Skip to content

Commit 6e54b98

Browse files
leogrpoiana
authored andcommitted
update(sdk): bump plugin_info version (plugin API v2)
This is temporary and required for testing purpose. Another bump should be expected before releasing v0.6.0. Signed-off-by: Leonardo Grasso <[email protected]>
1 parent 4a87bc0 commit 6e54b98

File tree

2 files changed

+74
-41
lines changed

2 files changed

+74
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SHELL := /bin/bash
1414
GO ?= $(shell which go)
1515
CURL ?= $(shell which curl)
1616

17-
FALCOSECURITY_LIBS_REVISION ?= 5b9c3ca9ae55800e774e1681a0c5e7d54ca89263
17+
FALCOSECURITY_LIBS_REVISION ?= 000eb27573af74168510e4836330ff6958c3f355
1818
FALCOSECURITY_LIBS_REPO ?= falcosecurity/libs
1919
PLUGINLIB_URL=https://raw.githubusercontent.com/${FALCOSECURITY_LIBS_REPO}/${FALCOSECURITY_LIBS_REVISION}/userspace/plugin
2020

pkg/sdk/plugin_api.h

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ extern "C" {
2525

2626

2727
//
28-
// API versions of this plugin engine
28+
// API versions of this plugin framework
2929
//
30-
#define PLUGIN_API_VERSION_MAJOR 1
30+
#define PLUGIN_API_VERSION_MAJOR 2
3131
#define PLUGIN_API_VERSION_MINOR 0
3232
#define PLUGIN_API_VERSION_PATCH 0
3333

@@ -64,8 +64,9 @@ extern "C" {
6464
// parameters) if not corresponding to plugin-allocated memory in the
6565
// cases above. Plugins can safely use the passed memory during the execution
6666
// of the exported functions.
67+
6768
//
68-
// Plugins vtable
69+
// Plugins API vtable
6970
//
7071
typedef struct
7172
{
@@ -74,9 +75,9 @@ typedef struct
7475
// Required: yes
7576
// Return value: the API version string, in the following format:
7677
// "<major>.<minor>.<patch>", e.g. "1.2.3".
77-
// NOTE: to ensure correct interoperability between the engine and the plugins,
78+
// NOTE: to ensure correct interoperability between the framework and the plugins,
7879
// we use a semver approach. Plugins are required to specify the version
79-
// of the API they run against, and the engine will take care of checking
80+
// of the API they run against, and the framework will take care of checking
8081
// and enforcing compatibility.
8182
//
8283
const char *(*get_required_api_version)();
@@ -103,17 +104,20 @@ typedef struct
103104
const char *(*get_init_schema)(ss_plugin_schema_type *schema_type);
104105

105106
//
106-
// Initialize the plugin and allocate its non-NULL state.
107+
// Initialize the plugin and allocate its state.
107108
// Required: yes
108109
// Arguments:
109110
// - config: a string with the plugin configuration. The format of the
110111
// string is chosen by the plugin itself.
111112
// - rc: pointer to a ss_plugin_rc that will contain the initialization result
112113
// Return value: pointer to the plugin state that will be treated as opaque
113-
// by the engine and passed to the other plugin functions.
114+
// by the framework and passed to the other plugin functions.
114115
// If rc is SS_PLUGIN_FAILURE, this function may return NULL or a state to
115116
// later retrieve the error string.
116-
//
117+
//
118+
// If a non-NULL ss_plugin_t* state is returned, then subsequent invocations
119+
// of init() must not return the same ss_plugin_t* value again, if not after
120+
// it has been disposed with destroy() first.
117121
ss_plugin_t *(*init)(const char *config, ss_plugin_rc *rc);
118122

119123
//
@@ -129,7 +133,7 @@ typedef struct
129133
//
130134
// In cases where any other api function returns an error, the
131135
// plugin should be prepared to return a human-readable error
132-
// string with more context for the error. The plugin manager
136+
// string with more context for the error. The framework
133137
// calls get_last_error() to access that string.
134138
//
135139
const char *(*get_last_error)(ss_plugin_t *s);
@@ -143,13 +147,13 @@ typedef struct
143147

144148
//
145149
// Return the descriptions of the plugin, which will be printed when displaying
146-
// information about the plugin or its events.
150+
// information about the plugin.
147151
// Required: yes
148152
//
149153
const char *(*get_description)();
150154

151155
//
152-
// Return a string containing contact info (url, email, twitter, etc) for
156+
// Return a string containing contact info (url, email, etc) for
153157
// the plugin authors.
154158
// Required: yes
155159
//
@@ -161,14 +165,15 @@ typedef struct
161165
// Return value: a string with a version identifier, in the following format:
162166
// "<major>.<minor>.<patch>", e.g. "1.2.3".
163167
// This differs from the api version in that this versions the
164-
// plugin itself, as compared to the plugin interface. When
165-
// reading capture files, the major version of the plugin that
166-
// generated events must match the major version of the plugin
167-
// used to read events.
168+
// plugin itself. Note, increasing the major version signals breaking
169+
// changes in the plugin implementation but must not change the
170+
// serialization format of the event data. For example, events written
171+
// in pre-existing capture files must always be readable by newer versions
172+
// of the plugin.
168173
//
169174
const char *(*get_version)();
170175

171-
// Sourcing capabilities related
176+
// Event sourcing capability API
172177
struct
173178
{
174179
//
@@ -180,33 +185,38 @@ typedef struct
180185
uint32_t (*get_id)();
181186

182187
//
183-
// Return a string describing the events generated by this plugin with event sourcing capabilities.
188+
// Return a string representing the name of the event source generated
189+
// by this plugin.
184190
// Required: yes
185-
// Example event sources would be strings like "syscall",
186-
// "k8s_audit", etc. The source can be used by extractor
187-
// plugins to filter the events they receive.
191+
// Example event sources would be strings like "aws_cloudtrail",
192+
// "k8s_audit", etc. The source can be used by plugins with event
193+
// sourcing capabilities to filter the events they receive.
188194
//
189195
const char* (*get_event_source)();
190196

191197
//
192-
// Open the source and start a capture (e.g. stream of events)
198+
// Open the event source and start a capture (e.g. stream of events)
193199
// Required: yes
194200
// Arguments:
195201
// - s: the plugin state returned by init()
196-
// - params: the open parameters, as a string. The format is defined by the plugin
197-
// itsef
202+
// - params: the open parameters, as an opaque string.
203+
// The string format is defined by the plugin itself
198204
// - rc: pointer to a ss_plugin_rc that will contain the open result
199-
// Return value: a pointer to the open context that will be passed to next_batch(),
200-
// close(), event_to_string() and extract_fields.
205+
// Return value: a pointer to the opened plugin instance that will be
206+
// passed to next_batch(), close(), event_to_string()
207+
// and extract_fields().
201208
//
209+
// If a non-NULL ss_instance_t* instance is returned, then subsequent
210+
// invocations of open() must not return the same ss_instance_t* value
211+
// again, if not after it has been disposed with close() first.
202212
ss_instance_t* (*open)(ss_plugin_t* s, const char* params, ss_plugin_rc* rc);
203213

204214
//
205215
// Close a capture.
206216
// Required: yes
207217
// Arguments:
208-
// - s: the plugin context, returned by init(). Can be NULL.
209-
// - h: the capture context, returned by open(). Can be NULL.
218+
// - s: the plugin state, returned by init(). Can be NULL.
219+
// - h: the plugin instance, returned by open(). Can be NULL.
210220
//
211221
void (*close)(ss_plugin_t* s, ss_instance_t* h);
212222

@@ -215,14 +225,21 @@ typedef struct
215225
// Any of the values in the returned list are valid parameters for open().
216226
// Required: no
217227
// Return value: a string with the list of open params encoded as
218-
// a json array.
219-
// Each field entry is a json object with the following properties:
220-
// "value": a string usable as an open() parameter.
221-
// "desc": (optional) a string with a description of the parameter.
228+
// a json array. Each field entry is a json object with the following
229+
// properties:
230+
// - "value": a string usable as an open() parameter.
231+
// - "desc": (optional) a string with a description of the parameter.
232+
// - "separator": (optional) a separator string, for when "value"
233+
// represents multiple contatenated open parameters
222234
// Example return value:
223235
// [
224236
// {"value": "resource1", "desc": "An example of openable resource"},
225-
// {"value": "resource2", "desc": "Another example of openable resource"}
237+
// {"value": "resource2", "desc": "Another example of openable resource"},
238+
// {
239+
// "value": "res1;res2;res3",
240+
// "desc": "Some names",
241+
// "separator": ";"
242+
// }
226243
// ]
227244
const char* (*list_open_params)(ss_plugin_t* s, ss_plugin_rc* rc);
228245

@@ -231,7 +248,7 @@ typedef struct
231248
// Required: no
232249
// Arguments:
233250
// - progress_pct: the read progress, as a number between 0 (no data has been read)
234-
// and 10000 (100% of the data has been read). This encoding allows the engine to
251+
// and 10000 (100% of the data has been read). This encoding allows the framework to
235252
// print progress decimals without requiring to deal with floating point numbers
236253
// (which could cause incompatibility problems with some languages).
237254
// Return value: a string representation of the read
@@ -245,6 +262,11 @@ typedef struct
245262
// when possible, it's recommended as it provides valuable information to the
246263
// user.
247264
//
265+
// This function can be invoked concurrently by multiple threads,
266+
// each with distinct and unique parameter values.
267+
// If the returned pointer is non-NULL, then it must be uniquely
268+
// attached to the ss_instance_t* parameter value. The pointer must not
269+
// be shared across multiple distinct ss_instance_t* values.
248270
const char* (*get_progress)(ss_plugin_t* s, ss_instance_t* h, uint32_t* progress_pct);
249271

250272
//
@@ -261,6 +283,11 @@ typedef struct
261283
// and must not be deallocated or modified until the next call to
262284
// event_to_string().
263285
//
286+
// This function can be invoked concurrently by multiple threads,
287+
// each with distinct and unique parameter values.
288+
// If the returned pointer is non-NULL, then it must be uniquely
289+
// attached to the ss_plugin_t* parameter value. The pointer must not
290+
// be shared across multiple distinct ss_plugin_t* values.
264291
const char* (*event_to_string)(ss_plugin_t *s, const ss_plugin_event *evt);
265292

266293
//
@@ -275,10 +302,15 @@ typedef struct
275302
// next_batch() or close().
276303
// Required: yes
277304
//
305+
// This function can be invoked concurrently by multiple threads,
306+
// each with distinct and unique parameter values.
307+
// The value of the ss_plugin_event** output parameter must be uniquely
308+
// attached to the ss_instance_t* parameter value. The pointer must not
309+
// be shared across multiple distinct ss_instance_t* values.
278310
ss_plugin_rc (*next_batch)(ss_plugin_t* s, ss_instance_t* h, uint32_t *nevts, ss_plugin_event **evts);
279311
};
280312

281-
// Extraction capability related
313+
// Field extraction capability API
282314
struct
283315
{
284316
//
@@ -305,9 +337,6 @@ typedef struct
305337
// "type": one of "string", "uint64"
306338
// "isList: (optional) If present and set to true, notes
307339
// that the field extracts a list of values.
308-
// "argRequired": [DEPRECATED, use "arg" property instead]
309-
// (optional) If present and set to true, notes
310-
// that the field requires an argument e.g. field[arg].
311340
// "arg": (optional) if present, notes that the field can accept
312341
// an argument e.g. field[arg]. More precisely, the following
313342
// flags could be specified:
@@ -325,9 +354,8 @@ typedef struct
325354
// "desc": a string with a description of the field
326355
// Example return value:
327356
// [
328-
// {"type": "string", "name": "field1", "argRequired": true, "desc": "Describing field 1"}, [DEPRECATED 'argRequired' property]
329-
// {"type": "uint64", "name": "field2", "desc": "Describing field 2"},
330-
// {"type": "string", "name": "field3", "arg": {"isRequired": true, "isIndex": true,}, "desc": "Describing field 3"},
357+
// {"type": "uint64", "name": "field1", "desc": "Describing field 1"},
358+
// {"type": "string", "name": "field2", "arg": {"isRequired": true, "isIndex": true}, "desc": "Describing field 2"},
331359
// ]
332360
const char* (*get_fields)();
333361

@@ -348,6 +376,11 @@ typedef struct
348376
//
349377
// Return value: A ss_plugin_rc with values SS_PLUGIN_SUCCESS or SS_PLUGIN_FAILURE.
350378
//
379+
// This function can be invoked concurrently by multiple threads,
380+
// each with distinct and unique parameter values.
381+
// The value of the ss_plugin_extract_field* output parameter must be
382+
// uniquely attached to the ss_plugin_t* parameter value. The pointer
383+
// must not be shared across multiple distinct ss_plugin_t* values.
351384
ss_plugin_rc (*extract_fields)(ss_plugin_t *s, const ss_plugin_event *evt, uint32_t num_fields, ss_plugin_extract_field *fields);
352385
};
353386
} plugin_api;

0 commit comments

Comments
 (0)