libddwaf 1.24.1.0.0-aarch64-linux → 1.24.1.0.3-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +124 -0
- data/lib/datadog/appsec/waf/handle.rb +0 -1
- data/lib/datadog/appsec/waf/lib_ddwaf.rb +3 -36
- data/lib/datadog/appsec/waf/version.rb +1 -1
- data/libddwaf.gemspec +43 -0
- data/sig/datadog/appsec/waf/context.rbs +29 -0
- data/sig/datadog/appsec/waf/converter.rbs +11 -0
- data/sig/datadog/appsec/waf/errors.rbs +20 -0
- data/sig/datadog/appsec/waf/handle.rbs +21 -0
- data/sig/datadog/appsec/waf/handle_builder.rbs +23 -0
- data/sig/datadog/appsec/waf/lib_ddwaf.rbs +158 -0
- data/sig/datadog/appsec/waf/result.rbs +33 -0
- data/sig/datadog/appsec/waf/version.rbs +13 -0
- data/sig/datadog/appsec/waf.rbs +16 -0
- data/sig/libddwaf.rbs +0 -0
- data/vendor/rbs/gem/0/gem.rbs +7 -0
- data/vendor/rbs/jruby/0/jruby.rbs +3 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94f0f27a08d18b3e1d41ad75c96edd62c01d1d22c2d69e5d6c8f2f4f98bd8172
|
4
|
+
data.tar.gz: 732d929052278441c9b5d95cd7f9ad1a52917d4af267b5803d7e90e7760d5532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43139856cbb68e3be10d6d35aa412783a9396f2038f48f39ec297f2db13046e0185fd2a24e581bf2cb2b0294d9e461a4d9416023208f4468fe58b7778d4c875e
|
7
|
+
data.tar.gz: d1f5f32f20ad0abbb544e66dec7e81f655fd1892eca8a3d89f0be771abbab85eacecc50c08fa590e754cbf2b3b48089798c6e28edf84b2b400d84b4c67879284
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# libddwaf Ruby bindings
|
2
|
+
|
3
|
+
``libddwaf-rb`` is library exposing the libddwaf C++ library to Ruby, packaging it in a multiplatform gem.
|
4
|
+
|
5
|
+
For the libddwaf implementation, see this repository:
|
6
|
+
- [``libddwaf``: libddwaf](https://github.com/DataDog/libddwaf.git)
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## Rake tasks
|
11
|
+
|
12
|
+
### Outline
|
13
|
+
|
14
|
+
A typical workflow is as follows:
|
15
|
+
|
16
|
+
```
|
17
|
+
rake fetch # fetch prebuilt libddwaf binaries tarball in vendor/libddwaf
|
18
|
+
rake extract # extract downloaded tarball in vendor/libddwaf
|
19
|
+
rake spec # run rspec
|
20
|
+
rake binary # build the gem
|
21
|
+
```
|
22
|
+
|
23
|
+
Note that each depends on the previous one, but `fetch` and `extract` are lazy, which proves useful to produce manual builds.
|
24
|
+
|
25
|
+
### Platform selection
|
26
|
+
|
27
|
+
By default the above will automatically use the local Ruby platform.
|
28
|
+
|
29
|
+
Since libddwaf binary builds are available upstream, it's possible to build gems for any platform on any other platform. To that end `fetch`, `extract`, and `binary` can take an argument to specify the Ruby platform for which these operations should apply:
|
30
|
+
|
31
|
+
```
|
32
|
+
rake fetch[x86_64-linux-musl]
|
33
|
+
rake extract[x86_64-linux-musl]
|
34
|
+
rake binary[x86_64-linux-musl]
|
35
|
+
```
|
36
|
+
|
37
|
+
Of course you can't force the platform for `rspec` since that requires running code; see the Docker section below for ways to achieve that.
|
38
|
+
|
39
|
+
Note that zsh gives special meaning to brackets, therefore you may need to quote the argument:
|
40
|
+
|
41
|
+
```
|
42
|
+
rake 'fetch[x86_64-linux-musl]'
|
43
|
+
```
|
44
|
+
|
45
|
+
Available platforms are:
|
46
|
+
|
47
|
+
```
|
48
|
+
x86_64-linux-musl # Alpine build: targets musl-based Linux
|
49
|
+
x86_64-linux-gnu # Debian build: targets glibc-based Linux
|
50
|
+
x86_64-linux # Portable build: targets multiple linux libc
|
51
|
+
x86_64-darwin # Darwin build: targets macOS
|
52
|
+
aarch64-linux-musl # Same as above, for ARMv8
|
53
|
+
aarch64-linux-gnu # Same as above, for ARMv8
|
54
|
+
aarch64-linux # Same as above, for ARMv8
|
55
|
+
arm64-darwin # Same as above, for Apple Silicon
|
56
|
+
java # JRuby build, universal
|
57
|
+
```
|
58
|
+
|
59
|
+
Note: since it is not (yet) possible to package gems for the `java` Ruby platform any other way than `java`, it has to package all the native architectures.
|
60
|
+
|
61
|
+
In addition, options can be specified for the portable build:
|
62
|
+
|
63
|
+
```
|
64
|
+
rake binary[x86_64-linux:gnu+musl] # Combined build: combine musl and glibc builds, selecting one at runtime
|
65
|
+
rake binary[x86_64-linux:llvm] # Hybrid build: linked to llvm static libs and built against a musl sysroot
|
66
|
+
```
|
67
|
+
|
68
|
+
See upstream libddwaf for details about the [hybrid portable build](https://github.com/DataDog/libddwaf/blob/master/docker/libddwaf/README.md).
|
69
|
+
|
70
|
+
## Testing with Docker
|
71
|
+
|
72
|
+
Unless using Docker for Mac, remember to enable foreign CPU emulation via QEMU:
|
73
|
+
|
74
|
+
```
|
75
|
+
# aarch64 on x86_64 hardware
|
76
|
+
docker run --privileged --rm tonistiigi/binfmt --install arm64
|
77
|
+
# x86_64 on aarch64 hardware
|
78
|
+
docker run --privileged --rm tonistiigi/binfmt --install amd64
|
79
|
+
```
|
80
|
+
|
81
|
+
Then you can substitute e.g `--platform linux/x86_64` with `--platform linux/aarch64` below.
|
82
|
+
|
83
|
+
### GNU (Debian)
|
84
|
+
|
85
|
+
```
|
86
|
+
# this is too old for aarch64
|
87
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.1 sh -c 'rm -fv Gemfile.lock && gem install bundler -v "~> 1.17" && bundle install && bundle exec rake spec'
|
88
|
+
# these are fine for aarch64
|
89
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.2 sh -c 'rm -fv Gemfile.lock && gem install bundler -v "~> 1.17" && bundle install && bundle exec rake spec'
|
90
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.3 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
91
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.4 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
92
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.5 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
93
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.6 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
94
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.7 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
95
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:3.0 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
96
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:3.1 sh -c 'rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
97
|
+
```
|
98
|
+
|
99
|
+
### musl (Alpine)
|
100
|
+
|
101
|
+
```
|
102
|
+
# these are too old for aarch64
|
103
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.1-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler -v "~> 1.17" && bundle install && bundle exec rake spec'
|
104
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.2-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler -v "~> 1.17" && bundle install && bundle exec rake spec'
|
105
|
+
# these are fine for aarch64
|
106
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.3-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
107
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.4-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
108
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.5-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
109
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.6-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
110
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:2.7-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
111
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:3.0-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
112
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:3.1-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
113
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" ruby:3.1-alpine sh -c 'apk update && apk add build-base git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
114
|
+
```
|
115
|
+
|
116
|
+
### JRuby
|
117
|
+
|
118
|
+
```
|
119
|
+
# these are too old for aarch64
|
120
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" jruby:9.2.8.0 sh -c 'apt-get update && apt-get install -y build-essential git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
121
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" jruby:9.3.0.0 sh -c 'apt-get update && apt-get install -y build-essential git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
122
|
+
# this is fine for aarch64
|
123
|
+
docker run --rm -it --platform linux/x86_64 -v "${PWD}":"${PWD}" -w "${PWD}" jruby:9.3.4.0 sh -c 'apt-get update && apt-get install -y build-essential git && rm -fv Gemfile.lock && gem install bundler:2.2.22 && bundle install && bundle exec rake spec'
|
124
|
+
```
|
@@ -37,15 +37,6 @@ module Datadog
|
|
37
37
|
Gem::Platform.local.os
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.local_version
|
41
|
-
return nil unless local_os == "linux"
|
42
|
-
|
43
|
-
# Old rubygems don't handle non-gnu linux correctly
|
44
|
-
return ::Regexp.last_match(1) if RUBY_PLATFORM =~ /linux-(.+)$/
|
45
|
-
|
46
|
-
"gnu"
|
47
|
-
end
|
48
|
-
|
49
40
|
def self.local_cpu
|
50
41
|
if RUBY_ENGINE == "jruby"
|
51
42
|
os_arch = java.lang.System.get_property("os.arch")
|
@@ -66,33 +57,6 @@ module Datadog
|
|
66
57
|
__dir__ || raise("__dir__ is nil: eval?")
|
67
58
|
end
|
68
59
|
|
69
|
-
def self.vendor_dir
|
70
|
-
File.join(source_dir, "../../../../vendor")
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.libddwaf_vendor_dir
|
74
|
-
File.join(vendor_dir, "libddwaf")
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.shared_lib_triplet(version: local_version)
|
78
|
-
version ? "#{local_os}-#{version}-#{local_cpu}" : "#{local_os}-#{local_cpu}"
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.libddwaf_dir
|
82
|
-
default = File.join(libddwaf_vendor_dir,
|
83
|
-
"libddwaf-#{Datadog::AppSec::WAF::VERSION::BASE_STRING}-#{shared_lib_triplet}")
|
84
|
-
candidates = [
|
85
|
-
default
|
86
|
-
]
|
87
|
-
|
88
|
-
if local_os == "linux"
|
89
|
-
candidates << File.join(libddwaf_vendor_dir,
|
90
|
-
"libddwaf-#{Datadog::AppSec::WAF::VERSION::BASE_STRING}-#{shared_lib_triplet(version: nil)}")
|
91
|
-
end
|
92
|
-
|
93
|
-
candidates.find { |d| Dir.exist?(d) } || default
|
94
|
-
end
|
95
|
-
|
96
60
|
def self.shared_lib_extname
|
97
61
|
if Gem::Platform.local.os == "darwin"
|
98
62
|
".dylib"
|
@@ -104,6 +68,9 @@ module Datadog
|
|
104
68
|
end
|
105
69
|
|
106
70
|
def self.shared_lib_path
|
71
|
+
variant = "#{Datadog::AppSec::WAF::VERSION::BASE_STRING}-#{local_os}-#{local_cpu}"
|
72
|
+
libddwaf_dir = File.join(source_dir, "../../../../vendor/libddwaf/libddwaf-#{variant}")
|
73
|
+
|
107
74
|
File.join(libddwaf_dir, "lib", "libddwaf#{shared_lib_extname}")
|
108
75
|
end
|
109
76
|
|
@@ -5,7 +5,7 @@ module Datadog
|
|
5
5
|
BASE_STRING = "1.24.1"
|
6
6
|
# NOTE: Every change to the `BASE_STRING` should be accompanied
|
7
7
|
# by a reset of the patch version in the `STRING` below.
|
8
|
-
STRING = "#{BASE_STRING}.0.
|
8
|
+
STRING = "#{BASE_STRING}.0.3"
|
9
9
|
MINIMUM_RUBY_VERSION = "2.5"
|
10
10
|
end
|
11
11
|
end
|
data/libddwaf.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "datadog/appsec/waf/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "libddwaf"
|
7
|
+
spec.version = Datadog::AppSec::WAF::VERSION::STRING
|
8
|
+
spec.required_ruby_version = [">= #{Datadog::AppSec::WAF::VERSION::MINIMUM_RUBY_VERSION}"]
|
9
|
+
spec.required_rubygems_version = ">= 2.0.0"
|
10
|
+
spec.authors = ["Datadog, Inc."]
|
11
|
+
spec.email = ["dev@datadoghq.com"]
|
12
|
+
|
13
|
+
spec.summary = "Datadog WAF"
|
14
|
+
spec.description = <<-EOS.gsub(/^[\s]+/, "")
|
15
|
+
libddwaf packages a WAF implementation in C++, exposed to Ruby
|
16
|
+
EOS
|
17
|
+
|
18
|
+
spec.homepage = "https://github.com/DataDog/libddwaf-rb"
|
19
|
+
spec.license = "BSD-3-Clause"
|
20
|
+
|
21
|
+
if spec.respond_to?(:metadata)
|
22
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
libddwaf_version = Datadog::AppSec::WAF::VERSION::BASE_STRING
|
28
|
+
|
29
|
+
spec.files = ["libddwaf.gemspec"]
|
30
|
+
spec.files.concat(Dir.glob("lib/**/*.rb"))
|
31
|
+
spec.files.concat(Dir.glob("{vendor/rbs,sig}/**/*.rbs"))
|
32
|
+
spec.files.concat(Dir.glob("{README,CHANGELOG,LICENSE,NOTICE}*"))
|
33
|
+
spec.files.concat(%W[
|
34
|
+
vendor/libddwaf/libddwaf-#{libddwaf_version}-darwin-arm64/lib/libddwaf.dylib
|
35
|
+
vendor/libddwaf/libddwaf-#{libddwaf_version}-darwin-x86_64/lib/libddwaf.dylib
|
36
|
+
vendor/libddwaf/libddwaf-#{libddwaf_version}-linux-aarch64/lib/libddwaf.so
|
37
|
+
vendor/libddwaf/libddwaf-#{libddwaf_version}-linux-x86_64/lib/libddwaf.so
|
38
|
+
])
|
39
|
+
|
40
|
+
spec.require_paths = ["lib"]
|
41
|
+
|
42
|
+
spec.add_dependency "ffi", "~> 1.0"
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
class Context
|
5
|
+
@context_ptr: ::FFI::Pointer
|
6
|
+
|
7
|
+
@retained: Array[untyped]
|
8
|
+
|
9
|
+
RESULT_CODE: ::Hash[::Symbol, ::Symbol]
|
10
|
+
|
11
|
+
def initialize: (::FFI::Pointer context_ptr) -> void
|
12
|
+
|
13
|
+
def finalize!: () -> void
|
14
|
+
|
15
|
+
def run: (WAF::data persistent_data, WAF::data ephemeral_data, ?::Integer timeout) -> Result
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def ensure_pointer_presence!: () -> void
|
20
|
+
|
21
|
+
def retained: () -> Array[untyped]
|
22
|
+
|
23
|
+
def retain: (top object) -> void
|
24
|
+
|
25
|
+
def release: (top object) -> void
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
module Converter
|
5
|
+
def self.ruby_to_object: (top val, ?max_container_size: ::Integer?, ?max_container_depth: ::Integer?, ?max_string_length: ::Integer?, ?coerce: bool?) -> LibDDWAF::Object
|
6
|
+
|
7
|
+
def self.object_to_ruby: (LibDDWAF::Object obj) -> WAF::data
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
class Error < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class InstanceFinalizedError < Error
|
8
|
+
end
|
9
|
+
|
10
|
+
class ConversionError < Error
|
11
|
+
end
|
12
|
+
|
13
|
+
class LibDDWAFError < Error
|
14
|
+
attr_reader diagnostics: WAF::data
|
15
|
+
|
16
|
+
def initialize: (::String msg, ?diagnostics: WAF::data?) -> void
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
class Handle
|
5
|
+
@handle_ptr: ::FFI::Pointer
|
6
|
+
|
7
|
+
def initialize: (::FFI::Pointer handle_ptr) -> void
|
8
|
+
|
9
|
+
def finalize!: () -> void
|
10
|
+
|
11
|
+
def build_context: () -> Context
|
12
|
+
|
13
|
+
def known_addresses: () -> ::Array[::String?]
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def ensure_pointer_presence!: () -> void
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
class HandleBuilder
|
5
|
+
@builder_ptr: ::FFI::Pointer
|
6
|
+
|
7
|
+
def initialize: (?limits: ::Hash[::Symbol, ::Integer], ?obfuscator: ::Hash[::Symbol, ::String]) -> void
|
8
|
+
|
9
|
+
def finalize!: () -> void
|
10
|
+
|
11
|
+
def build_handle: () -> Handle
|
12
|
+
|
13
|
+
def add_or_update_config: (data config, path: ::String) -> data
|
14
|
+
|
15
|
+
def remove_config_at_path: (::String path) -> bool
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def ensure_pointer_presence!: () -> void
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
module LibDDWAF
|
5
|
+
DEFAULT_MAX_CONTAINER_SIZE: ::Integer
|
6
|
+
DEFAULT_MAX_CONTAINER_DEPTH: ::Integer
|
7
|
+
DEFAULT_MAX_STRING_LENGTH: ::Integer
|
8
|
+
|
9
|
+
DDWAF_MAX_CONTAINER_SIZE: ::Integer
|
10
|
+
DDWAF_MAX_CONTAINER_DEPTH: ::Integer
|
11
|
+
DDWAF_MAX_STRING_LENGTH: ::Integer
|
12
|
+
|
13
|
+
DDWAF_RUN_TIMEOUT: ::Integer
|
14
|
+
|
15
|
+
extend ::FFI::Library
|
16
|
+
|
17
|
+
def self.typedef: [T < ::FFI::Type, N, R, C] (T old, Symbol | ::FFI::DataConverter[N, R, C] add, ?untyped) -> T
|
18
|
+
| (Symbol old, Symbol add, ?untyped) -> (::FFI::Type | ::FFI::Enum)
|
19
|
+
| [X < ::FFI::DataConverter[N, R, C], N, R, C] (X old, Symbol add, ?untyped) -> ::FFI::Type::Mapped[X, N, R, C]
|
20
|
+
| (:enum old, Array[Symbol | Integer] add, ?untyped) -> ::FFI::Enum
|
21
|
+
| (:enum old, Symbol | ::FFI::Type add, Array[Symbol | Integer] info) -> ::FFI::Enum
|
22
|
+
| (untyped, ::Symbol) -> void
|
23
|
+
|
24
|
+
def self.callback: (::Symbol name, Array[::FFI::Library::ffi_lib_type] params, ::FFI::Library::ffi_lib_type ret) -> ::FFI::CallbackInfo
|
25
|
+
|
26
|
+
def self.enum: (*(Symbol | Integer) args) -> ::FFI::Enum
|
27
|
+
| (Array[Symbol | Integer] values) -> ::FFI::Enum
|
28
|
+
|
29
|
+
def self.local_os: () -> ::String
|
30
|
+
def self.local_cpu: () -> ::String
|
31
|
+
def self.local_version: () -> (::String | nil)
|
32
|
+
def self.source_dir: () -> ::String
|
33
|
+
def self.vendor_dir: () -> ::String
|
34
|
+
def self.libddwaf_vendor_dir: () -> ::String
|
35
|
+
def self.shared_lib_triplet: (?version: ::String?) -> ::String
|
36
|
+
def self.libddwaf_dir: () -> ::String
|
37
|
+
def self.shared_lib_extname: () -> ::String
|
38
|
+
def self.shared_lib_path: () -> ::String
|
39
|
+
|
40
|
+
# version
|
41
|
+
|
42
|
+
def self.ddwaf_get_version: () -> ::String
|
43
|
+
|
44
|
+
# ddwaf::object data structure
|
45
|
+
|
46
|
+
DDWAF_OBJ_TYPE: ::FFI::Enum
|
47
|
+
|
48
|
+
class UInt32Ptr < ::FFI::Struct[::FFI::AbstractMemory, ::Integer]
|
49
|
+
end
|
50
|
+
|
51
|
+
class UInt64Ptr < ::FFI::Struct[::FFI::AbstractMemory, ::Integer]
|
52
|
+
end
|
53
|
+
|
54
|
+
class SizeTPtr < ::FFI::Struct[::FFI::AbstractMemory, ::Integer]
|
55
|
+
end
|
56
|
+
|
57
|
+
class ObjectValueUnion < ::FFI::Union[::FFI::AbstractMemory, untyped]
|
58
|
+
end
|
59
|
+
|
60
|
+
class Object < ::FFI::Struct[::FFI::AbstractMemory, untyped]
|
61
|
+
end
|
62
|
+
|
63
|
+
# setters
|
64
|
+
|
65
|
+
def self.ddwaf_object_invalid: (LibDDWAF::Object) -> ::FFI::Pointer
|
66
|
+
def self.ddwaf_object_string: (LibDDWAF::Object, ::String) -> ::FFI::Pointer
|
67
|
+
def self.ddwaf_object_stringl: (LibDDWAF::Object, ::String, ::Integer) -> ::FFI::Pointer
|
68
|
+
def self.ddwaf_object_stringl_nc: (LibDDWAF::Object, ::String, ::Integer) -> ::FFI::Pointer
|
69
|
+
def self.ddwaf_object_unsigned: (LibDDWAF::Object, ::Integer) -> ::FFI::Pointer
|
70
|
+
def self.ddwaf_object_signed: (LibDDWAF::Object, ::Integer) -> ::FFI::Pointer
|
71
|
+
def self.ddwaf_object_string_from_unsigned: (LibDDWAF::Object, ::Integer) -> ::FFI::Pointer
|
72
|
+
def self.ddwaf_object_string_from_signed: (LibDDWAF::Object, ::Integer) -> ::FFI::Pointer
|
73
|
+
def self.ddwaf_object_bool: (LibDDWAF::Object, bool) -> ::FFI::Pointer
|
74
|
+
def self.ddwaf_object_float: (LibDDWAF::Object, ::Float) -> ::FFI::Pointer
|
75
|
+
def self.ddwaf_object_null: (LibDDWAF::Object) -> ::FFI::Pointer
|
76
|
+
|
77
|
+
def self.ddwaf_object_array: (LibDDWAF::Object) -> ::FFI::Pointer
|
78
|
+
def self.ddwaf_object_array_add: (LibDDWAF::Object, LibDDWAF::Object) -> bool
|
79
|
+
|
80
|
+
def self.ddwaf_object_map: (LibDDWAF::Object) -> ::FFI::Pointer
|
81
|
+
def self.ddwaf_object_map_add: (LibDDWAF::Object, ::String, LibDDWAF::Object) -> bool
|
82
|
+
def self.ddwaf_object_map_addl: (LibDDWAF::Object, ::String, ::Integer, LibDDWAF::Object) -> bool
|
83
|
+
def self.ddwaf_object_map_addl_nc: (LibDDWAF::Object, ::String, ::Integer, LibDDWAF::Object) -> bool
|
84
|
+
|
85
|
+
# getters
|
86
|
+
|
87
|
+
def self.ddwaf_object_type: (LibDDWAF::Object) -> ::FFI::Enum
|
88
|
+
def self.ddwaf_object_size: (LibDDWAF::Object) -> ::Integer
|
89
|
+
def self.ddwaf_object_length: (LibDDWAF::Object) -> ::Integer
|
90
|
+
def self.ddwaf_object_get_key: (LibDDWAF::Object, SizeTPtr) -> ::String
|
91
|
+
def self.ddwaf_object_get_string: (LibDDWAF::Object, SizeTPtr) -> ::String
|
92
|
+
def self.ddwaf_object_get_unsigned: (LibDDWAF::Object, SizeTPtr) -> ::Integer
|
93
|
+
def self.ddwaf_object_get_signed: (LibDDWAF::Object, SizeTPtr) -> ::Integer
|
94
|
+
def self.ddwaf_object_get_index: (LibDDWAF::Object, ::Integer) -> LibDDWAF::Object
|
95
|
+
def self.ddwaf_object_get_bool: (LibDDWAF::Object) -> bool
|
96
|
+
def self.ddwaf_object_get_float: (LibDDWAF::Object) -> ::Float
|
97
|
+
|
98
|
+
# freeers
|
99
|
+
|
100
|
+
def self.ddwaf_object_free: (LibDDWAF::Object) -> void
|
101
|
+
|
102
|
+
ObjectFree: ::FFI::Function
|
103
|
+
ObjectNoFree: ::FFI::Pointer
|
104
|
+
|
105
|
+
# handle builder
|
106
|
+
|
107
|
+
def self.ddwaf_builder_init: (HandleBuilderConfig) -> ::FFI::Pointer
|
108
|
+
def self.ddwaf_builder_destroy: (::FFI::Pointer) -> void
|
109
|
+
|
110
|
+
def self.ddwaf_builder_add_or_update_config: (::FFI::Pointer, ::String, ::Integer, LibDDWAF::Object, LibDDWAF::Object) -> bool
|
111
|
+
def self.ddwaf_builder_remove_config: (::FFI::Pointer, ::String, ::Integer) -> bool
|
112
|
+
|
113
|
+
def self.ddwaf_builder_build_instance: (::FFI::Pointer) -> ::FFI::Pointer
|
114
|
+
|
115
|
+
# main handle
|
116
|
+
|
117
|
+
class HandleBuilderConfig < ::FFI::Struct[::FFI::AbstractMemory, untyped]
|
118
|
+
class Limits < ::FFI::Struct[::FFI::AbstractMemory, ::Integer]
|
119
|
+
end
|
120
|
+
|
121
|
+
class Obfuscator < ::FFI::Struct[::FFI::AbstractMemory, ::FFI::Pointer]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.ddwaf_destroy: (::FFI::Pointer) -> void
|
126
|
+
|
127
|
+
def self.ddwaf_known_addresses: (::FFI::Pointer, UInt32Ptr) -> ::FFI::Pointer
|
128
|
+
def self.ddwaf_rule_data_ids: (::FFI::Pointer, UInt32Ptr) -> ::FFI::Pointer
|
129
|
+
|
130
|
+
# updating
|
131
|
+
|
132
|
+
DDWAF_RET_CODE: ::FFI::Enum
|
133
|
+
|
134
|
+
# running
|
135
|
+
|
136
|
+
def self.ddwaf_context_init: (::FFI::Pointer) -> ::FFI::Pointer
|
137
|
+
def self.ddwaf_context_destroy: (::FFI::Pointer) -> void
|
138
|
+
|
139
|
+
class Result < ::FFI::Struct[::FFI::AbstractMemory, untyped]
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.ddwaf_run: (::FFI::Pointer, Object, Object, Result, ::Integer) -> ::Symbol
|
143
|
+
def self.ddwaf_result_free: (Result) -> void
|
144
|
+
|
145
|
+
# logging
|
146
|
+
|
147
|
+
DDWAF_LOG_LEVEL: ::FFI::Enum
|
148
|
+
|
149
|
+
type ddwaf_log_level = ::Symbol
|
150
|
+
|
151
|
+
# TODO: signature is as below but steep 1.1 does not yet support method/proc/block mapping
|
152
|
+
# type ddwaf_log_cb = ^(ddwaf_log_level, ::String, ::String, ::Integer, ::FFI::Pointer, ::Integer) -> void
|
153
|
+
type ddwaf_log_cb = ::Method | ::Proc
|
154
|
+
def self.ddwaf_set_log_cb: (ddwaf_log_cb, ddwaf_log_level) -> bool
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
class Result
|
5
|
+
@status: ::Symbol
|
6
|
+
|
7
|
+
@events: WAF::data
|
8
|
+
|
9
|
+
@total_runtime: ::Float
|
10
|
+
|
11
|
+
@timeout: bool
|
12
|
+
|
13
|
+
@actions: WAF::data
|
14
|
+
|
15
|
+
@derivatives: WAF::data
|
16
|
+
|
17
|
+
attr_reader status: ::Symbol
|
18
|
+
|
19
|
+
attr_reader events: WAF::data
|
20
|
+
|
21
|
+
attr_reader total_runtime: ::Float
|
22
|
+
|
23
|
+
attr_reader timeout: bool
|
24
|
+
|
25
|
+
attr_reader actions: WAF::data
|
26
|
+
|
27
|
+
attr_reader derivatives: WAF::data
|
28
|
+
|
29
|
+
def initialize: (::Symbol status, WAF::data events, ::Float total_runtime, bool timeout, WAF::data actions, WAF::data derivatives) -> void
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Datadog
|
2
|
+
module AppSec
|
3
|
+
module WAF
|
4
|
+
type data = String | Symbol | Integer | Float | TrueClass | FalseClass | Array[data] | Hash[(String | Symbol | nil), data] | nil
|
5
|
+
|
6
|
+
def self.version: () -> ::String
|
7
|
+
|
8
|
+
self.@logger: ::Logger
|
9
|
+
self.@log_callback: LibDDWAF::ddwaf_log_cb
|
10
|
+
|
11
|
+
def self.log_callback: (LibDDWAF::ddwaf_log_level, ::String, ::String, ::Integer, ::FFI::Pointer, ::Integer) -> void
|
12
|
+
def self.logger: () -> ::Logger
|
13
|
+
def self.logger=: (::Logger logger) -> void
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/sig/libddwaf.rbs
ADDED
File without changes
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libddwaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.24.1.0.
|
4
|
+
version: 1.24.1.0.3
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-
|
11
|
+
date: 2025-07-23 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: ffi
|
@@ -38,6 +39,7 @@ files:
|
|
38
39
|
- LICENSE.Apache
|
39
40
|
- LICENSE.BSD3
|
40
41
|
- NOTICE
|
42
|
+
- README.md
|
41
43
|
- lib/datadog/appsec/waf.rb
|
42
44
|
- lib/datadog/appsec/waf/context.rb
|
43
45
|
- lib/datadog/appsec/waf/converter.rb
|
@@ -48,12 +50,26 @@ files:
|
|
48
50
|
- lib/datadog/appsec/waf/result.rb
|
49
51
|
- lib/datadog/appsec/waf/version.rb
|
50
52
|
- lib/libddwaf.rb
|
53
|
+
- libddwaf.gemspec
|
54
|
+
- sig/datadog/appsec/waf.rbs
|
55
|
+
- sig/datadog/appsec/waf/context.rbs
|
56
|
+
- sig/datadog/appsec/waf/converter.rbs
|
57
|
+
- sig/datadog/appsec/waf/errors.rbs
|
58
|
+
- sig/datadog/appsec/waf/handle.rbs
|
59
|
+
- sig/datadog/appsec/waf/handle_builder.rbs
|
60
|
+
- sig/datadog/appsec/waf/lib_ddwaf.rbs
|
61
|
+
- sig/datadog/appsec/waf/result.rbs
|
62
|
+
- sig/datadog/appsec/waf/version.rbs
|
63
|
+
- sig/libddwaf.rbs
|
51
64
|
- vendor/libddwaf/libddwaf-1.24.1-linux-aarch64/lib/libddwaf.so
|
65
|
+
- vendor/rbs/gem/0/gem.rbs
|
66
|
+
- vendor/rbs/jruby/0/jruby.rbs
|
52
67
|
homepage: https://github.com/DataDog/libddwaf-rb
|
53
68
|
licenses:
|
54
69
|
- BSD-3-Clause
|
55
70
|
metadata:
|
56
71
|
allowed_push_host: https://rubygems.org
|
72
|
+
post_install_message:
|
57
73
|
rdoc_options: []
|
58
74
|
require_paths:
|
59
75
|
- lib
|
@@ -68,7 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
84
|
- !ruby/object:Gem::Version
|
69
85
|
version: 2.0.0
|
70
86
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
87
|
+
rubygems_version: 3.5.21
|
88
|
+
signing_key:
|
72
89
|
specification_version: 4
|
73
90
|
summary: Datadog WAF
|
74
91
|
test_files: []
|