UNPKG

@soos-io/api-client

Version:

This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform. Register for a free trial today at https://app.soos.io/register

172 lines (171 loc) 6.23 kB
import FormData from "form-data"; import { HashAlgorithmEnum, HashEncodingEnum, IntegrationName, IntegrationType, ManifestStatus, PackageManagerType, ScanStatus, ScanType } from "../enums"; import { ICodedMessageModel } from "../models"; interface ICreateScanRequestContributingDeveloperAudit { source: string | null; sourceName: string | null; contributingDeveloperId: string | null; } interface ICreateScanRequest { clientId: string; projectName: string; commitHash: string | null; branch: string | null; scanType: ScanType; buildVersion: string | null; buildUri: string | null; branchUri: string | null; integrationType: IntegrationType; operatingEnvironment: string; integrationName: IntegrationName; scriptVersion: string | null; appVersion: string | null; contributingDeveloperAudit?: ICreateScanRequestContributingDeveloperAudit[]; toolName?: string | null; toolVersion?: string | null; commandLine?: string | null; scanMode?: string | null; } interface ICreateScanResponse { clientHash: string; projectHash: string; branchHash: string; analysisId: string; scanType: string; scanUrl: string; scanStatusUrl: string; scanSarifUrl: string; errors: ICodedMessageModel[] | null; } interface IGetSupportedScanFileFormatsRequest { clientId: string; } interface IGetSupportedScanFileFormatsResponsePackageManagerManifestAndHashableFiles { packageManager: PackageManagerType; manifests: Array<{ pattern: string; isLockFile: boolean; includeWithLockFiles: boolean; SupportsLockFiles: boolean; }>; hashableFiles: Array<{ hashAlgorithms: Array<{ hashAlgorithm: HashAlgorithmEnum; bufferEncoding: HashEncodingEnum; digestEncoding: HashEncodingEnum; }>; archiveFileExtensions: Array<string> | null; archiveContentFileExtensions: Array<string> | null; }> | null; } type IGetSupportedScanFileFormatsResponse = Array<IGetSupportedScanFileFormatsResponsePackageManagerManifestAndHashableFiles>; interface IScanStatusRequest { scanStatusUrl: string; } interface IScanStatusResponse extends Pick<IScanStatusApiResponse, "status"> { isComplete: boolean; isSuccess: boolean; issues: IIssuesModel | null; errors: ICodedMessageModel[]; } interface IScanStatusApiResponse { status: ScanStatus; issues: IIssuesModel | null; clientHash: string; projectHash: string; branchHash: string; scanId: string; analysisId: string; scanType: string; scanUrl: string; scanStatusUrl: string; errors: ICodedMessageModel[] | null; } interface IIssuesModel { Violation: { count: number; maxSeverity: string; } | null; Vulnerability: { count: number; maxSeverity: string; } | null; DependencyTypo: { count: number; maxSeverity: string; } | null; DependencySubstitution: { count: number; maxSeverity: string; } | null; Dast: { count: number; maxSeverity: string; } | null; Sast: { count: number; maxSeverity: string; } | null; UnknownPackage: { count: number; maxSeverity: string; } | null; } interface IStartScanRequest { clientId: string; projectHash: string; analysisId: string; } interface IUpdateScanStatusRequest { clientId: string; projectHash: string; branchHash: string; scanType: ScanType; scanId: string; status: ScanStatus; message: string; } interface IUploadManifestFilesRequest { clientId: string; projectHash: string; branchHash: string; analysisId: string; manifestFiles: FormData; hasMoreThanMaximumManifests: boolean; } interface IUploadManifestFilesResponseManifestStatus { name: string; filename: string; packageManager: PackageManagerType; status: ManifestStatus; statusMessage: string; } interface IUploadManifestFilesResponse { message: string; manifests?: Array<IUploadManifestFilesResponseManifestStatus> | undefined; } interface IUploadScanToolResultRequest { clientId: string; projectHash: string; branchHash: string; scanType: ScanType; scanId: string; resultFile: FormData; hasMoreThanMaximumFiles: boolean; } declare class SOOSAnalysisApiClient { private readonly baseUri; private readonly apiKey; private readonly client; private createApiClient; constructor(apiKey: string, baseUri?: string); createScan({ clientId, projectName, commitHash, branch, buildVersion, buildUri, branchUri, integrationType, operatingEnvironment, integrationName, scanType, appVersion, scriptVersion, contributingDeveloperAudit, toolName, toolVersion, commandLine, scanMode, }: ICreateScanRequest): Promise<ICreateScanResponse>; getSupportedScanFileFormats({ clientId, }: IGetSupportedScanFileFormatsRequest): Promise<IGetSupportedScanFileFormatsResponse>; uploadManifestFiles({ clientId, projectHash, analysisId, manifestFiles, hasMoreThanMaximumManifests, }: IUploadManifestFilesRequest): Promise<IUploadManifestFilesResponse>; startScan({ clientId, projectHash, analysisId }: IStartScanRequest): Promise<void>; updateScanStatus({ clientId, projectHash, branchHash, scanType, scanId, status, message, }: IUpdateScanStatusRequest): Promise<void>; getScanStatus({ scanStatusUrl }: IScanStatusRequest): Promise<IScanStatusResponse>; uploadScanToolResult({ clientId, projectHash, branchHash, scanType, scanId, resultFile, hasMoreThanMaximumFiles, }: IUploadScanToolResultRequest): Promise<void>; } export { ICreateScanRequestContributingDeveloperAudit, ICreateScanRequest, ICreateScanResponse, IGetSupportedScanFileFormatsRequest, IGetSupportedScanFileFormatsResponsePackageManagerManifestAndHashableFiles, IGetSupportedScanFileFormatsResponse, IScanStatusRequest, IScanStatusResponse, IStartScanRequest, IUpdateScanStatusRequest, IUploadManifestFilesRequest, IUploadManifestFilesResponseManifestStatus, IUploadManifestFilesResponse, IUploadScanToolResultRequest, IIssuesModel, }; export default SOOSAnalysisApiClient;