@@ -37,7 +37,7 @@ func NewBuilder(keyObfuscatorRegex string, valueObfuscatorRegex string) (*Builde
3737
3838 var pinner runtime.Pinner
3939 defer pinner .Unpin ()
40- hdl := gWafLib .BuilderInit (newConfig (& pinner , keyObfuscatorRegex , valueObfuscatorRegex ))
40+ hdl := bindings . Lib .BuilderInit (newConfig (& pinner , keyObfuscatorRegex , valueObfuscatorRegex ))
4141
4242 if hdl == 0 {
4343 return nil , errors .New ("failed to initialize the WAF builder" )
@@ -51,7 +51,7 @@ func (b *Builder) Close() {
5151 if b == nil || b .handle == 0 {
5252 return
5353 }
54- gWafLib .BuilderDestroy (b .handle )
54+ bindings . Lib .BuilderDestroy (b .handle )
5555 b .handle = 0
5656}
5757
@@ -65,15 +65,13 @@ const defaultRecommendedRulesetPath = "::/go-libddwaf/default/recommended.json"
6565// AddDefaultRecommendedRuleset adds the default recommended ruleset to the
6666// receiving [Builder], and returns the [Diagnostics] produced in the process.
6767func (b * Builder ) AddDefaultRecommendedRuleset () (Diagnostics , error ) {
68- var pinner runtime.Pinner
69- defer pinner .Unpin ()
70-
71- ruleset , err := ruleset .DefaultRuleset (& pinner )
68+ defaultRuleset , err := ruleset .DefaultRuleset ()
69+ defer bindings .Lib .ObjectFree (& defaultRuleset )
7270 if err != nil {
7371 return Diagnostics {}, fmt .Errorf ("failed to load default recommended ruleset: %w" , err )
7472 }
7573
76- diag , err := b .addOrUpdateConfig (defaultRecommendedRulesetPath , & ruleset )
74+ diag , err := b .addOrUpdateConfig (defaultRecommendedRulesetPath , & defaultRuleset )
7775 if err == nil {
7876 b .defaultLoaded = true
7977 }
@@ -122,9 +120,9 @@ func (b *Builder) AddOrUpdateConfig(path string, fragment any) (Diagnostics, err
122120// Returns the [Diagnostics] produced by adding or updating this configuration.
123121func (b * Builder ) addOrUpdateConfig (path string , cfg * bindings.WAFObject ) (Diagnostics , error ) {
124122 var diagnosticsWafObj bindings.WAFObject
125- defer gWafLib .ObjectFree (& diagnosticsWafObj )
123+ defer bindings . Lib .ObjectFree (& diagnosticsWafObj )
126124
127- res := gWafLib .BuilderAddOrUpdateConfig (b .handle , path , cfg , & diagnosticsWafObj )
125+ res := bindings . Lib .BuilderAddOrUpdateConfig (b .handle , path , cfg , & diagnosticsWafObj )
128126
129127 var diags Diagnostics
130128 if ! diagnosticsWafObj .IsInvalid () {
@@ -150,7 +148,7 @@ func (b *Builder) RemoveConfig(path string) bool {
150148 return false
151149 }
152150
153- return gWafLib .BuilderRemoveConfig (b .handle , path )
151+ return bindings . Lib .BuilderRemoveConfig (b .handle , path )
154152}
155153
156154// ConfigPaths returns the list of currently loaded configuration paths.
@@ -159,7 +157,7 @@ func (b *Builder) ConfigPaths(filter string) []string {
159157 return nil
160158 }
161159
162- return gWafLib .BuilderGetConfigPaths (b .handle , filter )
160+ return bindings . Lib .BuilderGetConfigPaths (b .handle , filter )
163161}
164162
165163// Build creates a new [Handle] instance that uses the current configuration.
@@ -171,7 +169,7 @@ func (b *Builder) Build() *Handle {
171169 return nil
172170 }
173171
174- hdl := gWafLib .BuilderBuildInstance (b .handle )
172+ hdl := bindings . Lib .BuilderBuildInstance (b .handle )
175173 if hdl == 0 {
176174 return nil
177175 }
0 commit comments