GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-dart
Allow Configuring "X-Powered-By" of underlying shelf server
- Dominant language
- Dart
- Stars
- 548
- Forks
- 49
- Avg merge
- 53m
- Merged PRs (30d)
- 1
Description
Per [OWASP recommendations](https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html#x-powered-by), I'd like to remove the "X-Powered-By" header.
Unless there is another option to remove a header with a Cloud Run instance behind a GCP API Gateway, the following is what I'd envision:
According to the [shelf documentation](https://pub.dev/documentation/shelf/latest/shelf_io/serve.html), this is doable by passing `null` for the header:
```
Future serve(
Handler handler,
Object address,
int port,
{SecurityContext? securityContext,
int? backlog,
bool shared = false,
String? poweredByHeader = 'Dart with package:shelf'}
)
```
In [`serve.dart`](https://github.com/GoogleCloudPlatform/functions-framework-dart/blob/main/functions_framework/lib/serve.dart) there is a call to `run`.
Within [run, shelf_io.serve](https://github.com/GoogleCloudPlatform/functions-framework-dart/blob/a8741286242c3e3d66f9fe5ff9395b20d4c135d3/functions_framework/lib/src/run.dart#L27) is called, which could be parameterized to pass `null` to the `poweredByHeader` param.
https://github.com/GoogleCloudPlatform/functions-framework-dart/blob/main/functions_framework/lib/serve.dart
Contributor guide
Assessment
This issue has not been assessed yet.