Skip to content

update(api): Add value offset support #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 11, 2025

Conversation

geraldcombs
Copy link
Contributor

@geraldcombs geraldcombs commented Mar 21, 2025

Add support for setting value offsets during extraction.

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area plugin-sdk

/area tests

What this PR does / why we need it:

This makes it possible to extend extractor plugins so that they can provide the location of each field in each event or log message.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

update(pkg/sdk): add field metadata support

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the SDK's extraction API by adding support for a new field type, FieldMetaTypeSlice, which allows extractor plugins to report field metadata (i.e. the start and end positions of fields).

  • Updated the extract request interface and its SetValue method to support a two-element uint32 pair for metadata.
  • Added new symbols and tests in the info and extract test files to validate the metadata extraction capability.
  • Enhanced the plugin Info structure and documentation to reflect the new metadata capability.

Reviewed Changes

Copilot reviewed 8 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/sdk/extract.go Extended SetValue to support FieldMetaTypeSlice
pkg/sdk/symbols/info/info.go Added get_extract_metadata_capability symbol
pkg/sdk/symbols/info/info_test.go Added tests for extracting metadata capability
pkg/sdk/sdk.go Defined new constant FieldMetaTypeSlice
pkg/sdk/extract_test.go Added helper and tests for the metadata slice extraction
pkg/sdk/plugins/plugins.go Updated Info struct to include metadata capability
pkg/sdk/symbols/doc.go Updated documentation to list get_extract_metadata_capability
Files not reviewed (7)
  • Makefile: Language not supported
  • pkg/loader/plugin_api_include.patch: Language not supported
  • pkg/loader/plugin_loader.c: Language not supported
  • pkg/loader/plugin_loader.h: Language not supported
  • pkg/loader/strlcpy.patch: Language not supported
  • pkg/sdk/plugin_types.h: Language not supported
  • pkg/sdk/plugin_types_include.patch: Language not supported
Comments suppressed due to low confidence (1)

pkg/sdk/extract.go:362

  • [nitpick] The panic message for unsupported lists of slices is terse. Consider enhancing it with additional context about the memory layout restriction that prevents lists of slices from being supported.
case FieldMetaTypeSlice:

@leogr
Copy link
Member

leogr commented Mar 21, 2025

/hold depend on falcosecurity/libs#2322

@geraldcombs geraldcombs force-pushed the slice-ftype branch 12 times, most recently from 3210c82 to f1e688d Compare March 24, 2025 23:16
@geraldcombs geraldcombs force-pushed the slice-ftype branch 4 times, most recently from 3fb7eeb to 918aacb Compare April 10, 2025 00:50
@geraldcombs geraldcombs changed the title update(api): Add field metadata support update(api): Add value offset support Apr 10, 2025
@geraldcombs geraldcombs force-pushed the slice-ftype branch 2 times, most recently from b919b5e to b02a6c2 Compare May 28, 2025 18:13
@geraldcombs geraldcombs force-pushed the slice-ftype branch 3 times, most recently from f334e6b to 41e2df3 Compare June 3, 2025 00:24
Add support for setting value offsets during extraction.

Signed-off-by: Gerald Combs <[email protected]>
leogr and others added 5 commits June 4, 2025 18:19
Signed-off-by: Leonardo Grasso <[email protected]>
Signed-off-by: Leonardo Grasso <[email protected]>
Co-authored-by: Gerald Combs <[email protected]>
Co-authored-by: Leonardo Di Giovanna <[email protected]>
Signed-off-by: Leonardo Grasso <[email protected]>
Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just found an issue (see the comment below); otherwise, SGTM.

By the way, I can try to work on addressing this last thing.

Comment on lines 185 to 186
C.free(e.startArrayPtr)
C.free(e.lengthArrayPtr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is precisely what I wanted to do from the beginning. Unfortunately, it's not enough since memory is allocated multiple times here by calloc in plugin_extract_fields_sync() (which is invoked on every extraction request) and freed only once here (when the extractRequestPool gets cleaned up by plugin_close()).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my tentative: 1ffcf7a

@poiana
Copy link

poiana commented Jun 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana
Copy link

poiana commented Jun 10, 2025

LGTM label has been added.

Git tree hash: 77cb41db82471aabc4a8ad85006dedb50bc2d0a0

@leogr
Copy link
Member

leogr commented Jun 11, 2025

/hold cancel

@poiana poiana merged commit 3fdac75 into falcosecurity:main Jun 11, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants