-
Notifications
You must be signed in to change notification settings - Fork 164
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
new(libsinsp): add basename() string transformer #1943
new(libsinsp): add basename() string transformer #1943
Conversation
/milestone 0.18.0 |
ff3e980
to
4fc8899
Compare
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
Signed-off-by: Luca Guerra <luca@guerra.sh>
4fc8899
to
38e9b21
Compare
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM label has been added. Git tree hash: c650bfe49234fab8bece68f6594e8b52ec42845a
|
case FTR_BASENAME: | ||
{ | ||
return string_transformer(vec, t, [](std::string_view in, storage_t& out) -> bool { | ||
auto last_slash_pos = in.find_last_of("/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, why can't we directly use posix basename
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we also build for Windows and MacOS, which are not guaranteed to have POSIX compatible functions. Especially on Windows a basename function would expect backslashes instead of slashes potentially making reading Linux scap files a bit of a headache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, LucaGuerra 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 |
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
No
What this PR does / why we need it:
Introduce
basename()
as transformer. This allows, for instance, to write expressions likebasename(proc.exepath) = cat
to match against the original executable name even if it has been symlinked without knowing the full path, or any other file name based detection.Which issue(s) this PR fixes:
Fixes #1927
Special notes for your reviewer:
Does this PR introduce a user-facing change?: