Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deepcode/tsc

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deepcode/tsc - npm Package Compare versions

Comparing version 2.0.15 to 2.0.16

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## [2.0.16] - 2020-12-17
- Performance improvement and stability on events 'file changed'
## [2.0.15] - 2020-12-08

@@ -2,0 +5,0 @@ - Add Username param to analyzeGit

3

dist/analysis.d.ts
import { AnalysisSeverity, IGitBundle, IFileBundle, IBundleResult } from './interfaces/analysis-result.interface';
export declare function analyzeBundle({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, }: {
export declare function analyzeBundle({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, limitToFiles, }: {
baseURL: string;

@@ -10,2 +10,3 @@ sessionToken: string;

username?: string;
limitToFiles?: string[];
}): Promise<IBundleResult>;

@@ -12,0 +13,0 @@ export declare function analyzeFolders(baseURL: string | undefined, sessionToken: string | undefined, includeLint: boolean | undefined, severity: AnalysisSeverity | undefined, paths: string[], symlinksEnabled?: boolean, maxPayload?: number, defaultFileIgnores?: string[]): Promise<IFileBundle>;

"use strict";
/* eslint-disable no-await-in-loop */
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -8,2 +7,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.analyzeGit = exports.extendAnalysis = exports.analyzeFolders = exports.analyzeBundle = void 0;
/* eslint-disable no-await-in-loop */
const lodash_1 = require("lodash");
const files_1 = require("./files");

@@ -17,3 +18,3 @@ const http_1 = require("./http");

const sleep = (duration) => new Promise(resolve => setTimeout(resolve, duration));
async function pollAnalysis({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, }) {
async function pollAnalysis({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, limitToFiles, }) {
let analysisResponse;

@@ -36,2 +37,3 @@ let analysisData;

severity,
limitToFiles,
});

@@ -61,5 +63,14 @@ if (analysisResponse.type === 'error') {

}
async function analyzeBundle({ baseURL = constants_1.defaultBaseURL, sessionToken = '', includeLint = false, severity = analysis_result_interface_1.AnalysisSeverity.info, bundleId, oAuthToken, username, }) {
async function analyzeBundle({ baseURL = constants_1.defaultBaseURL, sessionToken = '', includeLint = false, severity = analysis_result_interface_1.AnalysisSeverity.info, bundleId, oAuthToken, username, limitToFiles, }) {
// Call remote bundle for analysis results and emit intermediate progress
const analysisData = await pollAnalysis({ baseURL, sessionToken, oAuthToken, username, bundleId, includeLint, severity });
const analysisData = await pollAnalysis({
baseURL,
sessionToken,
oAuthToken,
username,
bundleId,
includeLint,
severity,
limitToFiles,
});
if (analysisData.type === 'error') {

@@ -89,2 +100,32 @@ throw analysisData.error;

}
const moveSuggestionIndexes = (suggestionIndex, suggestions) => {
const entries = Object.entries(suggestions);
return Object.fromEntries(entries.map(([i, s]) => {
return [`${parseInt(i, 10) + suggestionIndex + 1}`, s];
}));
};
function mergeBundleResults(bundle, analysisData, limitToFiles) {
// Determine max suggestion index in our data
const suggestionIndex = Math.max(...Object.keys(bundle.analysisResults.suggestions).map(i => parseInt(i, 10))) || -1;
// Addup all new suggestions' indexes
const newSuggestions = moveSuggestionIndexes(suggestionIndex, analysisData.analysisResults.suggestions);
const suggestions = { ...bundle.analysisResults.suggestions, ...newSuggestions };
const newFiles = Object.fromEntries(Object.entries(analysisData.analysisResults.files).map(([fn, s]) => {
return [fn, moveSuggestionIndexes(suggestionIndex, s)];
}));
const files = {
...lodash_1.omit(bundle.analysisResults.files, limitToFiles),
...newFiles,
};
const analysisResults = {
...analysisData.analysisResults,
files,
suggestions,
};
return {
...bundle,
...analysisData,
analysisResults,
};
}
async function analyzeFolders(baseURL = constants_1.defaultBaseURL, sessionToken = '', includeLint = false, severity = analysis_result_interface_1.AnalysisSeverity.info, paths, symlinksEnabled = false, maxPayload = constants_1.MAX_PAYLOAD, defaultFileIgnores = constants_1.IGNORES_DEFAULT) {

@@ -158,9 +199,8 @@ // Get supported filters and test baseURL for correctness and availability

bundleId: remoteBundle.bundleId,
limitToFiles: files.map(f => f.bundlePath),
});
// Transform relative paths into absolute
analysisData.analysisResults.files = normalizeResultFiles(analysisData.analysisResults.files, bundle.baseDir);
// Create bundle instance to handle extensions
return {
...bundle,
...analysisData,
};
// Merge into base bundle results
return mergeBundleResults(bundle, analysisData, files.map(f => f.filePath));
}

@@ -174,3 +214,11 @@ exports.extendAnalysis = extendAnalysis;

const { bundleId } = bundleResponse.value;
const analysisData = await analyzeBundle({ baseURL, sessionToken, oAuthToken, username, includeLint, severity, bundleId });
const analysisData = await analyzeBundle({
baseURL,
sessionToken,
oAuthToken,
username,
includeLint,
severity,
bundleId,
});
const result = {

@@ -177,0 +225,0 @@ baseURL,

@@ -225,6 +225,3 @@ "use strict";

const calcHash = (content) => {
return crypto_1.default
.createHash(constants_1.HASH_ALGORITHM)
.update(content)
.digest(constants_1.ENCODE_TYPE);
return crypto_1.default.createHash(constants_1.HASH_ALGORITHM).update(content).digest(constants_1.ENCODE_TYPE);
};

@@ -231,0 +228,0 @@ let fileContent = '';

@@ -98,7 +98,8 @@ import { AxiosError } from 'axios';

readonly sessionToken: string;
readonly oAuthToken?: string;
readonly username?: string;
readonly bundleId: string;
readonly includeLint?: boolean;
readonly severity: number;
readonly limitToFiles?: string[];
readonly oAuthToken?: string;
readonly username?: string;
}): Promise<IResult<GetAnalysisResponseDto, GetAnalysisErrorCodes>>;

@@ -105,0 +106,0 @@ declare type ReportTelemetryRequestDto = {

@@ -273,3 +273,3 @@ "use strict";

async function getAnalysis(options) {
const { baseURL, sessionToken, oAuthToken, username, bundleId, includeLint, severity } = options;
const { baseURL, sessionToken, oAuthToken, username, bundleId, includeLint, severity, limitToFiles } = options;
// ?linters=false is still a truthy query value, if(includeLint === false) we have to avoid sending the value altogether

@@ -290,2 +290,6 @@ const params = { severity, linters: includeLint || undefined };

};
if (limitToFiles && limitToFiles.length) {
config.data = { files: limitToFiles };
config.method = 'POST';
}
try {

@@ -292,0 +296,0 @@ const response = await axios_1.default.request(config);

@@ -34,3 +34,3 @@ import { Log } from 'sarif';

export interface ISuggestions {
[suggestionIndex: number]: ISuggestion;
[suggestionIndex: string]: ISuggestion;
}

@@ -49,3 +49,3 @@ export interface IPosition {

export interface IFilePath {
[suggestionIndex: number]: IFileSuggestion[];
[suggestionIndex: string]: IFileSuggestion[];
}

@@ -52,0 +52,0 @@ export interface IAnalysisFiles {

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

import { Log } from 'sarif';
import { IAnalysisResult } from './interfaces/analysis-result.interface';
import { Log } from 'sarif';
export default function getSarif(analysisResults: IAnalysisResult): Log;

@@ -13,2 +13,5 @@ "use strict";

results,
properties: {
coverage: analysisResults.coverage,
},
},

@@ -22,5 +25,5 @@ ],

for (const [file] of Object.entries(analysisResults.files)) {
for (const [issueId, issue] of Object.entries(analysisResults.files[file])) {
for (const [issueId, issues] of Object.entries(analysisResults.files[file])) {
if (!suggestions || !Object.keys(suggestions).includes(issueId)) {
suggestions[issueId] = { ...issue[0], file: file.substring(1) };
suggestions[issueId] = { ...issues[0], file: file.substring(1) };
}

@@ -36,3 +39,4 @@ }

let ruleIndex = 0;
for (const [suggestionName, suggestion] of Object.entries(analysisResults.suggestions)) {
const result = {};
for (const [suggestionIndex, suggestion] of Object.entries(analysisResults.suggestions)) {
const severity = {

@@ -43,3 +47,5 @@ 1: 'note',

}[suggestion.severity];
const suggestionId = suggestion.id;
// payload comes as URIencoded
const language = suggestion.id.split('%2F')[0];
const suggestionId = `${language}/${suggestion.rule}`;
const rule = {

@@ -59,3 +65,3 @@ id: suggestionId,

properties: {
tags: [suggestionId.split('%2F')[0], ...suggestion.tags, ...suggestion.categories],
tags: [language, ...suggestion.tags, ...suggestion.categories],
precision: 'very-high',

@@ -68,4 +74,5 @@ },

rules.push(rule);
suggestions[suggestionName] = {
...suggestions[suggestionName],
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
result[suggestionIndex] = {
...suggestions[suggestionIndex],
ruleIndex,

@@ -79,3 +86,3 @@ rule,

}
return { tool: { driver: { ...output.driver, rules } }, suggestions };
return { tool: { driver: { ...output.driver, rules } }, suggestions: result };
};

@@ -82,0 +89,0 @@ const getResults = (suggestions) => {

{
"name": "@deepcode/tsc",
"version": "2.0.15",
"version": "2.0.16",
"description": "Typescript consumer of Deepcode public API",

@@ -65,4 +65,4 @@ "main": "dist/index.js",

"micromatch": "^4.0.2",
"flat-cache": "^2.0.1"
"flat-cache": "^3.0.4"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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