New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@koliveira15/nx-sonarqube

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koliveira15/nx-sonarqube - npm Package Compare versions

Comparing version 1.0.4 to 1.1.101

src/executors/scan/utils/utils.d.ts

0

executors.json

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

20

package.json
{
"name": "@koliveira15/nx-sonarqube",
"description": "A Nx plugin that scans projects using SonarQube / SonarCloud.",
"repository": {
"type": "git",
"url": "https://github.com/koliveira15/nx-sonarqube.git"
"url": "https://github.com/koliveira15/nx-sonarqube.git",
"directory": "packages/nx-sonarqube"
},
"version": "1.0.4",
"main": "src/index.js",
"version": "1.1.101",
"main": "./src/index.js",
"generators": "./generators.json",
"executors": "./executors.json",
"typings": "./src/index.d.ts",
"peerDependencies": {
"@nx/devkit": "16.7.4"
},
"dependencies": {
"sonarqube-scanner": "2.8.1",
"@phenomnomnominal/tsquery": "5.0.0",
"tslib": "2.3.0"
"@phenomnomnominal/tsquery": "5.0.1",
"sonarqube-scanner": "3.0.1",
"tslib": "2.5.2"
},
"peerDependencies": {}
"type": "commonjs"
}
import { ScanExecutorSchema } from './schema';
import { ExecutorContext } from '@nrwl/devkit';
import { ExecutorContext } from '@nx/devkit';
export default function (options: ScanExecutorSchema, context: ExecutorContext): Promise<{
success: boolean;
}>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const sonarQubeScanner = require("sonarqube-scanner");
const devkit_1 = require("@nrwl/devkit");
const tsquery_1 = require("@phenomnomnominal/tsquery");
const fs_1 = require("fs");
const child_process_1 = require("child_process");
const devkit_1 = require("@nx/devkit");
const utils_1 = require("./utils/utils");
function default_1(options, context) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let success = true;
yield scanner(options, context).catch((e) => {
yield (0, utils_1.scanner)(options, context).catch((e) => {
devkit_1.logger.error(`The SonarQube scan failed for project '${context.projectName}'. Error: ${e}`);

@@ -22,83 +19,2 @@ success = false;

exports.default = default_1;
function determinePaths(options, context) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const sources = [];
const lcovPaths = [];
const graph = yield (0, devkit_1.createProjectGraphAsync)();
const targets = graph.dependencies[context.projectName].filter((project) => (options.skipImplicitDeps
? project.type === devkit_1.DependencyType.static
: project.type === devkit_1.DependencyType.static ||
project.type === devkit_1.DependencyType.implicit) &&
!project.target.includes('npm:'));
targets.push({
type: devkit_1.DependencyType.static,
target: context.projectName,
source: context.projectName,
});
targets.forEach((target) => {
const projectConfig = context.workspace.projects[target.target];
const testTarget = projectConfig.targets.test;
sources.push(projectConfig.sourceRoot);
if (testTarget) {
if (testTarget.options.jestConfig) {
const jestConfigPath = projectConfig.targets.test.options.jestConfig;
const jestConfig = (0, fs_1.readFileSync)(jestConfigPath, 'utf-8');
const ast = tsquery_1.tsquery.ast(jestConfig);
const nodes = (0, tsquery_1.tsquery)(ast, 'Identifier[name="coverageDirectory"] ~ StringLiteral', { visitAllChildren: true });
if (nodes.length) {
lcovPaths.push((0, devkit_1.joinPathFragments)(nodes[0]
.getText()
.replace(new RegExp(/'/g), '')
.replace(/^(?:\.\.\/)+/, ''), 'lcov.info'));
}
else {
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a coverageDirectory in ${jestConfigPath}`);
}
}
else {
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a jestConfig`);
}
}
else {
devkit_1.logger.warn(`Skipping ${context.projectName} as it does not have a test target`);
}
});
return Promise.resolve({
lcovPaths: lcovPaths.join(','),
sources: sources.join(','),
});
});
}
function scanner(options, context) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const paths = yield determinePaths(options, context);
devkit_1.logger.log(`Included sources: ${paths.sources}`);
if (!options.qualityGate)
devkit_1.logger.warn(`Skipping quality gate check`);
sonarQubeScanner({
serverUrl: options.hostUrl,
options: {
'sonar.branch.name': options.branches
? (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD').toString()
: '',
'sonar.exclusions': options.exclusions,
'sonar.javascript.lcov.reportPaths': paths.lcovPaths,
'sonar.language': 'ts',
'sonar.login': options.login,
'sonar.organization': options.organization,
'sonar.password': options.password,
'sonar.projectKey': options.projectKey,
'sonar.projectName': options.projectName,
'sonar.projectVersion': options.projectVersion,
'sonar.qualitygate.timeout': options.qualityGateTimeout,
'sonar.qualitygate.wait': String(options.qualityGate),
'sonar.scm.provider': 'git',
'sonar.sources': paths.sources,
'sonar.sourceEncoding': 'UTF-8',
'sonar.typescript.tsconfigPath': 'tsconfig.base.json',
'sonar.verbose': 'true',
},
});
});
}
//# sourceMappingURL=executor.js.map

@@ -6,5 +6,3 @@ export interface ScanExecutorSchema {

exclusions?: string;
login?: string;
organization?: string;
password?: string;
projectName?: string;

@@ -15,2 +13,6 @@ projectVersion?: string;

skipImplicitDeps?: boolean;
testInclusions?: string;
tsConfig?: string;
verbose?: boolean;
extra?: { [option: string]: string };
}
{
"version": 2,
"outputCapture": "direct-nodejs",
"$schema": "http://json-schema.org/schema",
"cli": "nx",
"title": "SonarQube Scanner Executor",

@@ -26,6 +27,2 @@ "description": "Scans and uploads test coverage based on SonarQube options (https://docs.sonarqube.org/latest/analysis/analysis-parameters/)",

},
"login": {
"description": "The authentication token or login of a SonarQube user with either Execute Analysis permission on the project or Global Execute Analysis permission.",
"type": "string"
},
"organization": {

@@ -35,6 +32,2 @@ "description": "Sonar organization",

},
"password": {
"description": "If you're using an authentication token, leave this blank. If you're using a login, this is the password that goes with your sonar.login username.",
"type": "string"
},
"projectName": {

@@ -62,2 +55,17 @@ "description": "Name of the project that will be displayed on the web interface.",

"default": false
},
"testInclusions": {
"description": "Comma-delimited list of test file path patterns to be included in analysis. When set, only test files matching the paths set here will be included in analysis",
"type": "string",
"default": "**/*.spec.ts"
},
"tsConfig": {
"description": "Path to tsconfig.json",
"type": "string",
"default": "tsconfig.base.json"
},
"verbose": {
"description": "Add more detail to both client and server-side analysis logs",
"type": "boolean",
"default": false
}

@@ -64,0 +72,0 @@ },

@@ -1,3 +0,3 @@

import { Tree } from '@nrwl/devkit';
import { Tree } from '@nx/devkit';
import { NxSonarqubeGeneratorSchema } from './schema';
export default function (tree: Tree, options: NxSonarqubeGeneratorSchema): Promise<void>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const devkit_1 = require("@nrwl/devkit");
const devkit_1 = require("@nx/devkit");
function default_1(tree, options) {

@@ -21,3 +21,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () {

if (!gitIgnore.includes('.scannerwork')) {
gitIgnore += '\n.scannerwork';
gitIgnore += '\n# Sonar\n.scannerwork';
tree.write(ignoreFile, gitIgnore);

@@ -28,12 +28,16 @@ }

function updateTargetDefaults(tree) {
const nxJsonConfiguration = (0, devkit_1.readNxJson)();
const hasSonar = Object.keys(nxJsonConfiguration.targetDefaults).find((key) => key === 'sonar');
if (!hasSonar) {
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => {
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => {
const nxJsonConfiguration = (0, devkit_1.readNxJson)(tree);
if (!nxJsonConfiguration.targetDefaults.sonar) {
json.targetDefaults.sonar = {
dependsOn: ['^test', 'test'],
};
return json;
});
}
}
if (!nxJsonConfiguration.targetDefaults.test) {
json.targetDefaults.test = {
dependsOn: ['^test'],
};
}
return json;
});
}

@@ -48,6 +52,3 @@ function updateProjectConfig(tree, options) {

executor: '@koliveira15/nx-sonarqube:scan',
options: {
hostUrl: options.hostUrl,
projectKey: options.projectKey,
},
options: Object.assign({}, options),
};

@@ -54,0 +55,0 @@ (0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfiguration);

@@ -6,2 +6,12 @@ export interface NxSonarqubeGeneratorSchema {

skipTargetDefaults?: boolean;
branches?: boolean;
exclusions?: string;
login?: string;
organization?: string;
password?: string;
projectName?: string;
projectVersion?: string;
qualityGate?: boolean;
qualityGateTimeout?: string;
skipImplicitDeps?: boolean;
}
{
"$schema": "http://json-schema.org/schema",
"cli": "nx",
"$id": "NxSonarqube",

@@ -31,2 +30,46 @@ "title": "",

"default": false
},
"branches": {
"description": "Include branch name in analysis",
"type": "boolean",
"default": false
},
"exclusions": {
"description": "Files to exclude from coverage",
"type": "string"
},
"login": {
"description": "The authentication token or login of a SonarQube user with either Execute Analysis permission on the project or Global Execute Analysis permission.",
"type": "string"
},
"organization": {
"description": "Sonar organization",
"type": "string"
},
"password": {
"description": "If you're using an authentication token, leave this blank. If you're using a login, this is the password that goes with your sonar.login username.",
"type": "string"
},
"projectName": {
"description": "Name of the project that will be displayed on the web interface.",
"type": "string"
},
"projectVersion": {
"description": "The project version.",
"type": "string"
},
"qualityGate": {
"description": "Forces the analysis step to poll the SonarQube instance and wait for the Quality Gate status.",
"type": "boolean",
"default": true
},
"qualityGateTimeout": {
"description": "Sets the number of seconds that the scanner should wait for a report to be processed.",
"type": "string",
"default": "300"
},
"skipImplicitDeps": {
"description": "Skips adding implicit dependencies to the project graph analysis",
"type": "boolean",
"default": false
}

@@ -33,0 +76,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc