Skip to content

Commit 0d277bb

Browse files
committed
fix(waf): ignore waf acl set to empty string
1 parent 7040d02 commit 0d277bb

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

pkg/ingress/model_build_load_balancer_addons.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ingress
22

33
import (
44
"context"
5+
56
"github.com/pkg/errors"
67
"k8s.io/apimachinery/pkg/util/sets"
78
"sigs.k8s.io/aws-load-balancer-controller/v3/pkg/annotations"
@@ -60,7 +61,8 @@ func (t *defaultModelBuildTask) buildWAFv2WebACLAssociation(ctx context.Context,
6061
}
6162

6263
rawWebACLARN := ""
63-
if exists := t.annotationParser.ParseStringAnnotation(annotations.IngressSuffixWAFv2ACLARN, &rawWebACLARN, member.Ing.Annotations); !exists {
64+
exists := t.annotationParser.ParseStringAnnotation(annotations.IngressSuffixWAFv2ACLARN, &rawWebACLARN, member.Ing.Annotations)
65+
if !exists || rawWebACLARN == "" {
6466
continue
6567
}
6668
explicitWebACLARNs.Insert(rawWebACLARN)

pkg/ingress/model_build_load_balancer_addons_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ func Test_defaultModelBuildTask_buildWAFv2WebACLAssociation(t *testing.T) {
6969
want: nil,
7070
wantErr: assert.NoError,
7171
},
72+
{
73+
name: " wafv2-acl-arn set to empty string",
74+
fields: fields{
75+
ingGroup: Group{
76+
Members: []ClassifiedIngress{
77+
{
78+
Ing: &networking.Ingress{
79+
ObjectMeta: metav1.ObjectMeta{
80+
Namespace: "awesome-ns",
81+
Name: "awesome-ing-0",
82+
Annotations: map[string]string{
83+
"alb.ingress.kubernetes.io/wafv2-acl-arn": "",
84+
},
85+
},
86+
},
87+
},
88+
},
89+
},
90+
},
91+
args: args{
92+
lbARN: core.LiteralStringToken("awesome-lb-arn"),
93+
},
94+
want: nil,
95+
wantErr: assert.NoError,
96+
},
7297
{
7398
name: "when all ingresses have wafv2-acl-arn annotation set to wafv2-arn-1",
7499
fields: fields{

0 commit comments

Comments
 (0)