appsec: integrate the new purego-based go-libddwaf#2090
Merged
Conversation
BenchmarksBenchmark execution time: 2023-07-05 13:18:51 Comparing candidate commit c753165 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics. |
Contributor
|
Should we wait until the go-libddwaf final PR is merged to merge this one ? |
Julio-Guerra
added a commit
to DataDog/go-libddwaf
that referenced
this pull request
Jul 5, 2023
- `func Load() (ok bool, err error)` to ease the integration in dd-trace-go so that we can distinguish the different possible error cases: - Panic errors that must be used to gracefully abort the caller and prevent it from continuing. Such errors are represented by the new `PanicError` error type. - Unsupported target OS and/or architecture, which must be handled as an informative error, is worth logging to the user, and prevents the caller from continuing. This error is represented by the new `UnsupportedTarget` error type. - Every other unexpected error that can possible happen is returned as-is, but `ok` is `false`, so that the caller knows it cannot use the package. - Informative errors, about internal non-critical failures, can also happen (eg. if os.Remove fails removing the temporary files), and are returned as-is, but with `ok` being `true` so that the caller can log the error and continue its startup. - The dd-trace-go integration of this PR can be found here DataDog/dd-trace-go#2090 - Note that `Health()` has been kept for the sake of simplicity health-checking cases such as in the tests, where it returns the `Load()` error only if `ok` is false, meaning that go-libddwaf is not healthy. - Simplified build tags, removed everywhere it was possible, down to purego which isn't properly stubbed for unsupported targets and which we stub ourselves at our level in the new `waf_dl_unsupported.go` file. --------- Co-authored-by: Eliott Bouhana <[email protected]> Co-authored-by: François Mazeau <[email protected]>
Hellzy
reviewed
Jul 5, 2023
Hellzy
left a comment
Contributor
There was a problem hiding this comment.
LGTM overall, a a few comments about debug logs
eliottness
reviewed
Jul 5, 2023
eliottness
approved these changes
Jul 5, 2023
Hellzy
approved these changes
Jul 5, 2023
katiehockman
approved these changes
Jul 5, 2023
katiehockman
left a comment
Contributor
There was a problem hiding this comment.
Didn't review the code, but the overall idea looks good. This is so awesome!
Approving just based on the go.mod and go.sum files. LMK if you want another set of eyes on the internal/appsec changes you made here, too, and I can check it out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This go-libddwaf version now relies on the dynamic liddwaf library instead of the static one, via
dlopen()anddlsym()internally.This allows us to no longer rely on CGO at compilation time, with all the requirements it needed such as a proper C toolchain. To do so, we now rely on https://github.com/ebitengine/purego which mainly provides a high-level API on top of
runtime/cgoto call the C world.The overall API of the package didn't change, but we split the former
Health()function in two to better integrate it into dd-trace-go and handle the different failure points correctly:Motivation
No more CGO prerequisites, mainly:
Describe how to test/QA your changes
Reviewer's Checklist