diff --git a/src/analysis.ts b/src/analysis.ts index 7696e506..9571aa12 100644 --- a/src/analysis.ts +++ b/src/analysis.ts @@ -98,6 +98,7 @@ export async function analyzeFolders(options: FileAnalysisOptions): Promise { // deepcode ignore PrototypePollution: FP this is an internal code d[f.bundlePath] = f.hash; @@ -91,7 +91,15 @@ interface UpdateRemoteBundleOptions extends ConnectionOptions { export async function uploadRemoteBundle(options: UpdateRemoteBundleOptions): Promise { let uploadedFiles = 0; emitter.uploadBundleProgress(0, options.files.length); - const apiParams = pick(options, ['baseURL', 'sessionToken', 'source', 'bundleHash', 'requestId', 'base64Encoding']); + const apiParams = pick(options, [ + 'baseURL', + 'sessionToken', + 'source', + 'bundleHash', + 'requestId', + 'base64Encoding', + 'org', + ]); const uploadFileChunks = async (bucketFiles: FileInfo[]): Promise => { // Note: we specifically create __new__ isolated bundles here to faster files upload @@ -129,7 +137,7 @@ async function fullfillRemoteBundle(options: FullfillRemoteBundleOptions): Promi // Check remove bundle to make sure no missing files left let attempts = 0; let { remoteBundle } = options; - const connectionOptions = pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'base64Encoding']); + const connectionOptions = pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'base64Encoding', 'org']); while (remoteBundle.missingFiles.length && attempts < (options.maxAttempts || MAX_UPLOAD_ATTEMPTS)) { const missingFiles = await resolveBundleFiles(options.baseDir, remoteBundle.missingFiles); @@ -156,7 +164,15 @@ interface RemoteBundleFactoryOptions extends PrepareRemoteBundleOptions { export async function remoteBundleFactory(options: RemoteBundleFactoryOptions): Promise { let remoteBundle: RemoteBundle | null = null; - const baseOptions = pick(options, ['baseURL', 'sessionToken', 'source', 'baseDir', 'requestId', 'base64Encoding']); + const baseOptions = pick(options, [ + 'baseURL', + 'sessionToken', + 'source', + 'baseDir', + 'requestId', + 'base64Encoding', + 'org', + ]); const bundleFactory = prepareRemoteBundle(omit(options, ['baseDir'])); for await (const response of bundleFactory) { if (response.type === 'error') { @@ -253,6 +269,7 @@ export async function createBundleFromFolders(options: CreateBundleFromFoldersOp ...pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'base64Encoding']), baseDir, files: bundleFiles, + ...(options.analysisContext?.org?.name ? { org: options.analysisContext.org.name } : {}), }; // Create remote bundle diff --git a/src/http.ts b/src/http.ts index 51cd4203..5be86ba2 100644 --- a/src/http.ts +++ b/src/http.ts @@ -29,6 +29,7 @@ export interface ConnectionOptions { source: string; requestId?: string; base64Encoding: boolean; + org?: string; } // The trick to typecast union type alias @@ -246,6 +247,7 @@ export async function createBundle( source: options.source, ...(options.requestId && { 'snyk-request-id': options.requestId }), ...(base64Encoding ? { 'content-type': 'application/octet-stream', 'content-encoding': 'gzip' } : null), + ...(options.org && { 'snyk-org-name': options.org }), }, url: `${options.baseURL}/bundle`, method: 'post', @@ -283,6 +285,7 @@ export async function checkBundle(options: CheckBundleOptions): Promise