PacktPublishing / Python-Web-Development-with-Sanic

Python Web Development with Sanic, published by Packt
MIT License
75 stars 33 forks source link

Unique footprint #15

Closed ceopeo closed 1 year ago

ceopeo commented 1 year ago

Hey guys. How can we determine that a particular site is built using Sanic?

ahopkins commented 1 year ago

You cannot. This is a rather intentional decision that has been made. Sanic tries to remain unopinionated where it can. One of those decisions means not adding a Server header, which could potentially open up a security issue.

For example, if there became known a security issue in Sanic, it would be possible for someone to exploit a site that has not upgraded. It literally would be an advertisement that it is vulnerable. Therefore, we suggest any app developer that wants to provide this information do so with their own knowledge and consent.

from sanic import HTTPResponse, Sanic, __version__

app = Sanic("TestApp")

@app.on_response
async def on_request(_, response: HTTPResponse):
    response.headers["server"] = f"Sanic, v{__version__}"