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

@snyk/code-client

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snyk/code-client - npm Package Compare versions

Comparing version 4.15.0 to 4.16.0

dist/report.d.ts

26

dist/analysis.js

@@ -14,2 +14,3 @@ "use strict";

const bundles_1 = require("./bundles");
const report_1 = require("./report");
const emitter_1 = require("./emitter");

@@ -70,2 +71,3 @@ const sleep = (duration) => new Promise(resolve => setTimeout(resolve, duration));

async function analyzeFolders(options) {
var _a, _b;
if (!options.connection.requestId) {

@@ -82,4 +84,3 @@ options.connection.requestId = (0, uuid_1.v4)();

return null;
// Analyze bundle
const analysisResults = await analyzeBundle({
const config = {
bundleHash: fileBundle.bundleHash,

@@ -90,3 +91,20 @@ ...options.connection,

...(options.analysisContext ? { analysisContext: options.analysisContext } : {}),
});
};
let analysisResults;
// Whether this is a report/result upload operation.
const isReport = (_b = (_a = options.reportOptions) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false;
let reportResults;
if (isReport && options.reportOptions) {
// Analyze and upload bundle results.
const reportRes = await (0, report_1.reportBundle)({
...config,
report: options.reportOptions,
});
analysisResults = reportRes.analysisResult;
reportResults = reportRes.uploadResult;
}
else {
// Analyze bundle.
analysisResults = await analyzeBundle(config);
}
if (analysisResults.type === 'legacy') {

@@ -96,3 +114,3 @@ // expand relative file names to absolute ones only for legacy results

}
return { fileBundle, analysisResults, ...options };
return { fileBundle, analysisResults, reportResults, ...options };
}

@@ -99,0 +117,0 @@ exports.analyzeFolders = analyzeFolders;

/// <reference types="node" />
import { ErrorCodes, GenericErrorTypes } from './constants';
import { BundleFiles, SupportedFiles } from './interfaces/files.interface';
import { AnalysisResult } from './interfaces/analysis-result.interface';
import { AnalysisOptions, AnalysisContext } from './interfaces/analysis-options.interface';
import { AnalysisResult, ReportResult } from './interfaces/analysis-result.interface';
import { AnalysisOptions, AnalysisContext, ReportOptions } from './interfaces/analysis-options.interface';
type ResultSuccess<T> = {

@@ -93,3 +93,15 @@ type: 'success';

export declare function getAnalysis(options: GetAnalysisOptions): Promise<Result<GetAnalysisResponseDto, GetAnalysisErrorCodes>>;
export interface UploadReportOptions extends GetAnalysisOptions {
report: ReportOptions;
}
export interface GetReportOptions extends ConnectionOptions {
reportId: string;
}
export type InitUploadResponseDto = {
reportId: string;
};
export type UploadReportResponseDto = ReportResult | AnalysisFailedResponse | AnalysisResponseProgress;
export declare function initReport(options: UploadReportOptions): Promise<Result<InitUploadResponseDto, GetAnalysisErrorCodes>>;
export declare function getReport(options: GetReportOptions): Promise<Result<UploadReportResponseDto, GetAnalysisErrorCodes>>;
export declare function getVerifyCallbackUrl(authHost: string): string;
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getVerifyCallbackUrl = exports.getAnalysis = exports.AnalysisStatus = exports.extendBundle = exports.checkBundle = exports.createBundle = exports.getFilters = exports.checkSession = exports.getIpFamily = exports.startSession = exports.compressAndEncode = void 0;
exports.getVerifyCallbackUrl = exports.getReport = exports.initReport = exports.getAnalysis = exports.AnalysisStatus = exports.extendBundle = exports.checkBundle = exports.createBundle = exports.getFilters = exports.checkSession = exports.getIpFamily = exports.startSession = exports.compressAndEncode = void 0;
const uuid_1 = require("uuid");

@@ -248,2 +248,51 @@ const lodash_pick_1 = __importDefault(require("lodash.pick"));

exports.getAnalysis = getAnalysis;
async function initReport(options) {
const config = {
headers: {
...prepareTokenHeaders(options.sessionToken),
source: options.source,
...(options.requestId && { 'snyk-request-id': options.requestId }),
...(options.org && { 'snyk-org-name': options.org }),
},
url: `${options.baseURL}/report`,
method: 'post',
body: {
workflowData: {
projectName: options.report.projectName,
},
key: {
type: 'file',
hash: options.bundleHash,
limitToFiles: options.limitToFiles || [],
...(options.shard ? { shard: options.shard } : null),
},
...(0, lodash_pick_1.default)(options, ['severity', 'prioritized', 'legacy', 'analysisContext']),
},
};
const res = await (0, needle_1.makeRequest)(config);
if (res.success)
return { type: 'success', value: res.body };
return generateError(res.errorCode, GET_ANALYSIS_ERROR_MESSAGES, 'initReport');
}
exports.initReport = initReport;
async function getReport(options) {
const config = {
headers: {
...prepareTokenHeaders(options.sessionToken),
source: options.source,
...(options.requestId && { 'snyk-request-id': options.requestId }),
...(options.org && { 'snyk-org-name': options.org }),
},
url: `${options.baseURL}/report/${options.reportId}`,
method: 'get',
body: {
reportId: options.reportId,
},
};
const res = await (0, needle_1.makeRequest)(config);
if (res.success)
return { type: 'success', value: res.body };
return generateError(res.errorCode, GET_ANALYSIS_ERROR_MESSAGES, 'getReport');
}
exports.getReport = getReport;
function getVerifyCallbackUrl(authHost) {

@@ -250,0 +299,0 @@ return `${authHost}/api/verify/callback`;

4

dist/index.d.ts

@@ -10,3 +10,3 @@ import { analyzeFolders, extendAnalysis } from './analysis';

import { AnalysisSeverity, AnalysisContext } from './interfaces/analysis-options.interface';
import { AnalysisResult, AnalysisResultLegacy, FilePath, FileSuggestion, Suggestion, Marker } from './interfaces/analysis-result.interface';
export { getGlobPatterns, analyzeFolders, createBundleFromFolders, extendAnalysis, emitter, MAX_FILE_SIZE, constants, AnalysisSeverity, AnalysisResult, AnalysisResultLegacy, SupportedFiles, FileAnalysis, FilePath, FileSuggestion, Suggestion, Marker, getAnalysis, startSession, checkSession, getIpFamily, IpFamily, AnalysisContext, };
import { AnalysisResult, AnalysisResultSarif, AnalysisResultLegacy, FilePath, FileSuggestion, Suggestion, Marker, ReportResult } from './interfaces/analysis-result.interface';
export { getGlobPatterns, analyzeFolders, createBundleFromFolders, extendAnalysis, emitter, MAX_FILE_SIZE, constants, AnalysisSeverity, AnalysisResult, AnalysisResultSarif, AnalysisResultLegacy, SupportedFiles, FileAnalysis, FilePath, FileSuggestion, Suggestion, Marker, getAnalysis, startSession, checkSession, getIpFamily, IpFamily, AnalysisContext, ReportResult, };

@@ -40,2 +40,3 @@ import { SupportedFiles } from '..';

fileOptions: AnalyzeFoldersOptions;
reportOptions?: ReportOptions;
languages?: string[];

@@ -54,1 +55,6 @@ }

}
export interface ReportOptions {
enabled: boolean;
projectName?: string;
targetRef?: string;
}

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

}
export interface ReportUploadResult {
projectId: string;
snapshotId: string;
reportUrl: string;
}
export interface ReportResult {
status: 'COMPLETE';
uploadResult: ReportUploadResult;
analysisResult: AnalysisResultSarif;
}
export type AnalysisResult = AnalysisResultSarif | AnalysisResultLegacy;
export {};
import { AnalysisResult } from '..';
import { FileBundle } from '../bundles';
import { FileAnalysisOptions } from './analysis-options.interface';
import { ReportUploadResult } from './analysis-result.interface';
export interface File {

@@ -25,2 +26,3 @@ hash: string;

analysisResults: AnalysisResult;
reportResults?: ReportUploadResult;
}

@@ -90,3 +90,3 @@ {

},
"version": "4.15.0"
"version": "4.16.0"
}

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