falcosecurity / plugin-sdk-go

Falco plugins SDK for Go
Apache License 2.0
26 stars 17 forks source link

new: support schema for plugin init configuration with automatic validation #35

Closed jasondellaluce closed 2 years ago

jasondellaluce commented 2 years ago

What type of PR is this?

/kind design

/kind feature

Any specific area of the project related to this PR?

/area plugin-sdk

/area tests

What this PR does / why we need it:

Following the updates of https://github.com/falcosecurity/libs/pull/175, this PR adds support for the get_init_schema function symbol to the Go SDK. An example of usage of the functionality, with ad-hoc documentation, is provided by updating the full plugin example.

The new interface sdk.InitSchema has been introduce to return a pointer to a sdk.SchemaInfo. sdk.SchemaInfo is a container for the returned schema, and can be updated in the future to also support schema types other than JSON Schema, if ever supported. As for now, InitSchema() is expected to return a valid JSON Schema.

Plugins can implement sdk.InitSchema optionally. If implemented, the Init() method must expect a JSON string to be passed as a configuration, and can assume it to always be well-formed and automatically checked against the provided schema by the plugin framework. If not implemented, the init config must be considered as an opaque string (like we already do right now).

Which issue(s) this PR fixes:

Special notes for your reviewer:

This depends on https://github.com/falcosecurity/libs/pull/175 and is noted as WIP until it gets merged.

Does this PR introduce a user-facing change?:

new: support schema for plugin init configuration with automatic validation
poiana commented 2 years ago

LGTM label has been added.

Git tree hash: 07e60a711d73f46476874e7e517061e0f257525e

poiana commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jasondellaluce, leogr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/falcosecurity/plugin-sdk-go/blob/main/OWNERS)~~ [jasondellaluce,leogr] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment