@zohodesk/codestandard-analytics
Advanced tools
Comparing version 0.0.1-exp-21 to 0.0.1-exp-22
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.constructConfigPath = constructConfigPath; | ||
exports.filterExemptionFiles = filterExemptionFiles; | ||
exports.filterFiles = filterFiles; | ||
@@ -16,3 +17,3 @@ exports.getFiles = getFiles; | ||
exports.getStagedFiles_preCommit = getStagedFiles_preCommit; | ||
exports.removeDiffFile = removeDiffFile; | ||
exports.removeFile = removeFile; | ||
exports.resolvePath = resolvePath; | ||
@@ -181,11 +182,8 @@ var _path = _interopRequireDefault(require("path")); | ||
/** | ||
* @function {removeDiffFile} - this methods remove diff json file | ||
* @function {removeFile} - this methods remove diff json file | ||
* @returns {void} | ||
*/ | ||
function removeDiffFile() { | ||
const { | ||
branchDiffPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
(0, _fs.unlinkSync)(branchDiffPath); | ||
function removeFile(file_path) { | ||
(0, _fileUtils.checkIfFileExists)(file_path) ? (0, _fs.unlinkSync)(file_path) : null; | ||
} | ||
@@ -201,2 +199,5 @@ | ||
function filterExemptionFiles(exemptionFiles, actualFiles) { | ||
if (exemptionFiles.length == 0) { | ||
return actualFiles; | ||
} | ||
return actualFiles.filter(file => { | ||
@@ -203,0 +204,0 @@ if (exemptionFiles.includes(file)) { |
@@ -16,2 +16,4 @@ "use strict"; | ||
var _child_process = require("child_process"); | ||
var _requestUtils = require("../../utils/requestUtils"); | ||
var _getSonarProperties = require("../sonar-dependencies/getSonarProperties"); | ||
/** | ||
@@ -45,2 +47,3 @@ * @function executeLintAnalysis - start lint analysis | ||
} = (0, _getFileUtils.getFiles)(env, dir, branchDiffPath); | ||
cliParams.cmdExecuted == "lint-ci" && (await (0, _requestUtils.isExemptionApplied)()) ? JsFiles = (0, _getFileUtils.filterExemptionFiles)((0, _requestUtils.getFilesSonarQube_API)((0, _getSonarProperties.getProjectNameForExemption)()), JsFiles) : null; | ||
const filteredLintReport = await startLint(branch_diff_json, JsFiles, env, impactBased, ruleConfigurationPath); | ||
@@ -47,0 +50,0 @@ _logger.Logger.stop(); |
@@ -1,30 +0,33 @@ | ||
"use strict"; | ||
// import { getProjectNameFrmGit, getSpawnOutput } from "./sonar-dependencies/getSonarProperties"; | ||
// import path from "path"; | ||
// function showMsgPopUp(condition) { | ||
// // java -jar ./IDEMessagePluginRecent.jar project_name "BothStagedAndUnstaged" server_url java_version_output | ||
// const command = "java"; | ||
// const params = [ | ||
// "-jar", | ||
// `${getPopupJarPath()}`, | ||
// getProjectNameFrmGit(), | ||
// condition, | ||
// "java version 11" | ||
// ]; | ||
// switch (condition) { | ||
// case "NoIssueFound": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// case "IssueFound": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// case "BothStagedAndUnstaged": | ||
// getSpawnOutput(command, params); | ||
// break; | ||
// default: | ||
// break; | ||
// } | ||
// } | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.showMsgPopUp = showMsgPopUp; | ||
var _getSonarProperties = require("./sonar-dependencies/getSonarProperties"); | ||
var _path = _interopRequireDefault(require("path")); | ||
function showMsgPopUp(condition) { | ||
// java -jar ./IDEMessagePluginRecent.jar project_name "BothStagedAndUnstaged" server_url java_version_output | ||
const command = "java"; | ||
const params = ["-jar", `${getPopupJarPath()}`, (0, _getSonarProperties.getProjectNameFrmGit)(), condition, "java version 11"]; | ||
switch (condition) { | ||
case "NoIssueFound": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
case "IssueFound": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
case "BothStagedAndUnstaged": | ||
(0, _getSonarProperties.getSpawnOutput)(command, params); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
function getPopupJarPath() { | ||
return _path.default.resolve(__dirname, "sonar-dependencies", "java-jar", "IDEMessagePluginRecent.jar"); | ||
} | ||
// function getPopupJarPath() { | ||
// return path.resolve(__dirname,"sonar-dependencies","java-jar", "IDEMessagePluginRecent.jar"); | ||
// } | ||
// export { showMsgPopUp }; | ||
"use strict"; |
@@ -1,56 +0,52 @@ | ||
"use strict"; | ||
// import https from 'https'; | ||
// import { cliArgsToObject } from '../utils/cliArgsToObject'; | ||
// import { Logger } from '../utils/logger'; | ||
// import fs from 'fs'; | ||
// import path from 'path'; | ||
// import { spawn } from 'child_process'; | ||
// import { getSonarJarPath } from '../utils/rootPath'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.requestJAR = requestJAR; | ||
var _https = _interopRequireDefault(require("https")); | ||
var _cliArgsToObject = require("../utils/cliArgsToObject"); | ||
var _logger = require("../utils/logger"); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _child_process = require("child_process"); | ||
var _rootPath = require("../utils/rootPath"); | ||
async function requestJAR(cliParams, options = {}) { | ||
const { | ||
pat, | ||
requestUrl | ||
} = (0, _cliArgsToObject.cliArgsToObject)(cliParams); | ||
const endpoint = requestUrl || 'https://zgit.csez.zohocorpin.com/zohodesk/zohodesk/-/raw/master/sonardependencies/lib/sonar-scanner-cli-4.8.0.2856.jar?inline=false'; | ||
const body = { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/java-archive', | ||
'PRIVATE-TOKEN': `${pat}` | ||
} | ||
}; | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cloning jar ${(0, _rootPath.getSonarJarPath)()}`); | ||
if (!pat) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `PAT token is Needed ..`); | ||
process.exit(0); | ||
} | ||
return await new Promise(resolve => { | ||
const jarAPI = _https.default.request(endpoint, body, response => { | ||
var responseChunk = ''; | ||
const fileStream = _fs.default.createWriteStream((0, _rootPath.getSonarJarPath)()); | ||
response.on('data', data => { | ||
responseChunk += data; | ||
}); | ||
response.pipe(fileStream); | ||
fileStream.on('finish', finish => { | ||
fileStream.close(); | ||
}); | ||
response.on('error', error => { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error - ${error}`); | ||
}); | ||
response.on('end', end => { | ||
// at end | ||
resolve({ | ||
path: (0, _rootPath.getSonarJarPath)() | ||
}); | ||
}); | ||
}); | ||
jarAPI.end(); | ||
}); | ||
} | ||
// async function requestJAR(cliParams, options = {}) { | ||
// const { pat, requestUrl } = cliArgsToObject(cliParams); | ||
// const endpoint = | ||
// requestUrl || | ||
// 'https://zgit.csez.zohocorpin.com/zohodesk/zohodesk/-/raw/master/sonardependencies/lib/sonar-scanner-cli-4.8.0.2856.jar?inline=false'; | ||
// const body = { | ||
// method: 'GET', | ||
// headers: { | ||
// 'Content-Type': 'application/java-archive', | ||
// 'PRIVATE-TOKEN': `${pat}` | ||
// } | ||
// }; | ||
// Logger.log(Logger.INFO_TYPE, `Cloning jar ${getSonarJarPath()}`); | ||
// if (!pat) { | ||
// Logger.log(Logger.FAILURE_TYPE, `PAT token is Needed ..`); | ||
// process.exit(0); | ||
// } | ||
// return await new Promise(resolve => { | ||
// const jarAPI = https.request(endpoint, body, response => { | ||
// var responseChunk = ''; | ||
// const fileStream = fs.createWriteStream(getSonarJarPath()); | ||
// response.on('data', data => { | ||
// responseChunk += data; | ||
// }); | ||
// response.pipe(fileStream); | ||
// fileStream.on('finish', finish => { | ||
// fileStream.close(); | ||
// }); | ||
// response.on('error', error => { | ||
// Logger.log(Logger.FAILURE_TYPE, `Error - ${error}`); | ||
// }); | ||
// response.on('end', end => { | ||
// // at end | ||
// resolve({ path: getSonarJarPath() }); | ||
// }); | ||
// }); | ||
// jarAPI.end(); | ||
// }); | ||
// } | ||
// export { requestJAR }; | ||
"use strict"; |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.getProjectName = getProjectName; | ||
exports.getProjectNameForExemption = getProjectNameForExemption; | ||
exports.getProjectNameFrmGit = getProjectNameFrmGit; | ||
@@ -24,2 +25,3 @@ exports.getRepoName = getRepoName; | ||
var _hash = require("../../utils/hash"); | ||
var _logger = require("../../../build/utils/logger"); | ||
/** | ||
@@ -32,5 +34,5 @@ * @function getSonarHostUrl - get sonar host url from property file | ||
var { | ||
sonar_hostURL | ||
metricServerHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
return sonar_hostURL; | ||
return metricServerHost; | ||
} | ||
@@ -49,29 +51,22 @@ | ||
dir = null, | ||
diffPath = null, | ||
cmdExecuted | ||
} = cliArgument; | ||
const { | ||
branchDiffPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const default_project = getProjectNameFrmGit(); | ||
var project_name = dir ? `${default_project}_dev` : diffPath && cmdExecuted == 'lint-ci' ? `${default_project}_CI` : `${default_project}_dev_${timeSuffix}`; | ||
var project_name = dir ? `${default_project}_Dev_Report` : (0, _fileUtils.checkIfFileExists)(branchDiffPath) && cmdExecuted == 'lint-ci' ? `${default_project}_CI-pipeline` : `${default_project}_Dev-pipeline`; | ||
return project_name; | ||
} | ||
// function getTestFiles(cliArgument) { | ||
// return " "; | ||
// } | ||
/** | ||
* @function getProjectNameForExemption - get project name for ExemptionFiles | ||
* @returns string | ||
*/ | ||
// /** | ||
// * @function getLintFiles - filter files based on cli argument | ||
// * @param {Object} cliArgument - Object represent cli Argument | ||
// * @returns {Array<string>} | ||
// */ | ||
function getProjectNameForExemption() { | ||
const default_project = getProjectNameFrmGit(); | ||
return `${default_project}_Dev-pipeline`; | ||
} | ||
// function getLintFiles(cliArgument) { | ||
// var { diffPath = false, dir = false } = cliArgument; | ||
// const linterFilesDirectory = dir && checkIfFileExists(dir) ? dir : false | ||
// if (linterFilesDirectory && !diffPath) { | ||
// return getFilesPathFromRootDir(linterFilesDirectory); | ||
// } | ||
// return getFilesFromBranchDiff(require(resolvePath(diffPath))); | ||
// } | ||
/** | ||
@@ -122,4 +117,10 @@ * @function getSonarProperties - collect all sonar properties | ||
function getGitUsername() { | ||
const userName = getSpawnOutput("git", ["config", "user.email"]); | ||
return userName.pop().split("@")[0]; | ||
try { | ||
const userName = getSpawnOutput("git", ["config", "user.email"]); | ||
return userName.pop().split("@")[0]; | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -133,4 +134,10 @@ | ||
function getRepoName() { | ||
const repoName = getSpawnOutput("git", ["remote", "get-url", "origin"]); | ||
return repoName.pop().split("/").pop().split(".")[0]; | ||
try { | ||
const repoName = getSpawnOutput("git", ["remote", "get-url", "origin"]); | ||
return repoName.pop().split("/").pop().split(".")[0]; | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -145,4 +152,10 @@ | ||
// git rev-parse --abbrev-ref HEAD | ||
var branchName = getSpawnOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"]); // to get current branch | ||
return branchName.shift().trim(); | ||
try { | ||
var branchName = getSpawnOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"]); // to get current branch | ||
return branchName.shift().trim(); | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `make sure that you have propery setup git`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
process.exit(0); | ||
} | ||
} | ||
@@ -149,0 +162,0 @@ |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _getFileUtils = require("../eslint/getFileUtils"); | ||
var _fileUtils = require("../../utils/fileUtils"); | ||
var _requestUtils = require("../../utils/requestUtils"); | ||
/** | ||
@@ -42,6 +44,8 @@ * @note javascript code to start sonar Server | ||
child_process.on("close", code => { | ||
const { | ||
branchDiffPath | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
code === 0 ? global.analytics.sonarQubeStatus = true : null; | ||
_logger.Logger.stop(); | ||
(0, _sonarReportSummary.writeSummaryOfLint)(cliParams); | ||
env == "ci" ? (0, _getFileUtils.removeDiffFile)() : null; | ||
_logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, 'SonarQube analysis completed...'); | ||
@@ -52,3 +56,4 @@ _logger.Logger.cliLog(_logger.Logger.SUCCESS_TYPE, `Report ${code === 0 ? "successfully" : "failed"} sent to the server : Status - ${code === 0 ? "Success" : "Failure"}`); | ||
code === 0 ? _logger.Logger.cliLog(_logger.Logger.INFO_TYPE, `SonarQube Artifacts Path - ${(0, _getSonarProperties.getSonarArtifactsDir)()}`) : null; | ||
env == 'ci' && cliParams.cmdExecuted == "lint-ci" || cliParams.cmdExecuted == "dev-ci" ? (0, _getFileUtils.removeFile)(branchDiffPath) && (0, _getFileUtils.removeFile)((0, _requestUtils.getExemptionFileInfoPath)()) : null; | ||
}); | ||
} |
@@ -23,7 +23,7 @@ "use strict"; | ||
const { | ||
sonar_hostURL | ||
metricServerHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
return { | ||
projectName: $projectName, | ||
reportUrl: global.analytics.sonarQubeStatus === true ? `${sonar_hostURL}/project/issues?id=${$projectName}&resolved=false` : sonar_hostURL, | ||
reportUrl: global.analytics.sonarQubeStatus === true ? `${metricServerHost}/dashboard?id=${$projectName}` : metricServerHost, | ||
jsonReportPath: (0, _getFileUtils.getLintReportPath)().toString() | ||
@@ -30,0 +30,0 @@ }; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _fileUtils = require("../utils/fileUtils.js"); | ||
var _request = require("../utils/request"); | ||
var _requestUtils = require("../utils/requestUtils.js"); | ||
/** | ||
@@ -42,6 +42,6 @@ * | ||
case "lint-ci": | ||
case "local": | ||
case "dev-ci": | ||
{ | ||
(0, _fileUtils.checkConfigurationFileExist)(); | ||
(0, _request.createBranchDiff)(); | ||
(0, _requestUtils.createBranchDiff)(); | ||
const $cliObjects = (0, _cliArgsToObject.cliArgsToObject)(option); | ||
@@ -48,0 +48,0 @@ $cliObjects.env = "ci"; |
@@ -8,5 +8,5 @@ const path = require("path"); | ||
* @property {string} lintReportPath - The path to the lint report JSON file. | ||
* @property {string} sonar_host_URL - The URL of the SonarQube server. | ||
* @property {string} loginName - The username for authentication with the SonarQube server. | ||
* @property {string} password - The password for authentication with the SonarQube server. | ||
* @property {string} metricServerHost - The URL of the SonarQube server. | ||
* @property {string} exemptionInstanceHost - This is Exemption running host URL | ||
* @property {string} metric_token - The token for authentication with the SonarQube server. | ||
* @property {string} gitEndPoint - API EndPoint for Git Actions | ||
@@ -23,3 +23,4 @@ * @property {number} projectId - project id of repository | ||
lintReportPath: path.resolve(process.cwd(), "lint-report", "lintReport.json"), | ||
sonar_hostURL: "https://client-linters.zohodesk.csez.zohocorpin.com", | ||
metricServerHost: "https://client-linters.zohodesk.csez.zohocorpin.com", | ||
exemptionInstanceHost:"", | ||
metric_token: "zxh_9737850jh2l53ml17223929ihii73072j54j2260", | ||
@@ -32,1 +33,2 @@ branchDiffPath:path.resolve(process.cwd(),"diffBranch.json"), | ||
}; | ||
@@ -143,3 +143,3 @@ "use strict"; | ||
const defaultLintConfPath = _path.default.resolve(__dirname, "..", "setup", "sampleLint.config.js"); | ||
return checkIfFileExists(actualLintConfPath) && JSON.stringify(require(actualLintConfPath)) === JSON.stringify(require(defaultLintConfPath)) ? require(actualLintConfPath) : require(defaultLintConfPath); | ||
return checkIfFileExists(actualLintConfPath) ? require(actualLintConfPath) : require(defaultLintConfPath); | ||
} | ||
@@ -146,0 +146,0 @@ /** |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,5 +8,8 @@ value: true | ||
exports.createBranchDiff = createBranchDiff; | ||
exports.getExemptionFileInfoPath = getExemptionFileInfoPath; | ||
exports.getFilesSonarQube_API = getFilesSonarQube_API; | ||
exports.getGitProjectId = getGitProjectId; | ||
exports.requestGit = requestGit; | ||
exports.requestUtils = requestUtils; | ||
exports.isExemptionApplied = isExemptionApplied; | ||
exports.requestAPI = requestAPI; | ||
exports.requestUtilsCLI = requestUtilsCLI; | ||
var _child_process = require("child_process"); | ||
@@ -17,31 +21,22 @@ var _fs = require("fs"); | ||
var _logger = require("./logger"); | ||
async function requestGit(apiDetails, options = {}) { | ||
const { | ||
action, | ||
headers, | ||
endPoint | ||
} = apiDetails; | ||
const body = { | ||
method: action, | ||
headers: headers | ||
}; | ||
return await new Promise(resolve => { | ||
const request = https.request(endPoint, body, response => { | ||
var responseChunk = ""; | ||
const fileStream = fs.createWriteStream(getLocalBranchPath()); | ||
response.on("data", data => { | ||
responseChunk += data; | ||
var _http = _interopRequireDefault(require("http")); | ||
var _path = _interopRequireDefault(require("path")); | ||
function requestAPI(apiDetails, body, options = {}) { | ||
const result = []; | ||
return new Promise(resolve => { | ||
var request = _http.default.request(apiDetails, function (res) { | ||
; | ||
var chunks = []; | ||
res.on("data", function (chunk) { | ||
chunks.push(chunk); | ||
}); | ||
response.pipe(fileStream); | ||
fileStream.on("finish", finish => { | ||
fileStream.close(); | ||
res.on("end", function (chunk) { | ||
var body = Buffer.concat(chunks); | ||
resolve(body.toString()); | ||
}); | ||
response.on("error", error => { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error - ${error}`); | ||
res.on("error", function (error) { | ||
console.error(error); | ||
}); | ||
response.on("end", end => { | ||
// at end | ||
resolve({}); | ||
}); | ||
}); | ||
request.write(body); | ||
request.end(); | ||
@@ -52,7 +47,7 @@ }); | ||
/** | ||
*@function requestUtils - method execute curl cli request | ||
*@function requestUtilsCLI - method execute curl cli request | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
function requestUtils(command) { | ||
function requestUtilsCLI(command) { | ||
return (0, _child_process.execSync)(command, { | ||
@@ -77,15 +72,21 @@ shell: true | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
if (projectId == "project-id") { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that project id is properly configured`); | ||
if (projectId == 'project-id') { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Make sure that project id is properly configured`); | ||
projectId = getGitProjectId(); | ||
} | ||
const endPoint = `${gitEndPoint}/api/v4/projects/${projectId}/repository/compare?from=${compareBranch}&to=${(0, _getSonarProperties.getBranchName)()}`; | ||
const endPoint = `${gitEndPoint}/api/v4/projects/${projectId.toString()}/repository/compare?from=${compareBranch}&to=${(0, _getSonarProperties.getBranchName)()}`; | ||
try { | ||
command = `curl --header "PRIVATE-TOKEN:${(0, _hash.decrypt)(token, 12)}" "${endPoint}"`; | ||
(0, _fs.writeFileSync)(branchDiffPath, requestUtils(command)); | ||
(0, _fs.writeFileSync)(branchDiffPath, requestUtilsCLI(command)); | ||
} catch (err) { | ||
_logger.Logger.log(_logger.Logger.INFO_TYPE, `INFO : If you are using a VPN and encounter an SSL certification issue, ensure that the proxy is enabled for SSH and shell connections.`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that you have access to this repository ${(0, _getSonarProperties.getRepoName)()}`); | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Make sure that you have access to this repository ${(0, _getSonarProperties.getRepoName)()}`); | ||
} | ||
} | ||
/** | ||
* @function getGitProjectId - retrives project id of repository | ||
* @returns string | ||
*/ | ||
function getGitProjectId() { | ||
@@ -105,2 +106,71 @@ var command; | ||
} | ||
} | ||
/** | ||
* @function getFilesSonarQube_API - returns array of Paths after filteration of response of sonarQube issue api | ||
* @param {String} projectName - project name of lint report | ||
* @returns Array<String> | ||
*/ | ||
function getFilesSonarQube_API(projectName) { | ||
try { | ||
const { | ||
metricServerHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const encryptedSonarToken = "cmFqYXNla2FyLmhtOnJhamFzZWthci5obQ=="; | ||
const sonarQubeIssueGetAPI = `${metricServerHost}/api/issues/search?componentKeys=${projectName}&s=FILE_LINE&resolved=false&ps=100&facets=severities,types&additionalFields=_all&timeZone=Asia/Calcutta`; | ||
var command = (0, _child_process.execSync)(`curl --location "${sonarQubeIssueGetAPI}" --header "Authorization: Basic ${encryptedSonarToken}"`); | ||
(0, _fs.writeFileSync)(getExemptionFileInfoPath(), JSON.stringify(command.toString())); | ||
} catch (error) { | ||
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error); | ||
return []; | ||
} | ||
const exemptionDetails = JSON.parse(require(getExemptionFileInfoPath())); | ||
return exemptionDetails !== null && exemptionDetails !== void 0 && exemptionDetails.issues ? Array.from(new Set(exemptionDetails.issues.map(file => { | ||
return file.component.split(':').pop(); | ||
}))) : []; | ||
} | ||
/** | ||
* @function getExemptionFileInfoPath - returns path of exemption details | ||
* @returns string | ||
*/ | ||
function getExemptionFileInfoPath() { | ||
return _path.default.resolve(__dirname, '..', '..', 'exemptionInfo.json'); | ||
} | ||
/** | ||
* @function isExemptionApplied - check whether given branch raised exemption or not | ||
* @returns boolean | ||
*/ | ||
async function isExemptionApplied() { | ||
const { | ||
exemptionInstanceHost | ||
} = (0, _fileUtils.getLintConfiguration)(); | ||
const requestBody = JSON.stringify({ | ||
branchName: (0, _getSonarProperties.getBranchName)() | ||
}); | ||
const { | ||
hostname, | ||
port, | ||
pathname | ||
} = new URL(`${exemptionInstanceHost}/getApprovedTicket`); | ||
const apiInfo = { | ||
'method': 'GET', | ||
'hostname': hostname, | ||
'port': port, | ||
'path': pathname, | ||
'headers': { | ||
'Content-Type': 'text/json', | ||
'Authentication': 'hash', | ||
'Content-Length': Buffer.byteLength(requestBody) | ||
}, | ||
'maxRedirects': 20 | ||
}; | ||
var exemption_response = await requestAPI(apiInfo, requestBody); | ||
console.log(exemption_response); | ||
process.exit(1); | ||
exemption_response = JSON.parse(exemption_response); | ||
return exemption_response.status == 'free' ? false : exemption_response.status == 'Approved' ? true : false; | ||
} |
{ | ||
"name": "@zohodesk/codestandard-analytics", | ||
"version": "0.0.1-exp-21", | ||
"version": "0.0.1-exp-22", | ||
"description": "linting tool", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
739400
35
2292
10