elastic / elastic-agent

Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.
Other
127 stars 136 forks source link

Elastic Agent does not set correct content-type for Fleet Server APIs #5060

Open AndersonQ opened 3 months ago

AndersonQ commented 3 months ago

For confirmed bugs, please report:

The Elastic Agent does not correctly set the content-type for outgoing requests. It actually has application/json for any request made to Fleet Server:

https://github.com/elastic/elastic-agent/blob/2ac8064fae2e56fcebfd0f7ad5d57bbffb093dce/internal/pkg/remote/client.go#L189-L192

Fleet Server API defines the content-type for the upload API /api/fleet/uploads/{id}/{chunkNum} as */*, not application/json:

https://github.com/elastic/fleet-server/blob/e52dd873b7fa3ef035b45c1b1e14f6ae697db8a1/model/openapi.yml#L1566-L1573

The Elastic Agent should correctly set the content-type of the request it makes to:

It's important as customer might have proxies or firewalls that rely or require the content type header to match the actual content type of the request body

elasticmachine commented 3 months ago

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

cmacknz commented 3 months ago

We unconditionally set Content-Type to application/json in our Fleet client which is right everywhere except for the Chunk upload endpoint.

https://github.com/elastic/elastic-agent/blob/8e35021ab849470f30d52b623d3af5e4fc682c8e/internal/pkg/remote/client.go#L189-L192