GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-dart

Allow Configuring "X-Powered-By" of underlying shelf server

Open
#388 1 comment 0 reactions 0 assignees View on GitHub
kind/enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.