Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMF-3712 No specific JRE version dependency #119

Merged
merged 35 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
157d43f
SCANNPM-1 Cleanup existing sourcecode and prepare bootstrap foundatio…
lucas-paulger-sonarsource Apr 12, 2024
1ed6ea6
SCANNPM-2 Detect Platform (#110)
lucas-paulger-sonarsource Apr 16, 2024
1e20e0f
SCANNPM-2 Handle logic to process scanner properties from various sou…
7PH Apr 12, 2024
5c6a255
SCANNPM-2 Implement logic to fetch JRE (#112)
lucas-paulger-sonarsource Apr 17, 2024
b9a4f8c
SCANNPM-2 Handle proxy detection & usage
7PH Apr 17, 2024
d7148a4
SCANNPM-2 Allow to override the SonarQube version for internal testing
7PH Apr 18, 2024
48afbce
SCANNPM-2 Support JRE provisioning (#116)
lucas-paulger-sonarsource Apr 19, 2024
229c6f1
SCANNPM-2 Use axios instance to re-use fetching logic (#120)
7PH Apr 23, 2024
cf45c7e
SCANNPM-2 Fetch scanner engine
lucas-paulger-sonarsource Apr 23, 2024
d671b39
SCANNPM-2 Implement fallback on old bootstrapping logic
7PH Apr 18, 2024
63fcba2
SCANNPM-2 Log top-level errors & Adjust scan method
7PH Apr 23, 2024
4e16618
SCANNPM-2 Support custom cache location (#123)
lucas-paulger-sonarsource Apr 24, 2024
2786c56
SCANNPM-2 Implement running the Scanner Engine
7PH Apr 23, 2024
01df4d4
SCANNPM-2 Write targz test (#125)
lucas-paulger-sonarsource Apr 25, 2024
0affbae
SCANNPM-2 Allow sending arbitrary os/arch using default properties
7PH Apr 25, 2024
d805adb
SCANNPM-2 Add support for skipping JRE provisioning
7PH Apr 28, 2024
e50b7de
SCANNPM-2 Add support for dumping data to file instead of running the…
7PH Apr 28, 2024
fc126a1
SCANNPM-2 Add support for sonar.scanner.responseTimeout
7PH Apr 28, 2024
6dd8720
SCANNPM-2 Sanitize input passed to child processes (#135)
vdiez May 1, 2024
6ebaa08
SCANNPM-2 Add support to parse proxy configuration from HTTP[S]_PROXY…
7PH Apr 30, 2024
6bbf714
SCANNPM-2 Add support for reading PKCS12 truststore and keystores
7PH Apr 29, 2024
efcd17b
SCANNPM-5 Update CI tasks (#127)
lucas-paulger-sonarsource May 1, 2024
ec96c64
SCANNPM-2 Use new endpoints & checksum/download logic & Do not use ax…
7PH May 1, 2024
25c9683
SCANNPM-3 Cleanup/migrate old tests
lucas-paulger-sonarsource May 3, 2024
938a248
SCANNPM-2 Use which/where.exe to detect SonarScanner CLI presence
7PH May 2, 2024
770630d
SCANNPM-2 Change wasJreCacheHit from bool to enum and mark it disable…
7PH May 2, 2024
8be5bfa
SCANNPM-3 Test with Scanner cli v6
vdiez May 3, 2024
1636eed
SCANNPM-2 Validation fixes (#140)
7PH May 8, 2024
ee83965
SCANNPM-2 Polish logging and cleanup invalid cache (#141)
lucas-paulger-sonarsource May 13, 2024
1c2efbc
SCANNPM-35 Change default values and logic for inferring package.json…
7PH May 23, 2024
4b76d52
SCANNPM-8 Reintroduce default export
7PH May 27, 2024
b31554f
SCANNPM-7 Update Readme (#144)
lucas-paulger-sonarsource May 29, 2024
c73a82c
SCANNPM-7 Fix documentation obsolete caPath & Add link to v3 document…
7PH May 29, 2024
df1fe76
SCANNPM-36 Never send null or missing values to the scanner engine
7PH May 29, 2024
c81c947
NO-JIRA Bump version to v4.0.0
7PH May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest

USER root

ARG NODE_VERSION=16
ARG NODE_VERSION=18

RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && apt-get install -y nodejs=${NODE_VERSION}.*

Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cmake-build-debug/

# IntelliJ
/out/
*.iml

# mpeltonen/sbt-idea plugin
.idea_modules/
Expand All @@ -57,6 +58,10 @@ fabric.properties

.idea/


### VS Code ###
.vscode/

### Node ###
# Logs
logs
Expand Down Expand Up @@ -136,3 +141,6 @@ xunit.xml

# MacOS
.DS_Store

# TS build artifacts
build/
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ This module is analyzed on SonarCloud.

[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=SonarSource_sonar-scanner-npm&metric=alert_status)](https://sonarcloud.io/project/overview?id=SonarSource_sonar-scanner-npm) [![Maintainability](https://sonarcloud.io/api/project_badges/measure?project=SonarSource_sonar-scanner-npm&metric=sqale_rating)](https://sonarcloud.io/project/overview?id=SonarSource_sonar-scanner-npm) [![Reliability](https://sonarcloud.io/api/project_badges/measure?project=SonarSource_sonar-scanner-npm&metric=reliability_rating)](https://sonarcloud.io/project/overview?id=SonarSource_sonar-scanner-npm) [![Security](https://sonarcloud.io/api/project_badges/measure?project=SonarSource_sonar-scanner-npm&metric=security_rating)](https://sonarcloud.io/project/overview?id=SonarSource_sonar-scanner-npm) [![Releases](https://img.shields.io/github/release/SonarSource/sonar-scanner-npm.svg)](https://github.com/SonarSource/sonar-scanner-npm/releases)

This is the documentation for v4. If you are using v3, refer to [the v3 documentation](https://github.com/SonarSource/sonar-scanner-npm/tree/37797347a30635647da5a45ed912a9ae77405b85).

## Installation

_Prerequisite: Node v16+ (otherwise use sonarqube-scanner v2.9.1)_
_Prerequisite: Node v18+ (for v4 and above)_

_Prerequisite: Node v16+ (for v3, otherwise use sonarqube-scanner v2.9.1)_

This package is available on npm as: `sonarqube-scanner`

Expand All @@ -34,20 +38,25 @@ The following example shows how to run an analysis on a JavaScript
project, and pushing the results to a SonarQube instance:

```javascript
const scanner = require('sonarqube-scanner');
const scanner = require('sonarqube-scanner').default;

scanner(
{
serverUrl: 'https://sonarqube.mycompany.com',
token: '019d1e2e04eefdcd0caee1468f39a45e69d33d3f', // use "login" for SQ up to version 9
token: '019d1e2e04eefdcd0caee1468f39a45e69d33d3f',
options: {
'sonar.projectName': 'My App',
'sonar.projectDescription': 'Description for "My App" project...',
'sonar.sources': 'src',
'sonar.tests': 'test',
},
},
() => process.exit(),
error => {
if (error) {
console.error(error);
}
process.exit();
},
);
```

Expand All @@ -57,9 +66,7 @@ scanner(

- `parameters` _Map_
- `serverUrl` _String_ (optional) The URL of the SonarQube server. Defaults to http://localhost:9000
- `login` _String_ (optional) The login used to connect to the SonarQube server up to version 9. Empty by default.
- `token` _String_ (optional) The token used to connect to the SonarQube server v10+ or SonarCloud. Empty by default.
- `caPath` _String_ (optional) the path to a CA to pass as `https.request()` [options](https://nodejs.org/api/https.html#https_https_request_options_callback).
- `options` _Map_ (optional) Used to pass extra parameters for the analysis. See the [official documentation](http://redirect.sonarsource.com/doc/analysis-parameters.html) for more details.
- `callback` _Function_ (optional)
Callback (the execution of the analysis is asynchronous).
Expand Down Expand Up @@ -100,7 +107,7 @@ Similar to the above, you can specify analysis properties and settings using eit

#### _I constantly get "Impossible to download and extract binary [...] In such situation, the best solution is to install the standard SonarScanner", what can I do?_

You can install manually the [standard SonarScanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html),
You can install manually the [standard SonarScanner](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner/),
which requires to have a Java Runtime Environment available too (Java 8+).

It is important to make sure that the SonarScanner `$install_directory/bin` location is added to the system `$PATH` environment variable. This will ensure that `sonar-scanner` command will be resolved by the customScanner, and prevent the error:
Expand All @@ -125,7 +132,7 @@ It needs to be [installed manually](https://laptrinhx.com/docker-for-mac-alpine-

Thanks to [Philipp Eschenbach](https://github.com/peh) for troubleshooting this on [issue #59](https://github.com/bellingard/sonar-scanner-npm/issues/59).

## Download From Mirrors
## Download From Mirrors (SQ < 10.6 only)

By default, the scanner binaries are downloaded from `https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/`.
To use a custom mirror, set `$SONAR_SCANNER_MIRROR`. Or download precise version with `$SONAR_SCANNER_VERSION`
Expand Down Expand Up @@ -156,7 +163,7 @@ Proxy authentication is supported as well, see below.
## Specifying the cache folder

By default, the scanner binaries are cached into `$HOME/.sonar/native-sonar-scanner` folder.
To use a custom cache fodler instead of `$HOME`, set `$SONAR_BINARY_CACHE`.
To use a custom cache folder instead of `$HOME`, set `$SONAR_BINARY_CACHE`.

**Example:**

Expand Down
2 changes: 2 additions & 0 deletions bin/sonar-scanner
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../build/src/runner');
9 changes: 6 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* sonar-scanner-npm
* Copyright (C) 2022-2023 SonarSource SA
* Copyright (C) 2022-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
Expand All @@ -19,12 +19,15 @@
*/

module.exports = {
collectCoverageFrom: ['src/**/*.js'],
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverageFrom: ['src/**/*.{js,ts}'],
coverageReporters: ['lcov', 'text'],
coveragePathIgnorePatterns: ['.fixture.', '/fixtures/'],
moduleFileExtensions: ['js', 'ts', 'json'],
moduleDirectories: ['node_modules'],
testResultsProcessor: 'jest-sonar-reporter',
testMatch: ['<rootDir>/test/unit/**/*.test.js'],
testMatch: ['<rootDir>/test/unit/**/*.test.ts'],
testTimeout: 20000,
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
};
Loading