@soos-io/api-client
Advanced tools
Comparing version 0.2.0-pre.2 to 0.2.0-pre.3
@@ -13,2 +13,8 @@ export declare enum ContributingDevelopersVariableNames { | ||
} | ||
export declare enum ContributingDeveloperSource { | ||
Unknown = "Unknown", | ||
GithubWebhook = "GithubWebhook", | ||
EnvironmentVariable = "EnvironmentVariable", | ||
OperatingSystem = "OperatingSystem" | ||
} | ||
export declare enum IntegrationName { | ||
@@ -15,0 +21,0 @@ AWSCodeBuild = "AWSCodeBuild", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OnFailure = exports.OutputFormat = exports.LogLevel = exports.ScanType = exports.ScanStatus = exports.ManifestStatus = exports.PackageManagerType = exports.IntegrationName = exports.ContributingDevelopersVariableNames = void 0; | ||
exports.OnFailure = exports.OutputFormat = exports.LogLevel = exports.ScanType = exports.ScanStatus = exports.ManifestStatus = exports.PackageManagerType = exports.IntegrationName = exports.ContributingDeveloperSource = exports.ContributingDevelopersVariableNames = void 0; | ||
var ContributingDevelopersVariableNames; | ||
@@ -17,2 +17,9 @@ (function (ContributingDevelopersVariableNames) { | ||
})(ContributingDevelopersVariableNames || (exports.ContributingDevelopersVariableNames = ContributingDevelopersVariableNames = {})); | ||
var ContributingDeveloperSource; | ||
(function (ContributingDeveloperSource) { | ||
ContributingDeveloperSource["Unknown"] = "Unknown"; | ||
ContributingDeveloperSource["GithubWebhook"] = "GithubWebhook"; | ||
ContributingDeveloperSource["EnvironmentVariable"] = "EnvironmentVariable"; | ||
ContributingDeveloperSource["OperatingSystem"] = "OperatingSystem"; | ||
})(ContributingDeveloperSource || (exports.ContributingDeveloperSource = ContributingDeveloperSource = {})); | ||
var IntegrationName; | ||
@@ -19,0 +26,0 @@ (function (IntegrationName) { |
@@ -45,15 +45,7 @@ import SOOSAnalysisApiClient, { ICreateScanRequestContributingDeveloperAudit, ICreateScanResponse } from "../api/SOOSAnalysisApiClient"; | ||
static create(apiKey: string, apiURL: string): AnalysisService; | ||
setupScan({ args }: { | ||
args: ISetupScanParams; | ||
}): Promise<ICreateScanResponse>; | ||
startScan({ args }: { | ||
args: IStartScanParams; | ||
}): Promise<void>; | ||
waitForScanToFinish({ args }: { | ||
args: IWaitForScanToFinishParams; | ||
}): Promise<ScanStatus>; | ||
runOutputFormat({ args }: { | ||
args: IRunOutputFormatParams; | ||
}): Promise<void>; | ||
setupScan({ clientId, projectName, branchName, commitHash, buildVersion, buildUri, branchUri, integrationType, operatingEnvironment, integrationName, appVersion, scriptVersion, contributingDeveloperAudit, scanType, }: ISetupScanParams): Promise<ICreateScanResponse>; | ||
startScan({ clientId, projectHash, analysisId, scanType, scanUrl, }: IStartScanParams): Promise<void>; | ||
waitForScanToFinish({ scanStatusUrl, scanUrl, }: IWaitForScanToFinishParams): Promise<ScanStatus>; | ||
runOutputFormat({ clientId, projectHash, projectName, branchHash, scanType, analysisId, outputFormat, sourceCodePath, workingDirectory, }: IRunOutputFormatParams): Promise<void>; | ||
} | ||
export default AnalysisService; |
@@ -20,14 +20,14 @@ "use strict"; | ||
} | ||
setupScan({ args }) { | ||
setupScan({ clientId, projectName, branchName, commitHash, buildVersion, buildUri, branchUri, integrationType, operatingEnvironment, integrationName, appVersion, scriptVersion, contributingDeveloperAudit, scanType, }) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
logging_1.soosLogger.info(`Starting SOOS ${args.scanType} Analysis`); | ||
logging_1.soosLogger.info(`Creating scan for project '${args.projectName}'...`); | ||
logging_1.soosLogger.info(`Branch Name: ${args.branchName}`); | ||
if (args.integrationName) { | ||
logging_1.soosLogger.info(`Integration Name: ${args.integrationName}`); | ||
const envVariableName = enums_1.ContributingDevelopersVariableNames[args.integrationName]; | ||
logging_1.soosLogger.info(`Starting SOOS ${scanType} Analysis`); | ||
logging_1.soosLogger.info(`Creating scan for project '${projectName}'...`); | ||
logging_1.soosLogger.info(`Branch Name: ${branchName}`); | ||
if (integrationName && contributingDeveloperAudit.length === 0) { | ||
logging_1.soosLogger.info(`Integration Name: ${integrationName}`); | ||
const envVariableName = enums_1.ContributingDevelopersVariableNames[integrationName]; | ||
const contributingDeveloper = process.env[envVariableName]; | ||
if (contributingDeveloper) { | ||
args.contributingDeveloperAudit.push({ | ||
source: "EnvironmentVariable", | ||
contributingDeveloperAudit.push({ | ||
source: enums_1.ContributingDeveloperSource.EnvironmentVariable, | ||
sourceName: envVariableName, | ||
@@ -39,16 +39,16 @@ contributingDeveloperId: contributingDeveloper, | ||
const result = yield this.analysisApiClient.createScan({ | ||
clientId: args.clientId, | ||
projectName: args.projectName, | ||
commitHash: args.commitHash, | ||
branch: args.branchName, | ||
buildVersion: args.buildVersion, | ||
buildUri: args.buildUri, | ||
branchUri: args.branchUri, | ||
integrationType: args.integrationType, | ||
operatingEnvironment: args.operatingEnvironment, | ||
integrationName: args.integrationName, | ||
appVersion: args.appVersion, | ||
scriptVersion: args.scriptVersion, | ||
contributingDeveloperAudit: args.contributingDeveloperAudit, | ||
scanType: args.scanType, | ||
clientId: clientId, | ||
projectName: projectName, | ||
commitHash: commitHash, | ||
branch: branchName, | ||
buildVersion: buildVersion, | ||
buildUri: buildUri, | ||
branchUri: branchUri, | ||
integrationType: integrationType, | ||
operatingEnvironment: operatingEnvironment, | ||
integrationName: integrationName, | ||
appVersion: appVersion, | ||
scriptVersion: scriptVersion, | ||
contributingDeveloperAudit: contributingDeveloperAudit, | ||
scanType: scanType, | ||
toolName: null, | ||
@@ -64,17 +64,17 @@ toolVersion: null, | ||
} | ||
startScan({ args }) { | ||
startScan({ clientId, projectHash, analysisId, scanType, scanUrl, }) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
logging_1.soosLogger.info(`Starting ${args.scanType} Analysis scan`); | ||
logging_1.soosLogger.info(`Starting ${scanType} Analysis scan`); | ||
yield this.analysisApiClient.startScan({ | ||
clientId: args.clientId, | ||
projectHash: args.projectHash, | ||
analysisId: args.analysisId, | ||
clientId: clientId, | ||
projectHash: projectHash, | ||
analysisId: analysisId, | ||
}); | ||
logging_1.soosLogger.info(`Analysis scan started successfully, to see the results visit: ${args.scanUrl}`); | ||
logging_1.soosLogger.info(`Analysis scan started successfully, to see the results visit: ${scanUrl}`); | ||
}); | ||
} | ||
waitForScanToFinish({ args }) { | ||
waitForScanToFinish({ scanStatusUrl, scanUrl, }) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const scanStatus = yield this.analysisApiClient.getScanStatus({ | ||
scanStatusUrl: args.scanStatusUrl, | ||
scanStatusUrl: scanStatusUrl, | ||
}); | ||
@@ -84,3 +84,3 @@ if (!scanStatus.isComplete) { | ||
yield (0, utilities_1.sleep)(constants_1.SOOS_CONSTANTS.Status.DelayTime); | ||
return yield this.waitForScanToFinish({ args }); | ||
return yield this.waitForScanToFinish({ scanStatusUrl, scanUrl }); | ||
} | ||
@@ -101,3 +101,3 @@ if (scanStatus.errors.length > 0) { | ||
} | ||
const resultMessage = `${statusMessage}. View the results at: ${args.scanUrl}`; | ||
const resultMessage = `${statusMessage}. View the results at: ${scanUrl}`; | ||
logging_1.soosLogger.info(resultMessage); | ||
@@ -107,20 +107,20 @@ return scanStatus.status; | ||
} | ||
runOutputFormat({ args }) { | ||
runOutputFormat({ clientId, projectHash, projectName, branchHash, scanType, analysisId, outputFormat, sourceCodePath, workingDirectory, }) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
logging_1.soosLogger.info(`Generating ${args.outputFormat} report ${args.projectName}...`); | ||
logging_1.soosLogger.info(`Generating ${outputFormat} report ${projectName}...`); | ||
const output = yield this.analysisApiClient.getFormattedScanResult({ | ||
clientId: args.clientId, | ||
projectHash: args.projectHash, | ||
branchHash: args.branchHash, | ||
scanType: args.scanType, | ||
scanId: args.analysisId, | ||
outputFormat: args.outputFormat, | ||
clientId: clientId, | ||
projectHash: projectHash, | ||
branchHash: branchHash, | ||
scanType: scanType, | ||
scanId: analysisId, | ||
outputFormat: outputFormat, | ||
}); | ||
if (output) { | ||
logging_1.soosLogger.info(`${args.outputFormat} report generated successfully.`); | ||
logging_1.soosLogger.info(`Output ('${args.outputFormat}' format):`); | ||
logging_1.soosLogger.info(`${outputFormat} report generated successfully.`); | ||
logging_1.soosLogger.info(`Output ('${outputFormat}' format):`); | ||
logging_1.soosLogger.info(JSON.stringify(output, null, 2)); | ||
if (args.sourceCodePath) { | ||
logging_1.soosLogger.info(`Writing ${args.outputFormat} report to ${Path.join(args.sourceCodePath, constants_1.SOOS_CONSTANTS.Files.SarifOutput)}`); | ||
FileSystem.writeFile(`${args.workingDirectory}/${constants_1.SOOS_CONSTANTS.Files.SarifOutput}`, JSON.stringify(output, null, 2), (error) => { | ||
if (sourceCodePath) { | ||
logging_1.soosLogger.info(`Writing ${outputFormat} report to ${Path.join(sourceCodePath, constants_1.SOOS_CONSTANTS.Files.SarifOutput)}`); | ||
FileSystem.writeFile(`${workingDirectory}/${constants_1.SOOS_CONSTANTS.Files.SarifOutput}`, JSON.stringify(output, null, 2), (error) => { | ||
if (error) { | ||
@@ -127,0 +127,0 @@ logging_1.soosLogger.error(error); |
{ | ||
"name": "@soos-io/api-client", | ||
"version": "0.2.0-pre.2", | ||
"version": "0.2.0-pre.3", | ||
"description": "This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
57631
1229