Add a custom http header to all requests from sonar-scanner to a sonarqube instance

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarScanner 5.0.1.3006

  • how is SonarQube deployed: zip, Docker, Helm
    CircleCI Developer Hub - sonarsource/sonarcloud, but with a modified SONARQUBE_SCANNER_PARAMS to point to our instance

  • what are you trying to achieve
    Send data to our sonarqube instance

  • what have you tried so far to achieve this
    HTTP header

Hello!

Our sonarqube instance is behind a firewall, and to pass it, we need to add a x-* header with every request. The sonarqube scan is running in circleci.

I’ve tried to enable the sso headers, but those don’t seem to do anything.

What are ways I can add that header to all outgoing requests? Thanks.

3 Likes

Hi,

Welcome to the community!

I’ve moved this to the Product Manager for a Day category since the functionality doesn’t exist.

Could you share what header(s) you need to add?

 
Thx,
Ann

Thank you.

Ideally, it would be an arg that I pass to the sonar-scan call so that I can pass arbitrary headers.

I’m thinking of something like

sonar-scanner -H "X-Custom-Header=123123" -H "X-Other-Custom-Header=456456"

Hi all,

I have the exact same request; is there any progress on that request? Can we have a feedback?

In our case, we use a SonarQube server with a Developer license inside a Kubernetes cluster.
To access this instance, our company IT has configured the NetScaler with a link to an EntraID/SAML. To bypass this for our sonar scaner (we use a token) in CI, thet ask us for security reason to provide a dedicated token in HTTP headers.

Regards,

Chris

PS: This was also more or less related to these posts. Having a way to add HTTP headers is really mandatory for a professional infrastructure:

Hello Chris!

As a follow-up, we solved this issue by flipping it on its head and having CI runners use dedicated, known, IPs, which we then allowed to pass into our firewalled environment. I hope this helps!

2 Likes

We have a similar problem, as we’re running our instance behind an Identity Aware Proxy.

We’ve ended up implementing quite a complex workaround in our GitHub actions (running a temporary instance of nginx proxy and then piping requests to Sonar with auth headers added there) but the ideal solution would be config in SonarScanner like -Dproxy.addHeader=Proxy-Authorization=…