GoogleCloudPlatform / functions-framework-dart

FaaS (Function as a service) framework for writing portable Dart functions
https://pub.dev/packages/functions_framework
Apache License 2.0
536 stars 54 forks source link

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

Open zacharypuulsedev opened 1 year ago

zacharypuulsedev commented 1 year ago

Per OWASP recommendations, 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, this is doable by passing null for the header:

Future<HttpServer> serve(
Handler handler,
Object address,
int port,
{SecurityContext? securityContext,
int? backlog,
bool shared = false,
String? poweredByHeader = 'Dart with package:shelf'}
)

In serve.dart there is a call to run.

Within run, shelf_io.serve 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

kevmoo commented 1 year ago

PR welcome!