Skip to content

Commit

Permalink
rm gateway-api translation error message from direct response (#3878)
Browse files Browse the repository at this point in the history
* Responding back with an error message around translation errors
may leak info to internet facing external clients around ingress
internals

Signed-off-by: Arko Dasgupta <[email protected]>
Co-authored-by: zirain <[email protected]>
Co-authored-by: Xunzhuo <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent 7cbbcb5 commit 6b232f1
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 43 deletions.
3 changes: 0 additions & 3 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ func (t *Translator) processUnresolvedHTTPFilter(errMsg string, filterContext *H
errMsg,
)
filterContext.DirectResponse = &ir.DirectResponse{
Body: &errMsg,
StatusCode: 500,
}
}
Expand All @@ -842,7 +841,6 @@ func (t *Translator) processUnsupportedHTTPFilter(filterType string, filterConte
errMsg,
)
filterContext.DirectResponse = &ir.DirectResponse{
Body: &errMsg,
StatusCode: 500,
}
}
Expand All @@ -859,7 +857,6 @@ func (t *Translator) processInvalidHTTPFilter(filterType string, filterContext *
errMsg,
)
filterContext.DirectResponse = &ir.DirectResponse{
Body: &errMsg,
StatusCode: 500,
}
}
3 changes: 0 additions & 3 deletions internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,6 @@ func (h AddHeader) Validate() error {
// DirectResponse holds the details for returning a body and status code for a route.
// +k8s:deepcopy-gen=true
type DirectResponse struct {
// Body configures the body of the direct response. Currently only a string response
// is supported, but in the future a config.core.v3.DataSource may replace it.
Body *string `json:"body,omitempty" yaml:"body,omitempty"`
// StatusCode will be used for the direct response's status code.
StatusCode uint32 `json:"statusCode" yaml:"statusCode"`
}
Expand Down
2 changes: 0 additions & 2 deletions internal/ir/xds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ var (
Exact: ptr.To("filter-error"),
},
DirectResponse: &DirectResponse{
Body: ptr.To("invalid filter type"),
StatusCode: uint32(500),
},
}
Expand Down Expand Up @@ -297,7 +296,6 @@ var (
Exact: ptr.To("redirect"),
},
DirectResponse: &DirectResponse{
Body: ptr.To("invalid filter type"),
StatusCode: uint32(799),
},
}
Expand Down
7 changes: 1 addition & 6 deletions internal/ir/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,6 @@ func buildXdsURLRewriteAction(destName string, urlRewrite *ir.URLRewrite, pathMa

func buildXdsDirectResponseAction(res *ir.DirectResponse) *routev3.DirectResponseAction {
routeAction := &routev3.DirectResponseAction{Status: res.StatusCode}

if res.Body != nil {
routeAction.Body = &corev3.DataSource{
Specifier: &corev3.DataSource_InlineString{
InlineString: *res.Body,
},
}
}

return routeAction
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: first-listener/*
routes:
- directResponse:
body:
inlineString: 'Unknown custom filter type: UnsupportedType'
status: 500
match:
prefix: /
Expand Down

0 comments on commit 6b232f1

Please sign in to comment.