git: 2a0ece70c103 - main - devel/rubygem-ddtrace: Allow build with rubygem-libddwaf 1.11.0.0.0

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Mon, 04 Sep 2023 09:09:52 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2a0ece70c1034a6504f53e9e12f1008a1f0ab58c

commit 2a0ece70c1034a6504f53e9e12f1008a1f0ab58c
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-09-04 09:05:50 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-09-04 09:05:50 +0000

    devel/rubygem-ddtrace: Allow build with rubygem-libddwaf 1.11.0.0.0
    
    - Bump PORTREVISION for package change
    
    Obtained from:  https://github.com/DataDog/dd-trace-rb/commit/eb5ddedf18cf9129bab06b4f3063437fc0aabfd9
---
 devel/rubygem-ddtrace/Makefile             |  3 +-
 devel/rubygem-ddtrace/files/patch-libddwaf | 84 ++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/devel/rubygem-ddtrace/Makefile b/devel/rubygem-ddtrace/Makefile
index f6fa21f34149..8d2da3663c84 100644
--- a/devel/rubygem-ddtrace/Makefile
+++ b/devel/rubygem-ddtrace/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	ddtrace
 PORTVERSION=	1.14.0
+PORTREVISION=	1
 CATEGORIES=	devel rubygems
 MASTER_SITES=	RG
 
@@ -14,7 +15,7 @@ LICENSE_FILE_BSD3CLAUSE=${WRKSRC}/LICENSE.BSD3
 
 RUN_DEPENDS=	rubygem-debase-ruby_core_source>=3.2.1<3.2.1_99:devel/rubygem-debase-ruby_core_source \
 		rubygem-libdatadog>=3.0.0.1.0<3.0.0.2:devel/rubygem-libdatadog \
-		rubygem-libddwaf>=1.9.0.0.0<1.9.0.1:devel/rubygem-libddwaf \
+		rubygem-libddwaf>=1.11.0.0.0<1.11.0.1:devel/rubygem-libddwaf \
 		rubygem-msgpack>=0:devel/rubygem-msgpack
 
 USES=		gem
diff --git a/devel/rubygem-ddtrace/files/patch-libddwaf b/devel/rubygem-ddtrace/files/patch-libddwaf
new file mode 100644
index 000000000000..6c5e6e3032f8
--- /dev/null
+++ b/devel/rubygem-ddtrace/files/patch-libddwaf
@@ -0,0 +1,84 @@
+Obtained from:	https://github.com/DataDog/dd-trace-rb/commit/eb5ddedf18cf9129bab06b4f3063437fc0aabfd9
+
+--- ddtrace.gemspec.orig	2023-08-30 13:30:50 UTC
++++ ddtrace.gemspec
+@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
+ 
+   s.add_runtime_dependency(%q<msgpack>.freeze, [">= 0"])
+   s.add_runtime_dependency(%q<debase-ruby_core_source>.freeze, ["= 3.2.1"])
+-  s.add_runtime_dependency(%q<libddwaf>.freeze, ["~> 1.9.0.0.0"])
++  s.add_runtime_dependency(%q<libddwaf>.freeze, ["~> 1.11.0.0.0"])
+   s.add_runtime_dependency(%q<libdatadog>.freeze, ["~> 3.0.0.1.0"])
+ end
+ 
+--- lib/datadog/appsec/contrib/rack/request_middleware.rb.orig	2023-08-30 13:30:50 UTC
++++ lib/datadog/appsec/contrib/rack/request_middleware.rb
+@@ -137,17 +137,19 @@ module Datadog
+               )
+             end
+ 
+-            if processor.ruleset_info
+-              span.set_tag('_dd.appsec.event_rules.version', processor.ruleset_info[:version])
++            if processor.diagnostics
++              diagnostics = processor.diagnostics
+ 
++              span.set_tag('_dd.appsec.event_rules.version', diagnostics['ruleset_version'])
++
+               unless @oneshot_tags_sent
+                 # Small race condition, but it's inoccuous: worst case the tags
+                 # are sent a couple of times more than expected
+                 @oneshot_tags_sent = true
+ 
+-                span.set_tag('_dd.appsec.event_rules.loaded', processor.ruleset_info[:loaded].to_f)
+-                span.set_tag('_dd.appsec.event_rules.error_count', processor.ruleset_info[:failed].to_f)
+-                span.set_tag('_dd.appsec.event_rules.errors', JSON.dump(processor.ruleset_info[:errors]))
++                span.set_tag('_dd.appsec.event_rules.loaded', diagnostics['rules']['loaded'].size.to_f)
++                span.set_tag('_dd.appsec.event_rules.error_count', diagnostics['rules']['loaded'].size.to_f)
++                span.set_tag('_dd.appsec.event_rules.errors', JSON.dump(diagnostics['rules']['errors']))
+                 span.set_tag('_dd.appsec.event_rules.addresses', JSON.dump(processor.addresses))
+ 
+                 # Ensure these tags reach the backend
+--- lib/datadog/appsec/event.rb.orig	2023-08-30 13:30:50 UTC
++++ lib/datadog/appsec/event.rb
+@@ -105,7 +105,7 @@ module Datadog
+ 
+           # accumulate triggers
+           tags['_dd.appsec.triggers'] ||= []
+-          tags['_dd.appsec.triggers'] += event[:waf_result].data
++          tags['_dd.appsec.triggers'] += event[:waf_result].events
+         end
+       end
+     end
+--- lib/datadog/appsec/processor.rb.orig	2023-08-30 13:30:50 UTC
++++ lib/datadog/appsec/processor.rb
+@@ -43,10 +43,10 @@ module Datadog
+         end
+       end
+ 
+-      attr_reader :ruleset_info, :addresses
++      attr_reader :diagnostics, :addresses
+ 
+       def initialize(ruleset:)
+-        @ruleset_info = nil
++        @diagnostics = nil
+         @addresses = []
+         settings = Datadog.configuration.appsec
+ 
+@@ -83,7 +83,7 @@ module Datadog
+         }
+ 
+         @handle = Datadog::AppSec::WAF::Handle.new(ruleset, obfuscator: obfuscator_config)
+-        @ruleset_info = @handle.ruleset_info
++        @diagnostics = @handle.diagnostics
+         @addresses = @handle.required_addresses
+ 
+         true
+@@ -92,7 +92,7 @@ module Datadog
+           "libddwaf failed to initialize, error: #{e.inspect}"
+         end
+ 
+-        @ruleset_info = e.ruleset_info if e.ruleset_info
++        @diagnostics = e.diagnostics if e.diagnostics
+ 
+         false
+       rescue StandardError => e