@deepcode/tsc
Advanced tools
Comparing version 2.1.0 to 2.1.1
import { Log } from 'sarif'; | ||
import { IAnalysisResult } from './interfaces/analysis-result.interface'; | ||
export default function getSarif(analysisResults: IAnalysisResult): Log; | ||
export declare function stringSplice(str: string, index: number, count: number, add?: string): string; | ||
export declare function getArgumentsAndMessage(helpers: { | ||
index: number[]; | ||
msg: number[]; | ||
}[], message: string): { | ||
message: string; | ||
argumentArray: string[]; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getArgumentsAndMessage = exports.stringSplice = void 0; | ||
function getSarif(analysisResults) { | ||
@@ -34,3 +35,3 @@ const { tool, suggestions } = getTools(analysisResults, getSuggestions(analysisResults)); | ||
var _a; | ||
const output = { driver: { name: 'DeepCode', semanticVersion: '1.0.0' } }; | ||
const output = { driver: { name: 'SnykCode', semanticVersion: '1.0.0', version: '1.0.0' } }; | ||
const rules = []; | ||
@@ -86,3 +87,4 @@ let ruleIndex = 0; | ||
for (const [, suggestion] of Object.entries(suggestions)) { | ||
const result = { | ||
let helpers = []; | ||
let result = { | ||
ruleId: suggestion.id, | ||
@@ -93,2 +95,4 @@ ruleIndex: suggestion.ruleIndex, | ||
text: suggestion.text, | ||
markdown: suggestion.text, | ||
arguments: [''], | ||
}, | ||
@@ -113,11 +117,19 @@ locations: [ | ||
const codeThreadFlows = []; | ||
// let i = 0; | ||
let i = 0; | ||
if (suggestion.markers && suggestion.markers.length >= 1) { | ||
for (const marker of suggestion.markers) { | ||
for (const position of marker.pos) { | ||
const helperIndex = helpers.findIndex(helper => helper.msg === marker.msg); | ||
if (helperIndex != -1) { | ||
helpers[helperIndex].index.push(i); | ||
} | ||
else { | ||
helpers.push({ index: [i], msg: marker.msg }); | ||
} | ||
codeThreadFlows.push({ | ||
location: { | ||
id: i, | ||
physicalLocation: { | ||
artifactLocation: { | ||
uri: position.file, | ||
uri: position.file.substring(1), | ||
uriBaseId: '%SRCROOT%', | ||
@@ -134,3 +146,3 @@ }, | ||
}); | ||
// i += 1; | ||
i += 1; | ||
} | ||
@@ -142,2 +154,3 @@ } | ||
location: { | ||
id: 0, | ||
physicalLocation: { | ||
@@ -158,2 +171,5 @@ artifactLocation: { | ||
} | ||
const { message, argumentArray } = getArgumentsAndMessage(helpers, result.message.text); | ||
result.message.text = message; | ||
result.message.arguments = argumentArray; | ||
const newResult = { | ||
@@ -175,2 +191,28 @@ ...result, | ||
}; | ||
//custom string splice implementation | ||
function stringSplice(str, index, count, add) { | ||
// We cannot pass negative indexes directly to the 2nd slicing operation. | ||
if (index < 0) { | ||
index = str.length + index; | ||
if (index < 0) { | ||
index = 0; | ||
} | ||
} | ||
return str.slice(0, index) + (add || '') + str.slice(index + count); | ||
} | ||
exports.stringSplice = stringSplice; | ||
function getArgumentsAndMessage(helpers, message) { | ||
let negativeOffset = 0; | ||
let argumentArray = []; | ||
let sortedArguements = helpers.sort((a, b) => a.msg[0] - b.msg[0]); | ||
sortedArguements.forEach((arg, index) => { | ||
let word = message.substring(arg.msg[0] + negativeOffset, arg.msg[1] + 1 + negativeOffset); | ||
argumentArray.push(`[${word}]${arg.index.map((i) => `(${i})`)}`); | ||
message = stringSplice(message, arg.msg[0] + negativeOffset, arg.msg[1] + 1 + negativeOffset - (arg.msg[0] + negativeOffset), `{${index}}`); | ||
// (2 + index.toString().length) === number of inserted charecters, the 2 = {} | ||
negativeOffset += arg.msg[0] - (arg.msg[1] + 1) + (2 + index.toString().length); | ||
}); | ||
return { message, argumentArray }; | ||
} | ||
exports.getArgumentsAndMessage = getArgumentsAndMessage; | ||
//# sourceMappingURL=sarif_converter.js.map |
{ | ||
"name": "@deepcode/tsc", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Typescript consumer of Deepcode public API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
129983
1839
0
40