Skip to content

Commit 50c19cf

Browse files
committed
Merge remote-tracking branch 'upstream/main' into security-policy-for-tls-gateways
Signed-off-by: asif.hasnain@sap.com <asif.hasnain@sap.com>
2 parents 0677eca + 3a75814 commit 50c19cf

208 files changed

Lines changed: 13227 additions & 870 deletions

File tree

Some content is hidden

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

.github/workflows/build_and_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
outputs:
2828
run_test_workflow: ${{ steps.check-changes.outputs.run_test_workflow }}
2929
steps:
30-
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
30+
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
3131
id: check-changes
3232
# A dependent job will be automatically skipped if its parent job is skipped.
3333
# So we skip this step in pull_request event if the changes are not relevant.
@@ -368,7 +368,7 @@ jobs:
368368

369369
# build and push image
370370
- name: Login to DockerHub
371-
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
371+
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
372372
with:
373373
username: ${{ vars.DOCKERHUB_USERNAME }}
374374
password: ${{ secrets.DOCKERHUB_PASSWORD }}

.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@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
39+
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v3.29.5
4040
with:
4141
languages: ${{ matrix.language }}
4242

4343
- name: Autobuild
44-
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
44+
uses: github/codeql-action/autobuild@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v3.29.5
4545

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

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
} >> "$GITHUB_ENV"
108108
109109
- name: Login to DockerHub
110-
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
110+
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
111111
with:
112112
username: ${{ vars.DOCKERHUB_USERNAME }}
113113
password: ${{ secrets.DOCKERHUB_PASSWORD }}

.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@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
43+
uses: github/codeql-action/upload-sarif@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v3.29.5
4444
with:
4545
sarif_file: results.sarif

api/v1alpha1/authorization_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ type Principal struct {
164164
//
165165
// If multiple entries are specified, one of the ClientIPGeoLocation entries must match for the rule to match.
166166
//
167-
// The client IP is inferred from the X-Forwarded-For header or a custom header.
167+
// The client IP is inferred from the X-Forwarded-For header, a custom header, or the
168+
// direct downstream connection source address (the TCP peer of the connection terminated by Envoy).
168169
// You can use the `ClientIPDetection` field in the `ClientTrafficPolicy` to configure the client IP detection.
169170
//
170171
// +optional

api/v1alpha1/backend_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ type FQDNEndpoint struct {
110110
//
111111
// +kubebuilder:validation:MinLength=1
112112
// +kubebuilder:validation:MaxLength=253
113-
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
113+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\.?$`
114114
Hostname string `json:"hostname"`
115115

116116
// Port defines the port of the backend endpoint.

api/v1alpha1/clienttrafficpolicy_types.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ const (
281281

282282
// ClientIPDetectionSettings provides configuration for determining the original client IP address for requests.
283283
//
284-
// +kubebuilder:validation:XValidation:rule="!(has(self.xForwardedFor) && has(self.customHeader))",message="customHeader cannot be used in conjunction with xForwardedFor"
284+
// Exactly one of XForwardedFor, CustomHeader, or DirectSourceIP must be set.
285+
// +kubebuilder:validation:XValidation:rule="[has(self.xForwardedFor), has(self.customHeader), has(self.directSourceIP)].filter(x, x).size() == 1",message="exactly one of xForwardedFor, customHeader, or directSourceIP must be set"
285286
type ClientIPDetectionSettings struct {
286287
// XForwardedForSettings provides configuration for using X-Forwarded-For headers for determining the client IP address.
287288
//
@@ -294,8 +295,25 @@ type ClientIPDetectionSettings struct {
294295
//
295296
// +optional
296297
CustomHeader *CustomHeaderExtensionSettings `json:"customHeader,omitempty"`
298+
// DirectSourceIP configures the geoip filter to use the downstream connection
299+
// source address (the TCP peer of the connection terminated by Envoy) as the client IP.
300+
//
301+
// Use this in L4-transparent topologies where a load balancer preserves the original
302+
// client source IP at TCP level and does not populate XFF or a custom header — for
303+
// example, AWS NLB with target-type=instance + externalTrafficPolicy=Local, or
304+
// Azure Standard Load Balancer.
305+
//
306+
// Mutually exclusive with XForwardedFor and CustomHeader.
307+
//
308+
// +optional
309+
DirectSourceIP *DirectSourceIPSettings `json:"directSourceIP,omitempty"`
297310
}
298311

312+
// DirectSourceIPSettings configures client IP detection from the downstream
313+
// connection source address. It currently has no fields; its presence opts the listener
314+
// into using the TCP peer address as the client IP.
315+
type DirectSourceIPSettings struct{}
316+
299317
// XForwardedForSettings provides configuration for using X-Forwarded-For headers for determining the client IP address.
300318
// Refer to https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#x-forwarded-for
301319
// for more details.

api/v1alpha1/ext_proc_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ type ExtProc struct {
106106
//
107107
// +optional
108108
Metadata *ExtProcMetadata `json:"metadata,omitempty"`
109+
110+
// Sets the HTTP status that is returned to the client when the external processor returns an error
111+
// or cannot be reached. Defaults to 500 Internal Server Error.
112+
// Only 4xx and 5xx status codes are supported.
113+
//
114+
// +optional
115+
// +kubebuilder:validation:Enum=400;401;402;403;404;405;406;407;408;409;410;411;412;413;414;415;416;417;421;422;423;424;426;428;429;431;500;501;502;503;504;505;506;507;508;510;511
116+
StatusOnError *int32 `json:"statusOnError,omitempty"`
109117
}
110118

111119
// ExtProcMetadata defines options related to the sending and receiving of dynamic metadata to and from the

api/v1alpha1/securitypolicy_types.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type SecurityPolicy struct {
3737

3838
// SecurityPolicySpec defines the desired state of SecurityPolicy.
3939
//
40-
// NOTE: SecurityPolicy can target Gateway, HTTPRoute, GRPCRoute, TCPRoute, and TLSRoute.
40+
// NOTE: SecurityPolicy can target Gateway, ListenerSet, HTTPRoute, GRPCRoute, and TCPRoute, and TLSRoute.
4141
// When a SecurityPolicy targets a TCPRoute or TLSRoute, only client-IP CIDR based authorization
4242
// (Authorization rules that use Principal.ClientCIDRs) is applied. Other
4343
// authentication/authorization features such as JWT, API Key, Basic Auth,
@@ -46,17 +46,20 @@ type SecurityPolicy struct {
4646
//
4747
// +kubebuilder:validation:XValidation:rule="(has(self.targetRef) && !has(self.targetRefs)) || (!has(self.targetRef) && has(self.targetRefs)) || (has(self.targetSelectors) && self.targetSelectors.size() > 0) ", message="either targetRef or targetRefs must be used"
4848
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.group == 'gateway.networking.k8s.io' : true", message="this policy can only have a targetRef.group of gateway.networking.k8s.io"
49-
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
49+
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
5050
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.group == 'gateway.networking.k8s.io') : true ", message="this policy can only have a targetRefs[*].group of gateway.networking.k8s.io"
51-
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
51+
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
52+
// +kubebuilder:validation:XValidation:rule="!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'])))", message="mergeType can only be used with xRoute targets"
5253
// +kubebuilder:validation:XValidation:rule="(has(self.authorization) && has(self.authorization.rules) && self.authorization.rules.exists(r, has(r.principal) ? has(r.principal.jwt) : false)) ? has(self.jwt) : true", message="if authorization.rules.principal.jwt is used, jwt must be defined"
5354
type SecurityPolicySpec struct {
5455
PolicyTargetReferences `json:",inline"`
5556

5657
// MergeType determines how this configuration is merged with existing SecurityPolicy
5758
// configurations targeting a parent resource. When set, this configuration will be merged
58-
// into a parent SecurityPolicy (i.e. the one targeting a Gateway or Listener).
59-
// This field cannot be set when targeting a parent resource (Gateway).
59+
// into the closest parent SecurityPolicy in the route's attachment hierarchy (for
60+
// example, one targeting a Gateway, Gateway listener, ListenerSet, or ListenerSet
61+
// listener).
62+
// Currently, this field can only be set when targeting xRoute resources.
6063
// If unset, no merging occurs, and only the most specific configuration takes effect.
6164
//
6265
// +kubebuilder:validation:XValidation:rule="self != 'Replace'",message="Replace is not a valid MergeType for SecurityPolicy"

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 25 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)