Skip to content

Commit fe552bf

Browse files
committed
Merge branch 'main' into feat-ratelimit-shadow
Signed-off-by: kkk777-7 <[email protected]>
2 parents c7ccdfa + aa3ad43 commit fe552bf

File tree

601 files changed

+5423
-1225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

601 files changed

+5423
-1225
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ jobs:
3636
- uses: ./tools/github-actions/setup-deps
3737

3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v3.29.5
39+
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
4040
with:
4141
languages: ${{ matrix.language }}
4242

4343
- name: Autobuild
44-
uses: github/codeql-action/autobuild@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v3.29.5
44+
uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
4545

4646
- name: Perform CodeQL Analysis
47-
uses: github/codeql-action/analyze@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v3.29.5
47+
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
4848
with:
4949
category: "/language:${{matrix.language}}"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ jobs:
4040
retention-days: 5
4141

4242
- name: "Upload to code-scanning"
43-
uses: github/codeql-action/upload-sarif@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v3.29.5
43+
uses: github/codeql-action/upload-sarif@fdbfb4d2750291e159f0156def62b853c2798ca2 # v3.29.5
4444
with:
4545
sarif_file: results.sarif

api/v1alpha1/shared_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ type HTTPHeaderFilter struct {
931931
// +optional
932932
// +listType=map
933933
// +listMapKey=name
934+
// +kubebuilder:validation:MinItems=1
934935
// +kubebuilder:validation:MaxItems=64
935936
Set []gwapiv1.HTTPHeader `json:"set,omitempty"`
936937

@@ -954,6 +955,7 @@ type HTTPHeaderFilter struct {
954955
// +optional
955956
// +listType=map
956957
// +listMapKey=name
958+
// +kubebuilder:validation:MinItems=1
957959
// +kubebuilder:validation:MaxItems=64
958960
Add []gwapiv1.HTTPHeader `json:"add,omitempty"`
959961

@@ -977,6 +979,15 @@ type HTTPHeaderFilter struct {
977979
//
978980
// +optional
979981
// +listType=set
982+
// +kubebuilder:validation:MinItems=1
980983
// +kubebuilder:validation:MaxItems=64
981984
Remove []string `json:"remove,omitempty"`
985+
986+
// RemoveOnMatch removes headers whose names match the specified string matchers.
987+
// Matching is performed on the header name (case-insensitive).
988+
//
989+
// +optional
990+
// +kubebuilder:validation:MinItems=1
991+
// +kubebuilder:validation:MaxItems=64
992+
RemoveOnMatch []StringMatch `json:"removeOnMatch,omitempty"`
982993
}

api/v1alpha1/validation/envoyproxy_validate.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net"
1212
"net/netip"
1313
"regexp"
14+
"strings"
1415

1516
"github.com/dominikbraun/graph"
1617
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -296,32 +297,34 @@ func validateFilterOrder(filterOrder []egv1a1.FilterPosition) error {
296297
return nil
297298
}
298299

299-
func ValidateRouteStatName(routeStatName string) error {
300-
supportedOperators := map[string]bool{
300+
var (
301+
routeStatSupportedOperators = map[string]bool{
301302
egv1a1.StatFormatterRouteName: true,
302303
egv1a1.StatFormatterRouteNamespace: true,
303304
egv1a1.StatFormatterRouteKind: true,
304305
egv1a1.StatFormatterRouteRuleName: true,
305306
}
306307

307-
if err := validateStatName(routeStatName, supportedOperators); err != nil {
308-
return fmt.Errorf("unable to configure Route Stat Name: %w", err)
309-
}
310-
311-
return nil
312-
}
313-
314-
func ValidateClusterStatName(clusterStatName string) error {
315-
supportedOperators := map[string]bool{
308+
clusterStatSupportedOperators = map[string]bool{
316309
egv1a1.StatFormatterRouteName: true,
317310
egv1a1.StatFormatterRouteNamespace: true,
318311
egv1a1.StatFormatterRouteKind: true,
319312
egv1a1.StatFormatterRouteRuleName: true,
320313
egv1a1.StatFormatterRouteRuleNumber: true,
321314
egv1a1.StatFormatterBackendRefs: true,
322315
}
316+
)
317+
318+
func ValidateRouteStatName(routeStatName string) error {
319+
if err := validateStatName(routeStatName, routeStatSupportedOperators); err != nil {
320+
return fmt.Errorf("unable to configure Route Stat Name: %w", err)
321+
}
323322

324-
if err := validateStatName(clusterStatName, supportedOperators); err != nil {
323+
return nil
324+
}
325+
326+
func ValidateClusterStatName(clusterStatName string) error {
327+
if err := validateStatName(clusterStatName, clusterStatSupportedOperators); err != nil {
325328
return fmt.Errorf("unable to configure Cluster Stat Name: %w", err)
326329
}
327330

@@ -331,6 +334,9 @@ func ValidateClusterStatName(clusterStatName string) error {
331334
func validateStatName(statName string, supportedOperators map[string]bool) error {
332335
var unsupportedOperators []string
333336
matches := statNameRegex.FindAllString(statName, -1)
337+
if len(matches) == 0 && strings.Contains(statName, "%") {
338+
return fmt.Errorf("unable to configure stat name with invalid operator")
339+
}
334340
for _, operator := range matches {
335341
if _, ok := supportedOperators[operator]; !ok {
336342
unsupportedOperators = append(unsupportedOperators, operator)

api/v1alpha1/validation/envoyproxy_validate_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,3 +964,44 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) {
964964
})
965965
}
966966
}
967+
968+
func TestValidateClusterStatName(t *testing.T) {
969+
testCases := []struct {
970+
name string
971+
statName string
972+
expected bool
973+
}{
974+
{
975+
name: "valid cluster stat name with supported operators",
976+
statName: "%ROUTE_NAME%/%ROUTE_NAMESPACE%/%BACKEND_REFS%",
977+
expected: true,
978+
},
979+
{
980+
name: "invalid cluster stat name with unsupported operators",
981+
statName: "%ROUTE_NAME%/%FOO%/%BAR%",
982+
expected: false,
983+
},
984+
{
985+
name: "valid cluster stat name",
986+
statName: "any_custom_name",
987+
expected: true,
988+
},
989+
{
990+
name: "invalid cluster stat name",
991+
statName: "%ROUTE_NAME",
992+
expected: false,
993+
},
994+
}
995+
996+
for i := range testCases {
997+
tc := testCases[i]
998+
t.Run(tc.name, func(t *testing.T) {
999+
errs := ValidateClusterStatName(tc.statName)
1000+
if tc.expected {
1001+
require.NoError(t, errs)
1002+
} else {
1003+
require.Error(t, errs)
1004+
}
1005+
})
1006+
}
1007+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)