-
Notifications
You must be signed in to change notification settings - Fork 462
appsec: integrate the new purego-based go-libddwaf #2090
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
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. |
Should we wait until the go-libddwaf final PR is merged to merge this one ? |
- `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 <47679741+eliottness@users.noreply.github.com> Co-authored-by: François Mazeau <francois.mazeau@datadoghq.com>
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 overall, a a few comments about debug logs
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.
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.
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/cgo
to 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