I try to upgrade sonarqube-scanner from 3.0.1 to 4.0.1 but i have some issue

i’m behind a proxy and i use a vpn (globalprotect)

i m using this code :

import { scan } from 'sonarqube-scanner'

scan(
    { serverUrl: sonarServerUrl, options },
    {
      debug: true,
    },
  )

log of the first execution :

[INFO]  Bootstrapper: Retrieving info from "package.json" file
[DEBUG] Bootstrapper: Setting the log level to DEBUG due to verbose mode
[DEBUG] Bootstrapper: Properties: {
  'sonar.userHome': '/home/Robin.Louarn/.sonar',
  'sonar.scanner.os': 'linux',
  'sonar.scanner.arch': 'x64',
  'sonar.exclusions': 'node_modules/**,bower_components/**,jspm_packages/**,typings/**,lib-cov/**',
  'sonar.projectKey': 'poc-sofa-reports',
  'sonar.projectName': 'My App',
  'sonar.projectVersion': '0.1.0',
  'sonar.scanner.proxyHost': 'localhost',
  'sonar.scanner.proxyPort': '3128',
  'sonar.projectDescription': 'Description for "My App" project...',
  'sonar.sources': 'src',
  'sonar.tests': 'tests',
  'sonar.host.url': 'http:/.****:8080',
  'sonar.verbose': 'true',
  'sonar.scanner.internal.isSonarCloud': 'false',
  'sonar.scanner.apiBaseUrl': 'http://**********:8080/api/v2',
  'sonar.scanner.app': 'ScannerNpm',
  'sonar.scanner.appVersion': '4.0.1',
  'sonar.scanner.bootstrapStartTime': '1722005180515',
  'sonar.scanner.wasJreCacheHit': 'disabled',
  'sonar.scanner.wasEngineCacheHit': 'false',
  'sonar.projectBaseDir': '/home/Robin.Louarn/git/aod-static-s3'
}
[INFO]  Bootstrapper: Platform: linux x64
[DEBUG] Bootstrapper: Detecting proxy: http://localhost:3128/
[INFO]  Bootstrapper: Server URL: http://*******:8080
[INFO]  Bootstrapper: Version: 4.0.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: Bad response: 403. Falling back on /api/server/version
[DEBUG] Bootstrapper: Not using axios instance for http://******/api/server/version
[ERROR] Bootstrapper: Failed to fetch server version: Error: Bad response: 403
[ERROR] Bootstrapper: Verify that http://****** is a valid SonarQube server
[ERROR] Bootstrapper: An error occurred: Error: Bad response: 403

after comment Agents and add proxy in configation of axios :

request.js

    if (proxyUrl) {
        // agents.httpsAgent = new hpagent_1.HttpsProxyAgent({ proxy: proxyUrl.toString(), ...httpsAgentOptions });
        // agents.httpAgent = new hpagent_1.HttpProxyAgent({ proxy: proxyUrl.toString() });
        agents.proxy = {
            protocol: 'http',
            host: 'localhost',
            port: 3128,
        }
    }
[INFO]  Bootstrapper: Retrieving info from "package.json" file
[DEBUG] Bootstrapper: Setting the log level to DEBUG due to verbose mode
[DEBUG] Bootstrapper: Properties: {
  'sonar.userHome': '/home/Robin.Louarn/.sonar',
  'sonar.scanner.os': 'linux',
  'sonar.scanner.arch': 'x64',
  'sonar.exclusions': 'node_modules/**,bower_components/**,jspm_packages/**,typings/**,lib-cov/**',
  'sonar.projectKey': 'poc-sofa-reports',
  'sonar.projectName': 'My App',
  'sonar.projectVersion': '0.1.0',
  'sonar.scanner.proxyHost': 'localhost',
  'sonar.scanner.proxyPort': '3128',
  'sonar.projectDescription': 'Description for "My App" project...',
  'sonar.sources': 'src',
  'sonar.tests': 'tests',
  'sonar.host.url': 'http://so******m:8080',
  'sonar.verbose': 'true',
  'sonar.scanner.internal.isSonarCloud': 'false',
  'sonar.scanner.apiBaseUrl': 'http://sonarqube-********m:8080/api/v2',
  'sonar.scanner.app': 'ScannerNpm',
  'sonar.scanner.appVersion': '4.0.1',
  'sonar.scanner.bootstrapStartTime': '1722002967839',
  'sonar.scanner.wasJreCacheHit': 'disabled',
  'sonar.scanner.wasEngineCacheHit': 'false',
  'sonar.projectBaseDir': '/home/Robin.Louarn/git/aod-static-s3'
}
[INFO]  Bootstrapper: Platform: linux x64
[DEBUG] Bootstrapper: Detecting proxy: http://localhost:3128/
[INFO]  Bootstrapper: Server URL: http://sonarqube*******om:8080
[INFO]  Bootstrapper: Version: 4.0.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: AxiosError: Request failed with status code 404. Falling back on /api/server/version
[DEBUG] Bootstrapper: Not using axios instance for http://sonarqube-ic.in*******m:8080/api/server/version
[INFO]  Bootstrapper: SonarQube server version: 8.9.1
[DEBUG] Bootstrapper: SonarQube Server v8.9.1 supports JRE provisioning: false
[INFO]  Bootstrapper: JRE provisioning is NOT supported
[INFO]  Bootstrapper: Falling back on using sonar-scanner-cli
[INFO]  Bootstrapper: Starting analysis
[DEBUG] Bootstrapper: Detecting proxy: http://localhost:3128/
16:09:28.363 INFO: Scanner configuration file: /home/Robin.Louarn/.sonar/native-sonar-scanner/sonar-scanner-5.0.1.3006-linux/conf/sonar-scanner.properties
16:09:28.375 INFO: Project root configuration file: NONE
16:09:28.399 INFO: SonarScanner 5.0.1.3006
16:09:28.399 INFO: Java 17.0.7 Eclipse Adoptium (64-bit)
16:09:28.399 INFO: Linux 5.15.0-113-generic amd64
16:09:28.518 DEBUG: keyStore is : 
16:09:28.518 DEBUG: keyStore type is : pkcs12
16:09:28.518 DEBUG: keyStore provider is : 
16:09:28.518 DEBUG: init keystore
16:09:28.519 DEBUG: init keymanager of type SunX509
16:09:28.610 DEBUG: Create: /home/Robin.Louarn/.sonar/cache
16:09:28.611 INFO: User cache: /home/Robin.Louarn/.sonar/cache
16:09:28.611 DEBUG: Create: /home/Robin.Louarn/.sonar/cache/_tmp
16:09:28.613 DEBUG: Extract sonar-scanner-api-batch in temp...
16:09:28.616 DEBUG: Get bootstrap index...
16:09:28.616 DEBUG: Download: http://sonarqube-ic.in******m:8080/batch/index
[ERROR] Bootstrapper: 16:09:58.715 ERROR: SonarQube server [http://sonarqube-ic.int*****m:8080] can not be reached

16:09:58.715 INFO: ------------------------------------------------------------------------
16:09:58.716 INFO: EXECUTION FAILURE
16:09:58.716 INFO: ------------------------------------------------------------------------
16:09:58.717 INFO: Total time: 30.381s
16:09:58.739 INFO: Final Memory: 5M/40M
16:09:58.739 INFO: ------------------------------------------------------------------------
[ERROR] Bootstrapper: 16:09:58.739 ERROR: Error during SonarScanner execution

[ERROR] Bootstrapper: org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
        at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
        at org.sonarsource.scanner.cli.Main.main(Main.java:62)

[ERROR] Bootstrapper: Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
        at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
        at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)

[ERROR] Bootstrapper:   ... 7 more

[ERROR] Bootstrapper: Caused by: java.net.SocketTimeoutException: Connect timed out

[ERROR] Bootstrapper:   at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(Unknown Source)

[ERROR] Bootstrapper:   at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
        at java.base/java.net.SocksSocketImpl.connect(Unknown Source)

[ERROR] Bootstrapper:   at java.base/java.net.Socket.connect(Unknown Source)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.platform.Platform.connectSocket(Platform.java:130)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:263)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:183)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

[ERROR] Bootstrapper:   at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

some one can help me ?

now i remove the sonar bin in /home/Robin.Louarn/.sonar/native-sonar-scanner/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner

and now i have an error on download of cli

Hi,

It’s not clear to me why you’ve configured this for a proxy on localhost, but off-hand, it looks like you should talk to your network folks about the proxy.

Also, what scanner are you using?

 
Thx,
Ann

Hello, i’m using sonarqube-scanner 4.0.1

I use a local proxy to configure my password in one place

I don’t think it’s a proxy problem because as I said in my message above, I went to modify the file “node_modules/sonar-sacnner/dist/src/request.js” to modify the config of the proxy with:

if (proxyUrl) {
        // agents.httpsAgent = new hpagent_1.HttpsProxyAgent({ proxy: proxyUrl.toString(), ...httpsAgentOptions });
        // agents.httpAgent = new hpagent_1.HttpProxyAgent({ proxy: proxyUrl.toString() });
        agents.proxy = {
            protocol: 'http',
            host: 'localhost',
            port: 3128,
        }
    }

at least for the first call to retrieve the sonar version, it’s true that for the CLI download it could be a network problem on my side I will check

1 Like

Voici un exemple pour reproduire plus facilement mon erreur :

mon fichier sonar-project.properties :

sonar.host.url=http://****.com:8080
sonar.log.level=DEBUG
sonar.scanner.proxyHost=localhost
sonar.scanner.proxyPort=3128
sonar.projectKey=***
sonar.projectName=***

puis je lance le scan avec cette commande :

 npm exec sonar-scanner

[INFO]  Bootstrapper: Retrieving info from "package.json" file
[DEBUG] Bootstrapper: Overriding the log level to DEBUG
[DEBUG] Bootstrapper: Properties: {
  'sonar.userHome': '/home/Robin.Louarn/.sonar',
  'sonar.scanner.os': 'linux',
  'sonar.scanner.arch': 'x64',
  'sonar.exclusions': 'node_modules/**,bower_components/**,jspm_packages/**,typings/**,lib-cov/**',
  'sonar.projectKey': '***',
  'sonar.projectName': 'AZ00_sofa-sonar_develop_dev',
  'sonar.projectVersion': '0.1.0',
  'sonar.host.url': '***',
  'sonar.log.level': 'DEBUG',
  'sonar.scanner.proxyHost': 'localhost',
  'sonar.scanner.proxyPort': '3128',
  'sonar.scanner.internal.isSonarCloud': 'false',
  'sonar.scanner.apiBaseUrl': '***',
  'sonar.scanner.app': 'ScannerNpm',
  'sonar.scanner.appVersion': '4.2.0',
  'sonar.scanner.bootstrapStartTime': '1723476876278',
  'sonar.scanner.wasJreCacheHit': 'disabled',
  'sonar.scanner.wasEngineCacheHit': 'false',
  'sonar.projectBaseDir': '/home/Robin.Louarn/git/sofa-sonar'
}
[INFO]  Bootstrapper: Platform: linux x64
[DEBUG] Bootstrapper: Detecting proxy: http://localhost:3128/
[INFO]  Bootstrapper: Server URL: http://sonarqube-***.com:8080
[INFO]  Bootstrapper: Version: 4.2.0
[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: Bad response: 403. Falling back on /api/server/version
[DEBUG] Bootstrapper: Not using axios instance for http://sonarqube-ic.intra.***.com:8080/api/server/version
[ERROR] Bootstrapper: Failed to fetch server version: Error: Bad response: 403
[ERROR] Bootstrapper: Verify that http://sonarqube-ic.intra.***.com:8080 is a valid SonarQube server
[ERROR] Bootstrapper: An error occurred: Error: Bad response: 403

Puis quand j’essaye de récupérer la version de sonar avec un curl ça fonctionne correctement :

curl http://sonarqube-ic.intra.***.com:8080/api/server/version
8.9.1.44547

Hi,

We’re English-only, but I can tell from this:

That your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

8.9.1 → 9.9.6 → 10.6 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

 
HTH,
Ann

I also reproduce this issue.
In axios documentation (Request Config | Axios Docs), they specify that proxy has to be set to false when supplying an httpAgent:

// Use false to disable proxies, ignoring environment variables.
// Disable if supplying a custom httpAgent/httpsAgent to manage proxying requests.
proxy: {

Is it possible to disable option proxy when using an httpAgent ?

Ex in file request.ts, function getHttpAgents :
replace :

  return agents;

by

  return {...agents, ...((agents.httpsAgent || agents.httpAgent) ? {proxy:false} : {})};

Here, minimalist code to reproduce :

import axios from "axios";
import hpagent from "hpagent";

process.env.HTTP_PROXY = 'http://localhost:3128'
axios
  .get("http://sonarqube-ic.intra.arkea.com:8080/api/server/version", {
    httpAgent: new hpagent.HttpProxyAgent({ proxy: "http://localhost:3128" })
  })
  .then((res) => {
    console.log(res);
  })
  .catch((err) => console.error(err));

This request returns a 403 because axios configures 2 proxies

Hi @nicotu01,

Welcome to the community!

You’ve resurrected a thread that’s 3 months old. Per the FAQ, please don’t do that. Please create a new thread with all your details, including your version numbers.

 
Thx,
Ann