-
Notifications
You must be signed in to change notification settings - Fork 2
feat: upgrade libddwaf v1.25.1 -> v1.28.1 #151
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ff57962
feat: upgrade libddwaf v1.25.1 -> v1.28.1
eliottness 24216b7
remove custom json decoder in favor of ddwaf_object_from_json
eliottness bb8d0ab
fix prototype
eliottness 0cfa7c1
rotate all images
eliottness 189a16d
newWAFLib
eliottness a2492bf
ruleset unsupported
eliottness File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
|
|
||
| cd $(dirname $0) | ||
| cd "$(dirname "$0")" || exit | ||
| exec go run ./update.go "$@" |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016-present Datadog, Inc. | ||
|
|
||
| package bindings | ||
|
|
||
| import ( | ||
| "errors" | ||
| "sync" | ||
|
|
||
| "github.com/DataDog/go-libddwaf/v4/internal/support" | ||
| ) | ||
|
|
||
| // Globally dlopen() libddwaf only once because several dlopens (eg. in tests) | ||
| // aren't supported by macOS. | ||
| var ( | ||
| // Lib is libddwaf's dynamic library handle and entrypoints. This is only safe to | ||
| // read after calling [Load] or having acquired [gMu]. | ||
| Lib *WAFLib | ||
| // libddwaf's dlopen error if any. This is only safe to read after calling | ||
| // [Load] or having acquired [gMu]. | ||
| gWafLoadErr error | ||
| // Protects the global variables above. | ||
| gMu sync.Mutex | ||
|
|
||
| openWafOnce sync.Once | ||
| ) | ||
|
|
||
| // Load loads libddwaf's dynamic library. The dynamic library is opened only | ||
| // once by the first call to this function and internally stored globally. | ||
| // No function is currently provided in this API to unload it. | ||
| // | ||
| // This function is automatically called by [NewBuilder], and most users need | ||
| // not explicitly call it. It is however useful in order to explicitly check | ||
| // for the status of the Lib library's initialization. | ||
| // | ||
| // The function returns true when libddwaf was successfully loaded, along with | ||
| // an error value. An error might still be returned even though the Lib load was | ||
| // successful: in such cases the error is indicative that some non-critical | ||
| // features are not available; but the Lib may still be used. | ||
| func Load() (bool, error) { | ||
| if ok, err := Usable(); !ok { | ||
| return false, err | ||
| } | ||
|
|
||
| openWafOnce.Do(func() { | ||
| // Acquire the global state mutex so we don't have a race condition with | ||
| // [Usable] here. | ||
| gMu.Lock() | ||
| defer gMu.Unlock() | ||
|
|
||
| Lib, gWafLoadErr = newWAFLib() | ||
| if gWafLoadErr != nil { | ||
| return | ||
| } | ||
| wafVersion = Lib.GetVersion() | ||
| }) | ||
|
|
||
| return Lib != nil, gWafLoadErr | ||
| } | ||
|
|
||
| var wafVersion string | ||
|
|
||
| // Version returns the version returned by libddwaf. | ||
| // It relies on the dynamic loading of the library, which can fail and return | ||
| // an empty string or the previously loaded version, if any. | ||
| func Version() string { | ||
| _, _ = Load() | ||
| return wafVersion | ||
| } | ||
|
|
||
| // Usable returns true if the Lib is usable, false and an error otherwise. | ||
| // | ||
| // If the Lib is usable, an error value may still be returned and should be | ||
| // treated as a warning (it is non-blocking). | ||
| // | ||
| // The following conditions are checked: | ||
| // - The Lib library has been loaded successfully (you need to call [Load] first for this case to be | ||
| // taken into account) | ||
| // - The Lib library has not been manually disabled with the `datadog.no_waf` go build tag | ||
| // - The Lib library is not in an unsupported OS/Arch | ||
| // - The Lib library is not in an unsupported Go version | ||
| func Usable() (bool, error) { | ||
| wafSupportErrors := errors.Join(support.WafSupportErrors()...) | ||
| wafManuallyDisabledErr := support.WafManuallyDisabledError() | ||
|
|
||
| // Acquire the global state mutex as we are not calling [Load] here, so we | ||
| // need to explicitly avoid a race condition with it. | ||
| gMu.Lock() | ||
| defer gMu.Unlock() | ||
| return (Lib != nil || gWafLoadErr == nil) && wafSupportErrors == nil && wafManuallyDisabledErr == nil, errors.Join(gWafLoadErr, wafSupportErrors, wafManuallyDisabledErr) | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1.25.1 | ||
| 1.28.1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
macos-latest-large is the only amd64 image available under macos now