Sonar-scanner-npm assumes proxy is exposed on same protocol as SonarQube endpoint

Must-share information :

  • which versions are you using : SonarQube 10.5.1, sonar-scanner 4.2.1
  • what are you trying to achieve : download and run scanner behind proxy
  • what have you tried so far to achieve this :
sonar-scanner -Dsonar.branch.name=xxx -Dsonar.host.url=https://xxx
[INFO]  Bootstrapper: Retrieving info from "package.json" file
[DEBUG] Bootstrapper: Setting the log level to DEBUG due to verbose mode
...
[INFO]  Bootstrapper: Platform: linux x64
[DEBUG] Bootstrapper: **Detecting proxy: https://xxx:yyyy/**
[INFO]  Bootstrapper: **Server URL: https://xxx**
[INFO]  Bootstrapper: Version: 4.2.1
[DEBUG] Bootstrapper: Check if Server supports JRE provisioning
[DEBUG] Bootstrapper: Detecting SonarQube server version
[DEBUG] Bootstrapper: Fetching API V2 /analysis/version
[DEBUG] Bootstrapper: Unable to fetch API V2 /analysis/version: Error: write EPROTO C067916206710000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:
. Falling back on /api/server/version
[DEBUG] Bootstrapper: Not using axios instance for https://xxx/api/server/version
[ERROR] Bootstrapper: Failed to fetch server version: Error: write EPROTO C067916206710000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:

[ERROR] Bootstrapper: Verify that https://xxx is a valid SonarQube server
[ERROR] Bootstrapper: An error occurred: Error: write EPROTO C067916206710000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:

It looks like proxy detection is guessing proxy protocol based on the SonarQube endpoint protocol.
(proxy.ts - line 32)

This assumption does not match my situation, since I have :

  • SonarQube endpoint exposed through HTTPS
  • Forward proxy exposed through HTTP on a custom port.

Is there any way to run sonar-scanner-npm behind http proxy (not https) while having SonarQube platform exposed through https ?

Thanks for your help

Hello @Rom , indeed, this should be possible. The correct behavior for the Scanner for NPM should be to assume the proxy is http (because the underlying java tool it calls does not support CONNECT over TLS anyway). I have created SCANNPM-47 which you can track to follow our progress in addressing this specific issue.

Thanks for your help,
Benjamin