Skip to content

Commit

Permalink
Merge pull request #205 from snyk/fix/fedramp_urls
Browse files Browse the repository at this point in the history
fix: add orgId to code-client calls
  • Loading branch information
jozsef-armin-hamos committed Oct 5, 2023
2 parents f84f737 + 5369805 commit 0fc951e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
25 changes: 22 additions & 3 deletions src/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ async function* prepareRemoteBundle(
emitter.createBundleProgress(cumulativeProgress, options.files.length);
for (const chunkedFiles of composeFilePayloads(options.files)) {
const apiParams = {
...pick(options, ['baseURL', 'sessionToken', 'source', 'extraHeaders', 'removedFiles', 'requestId', 'org']),
...pick(options, [
'baseURL',
'sessionToken',
'source',
'extraHeaders',
'removedFiles',
'requestId',
'org',
'orgId',
]),
files: chunkedFiles.reduce((d, f) => {
// deepcode ignore PrototypePollution: FP this is an internal code
d[f.bundlePath] = f.hash;
Expand Down Expand Up @@ -98,6 +107,7 @@ export async function uploadRemoteBundle(options: UpdateRemoteBundleOptions): Pr
'bundleHash',
'requestId',
'org',
'orgId',
'extraHeaders',
]);

Expand Down Expand Up @@ -137,7 +147,15 @@ 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', 'org', 'extraHeaders']);
const connectionOptions = pick(options, [
'baseURL',
'sessionToken',
'source',
'requestId',
'org',
'orgId',
'extraHeaders',
]);

while (remoteBundle.missingFiles.length && attempts < (options.maxAttempts || MAX_UPLOAD_ATTEMPTS)) {
const missingFiles = await resolveBundleFiles(options.baseDir, remoteBundle.missingFiles);
Expand Down Expand Up @@ -171,6 +189,7 @@ export async function remoteBundleFactory(options: RemoteBundleFactoryOptions):
'baseDir',
'requestId',
'org',
'orgId',
'extraHeaders',
]);
const bundleFactory = prepareRemoteBundle(omit(options, ['baseDir']));
Expand Down Expand Up @@ -292,7 +311,7 @@ export async function createBundleWithCustomFiles(
}

const bundleOptions = {
...pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'org', 'extraHeaders']),
...pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'org', 'orgId', 'extraHeaders']),
baseDir,
files: bundleFiles,
};
Expand Down
6 changes: 4 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function parseConnectionOptions(options: {
token: string;
source: string;
org?: string;
orgId?: string;
headers?: string[];
}): ConnectionOptions {
let headers: { [key: string]: string } = {};
Expand All @@ -34,6 +35,7 @@ function parseConnectionOptions(options: {
sessionToken: options.token,
source: options.source,
...(options.org ? { org: options.org } : {}),
...(options.orgId ? { orgId: options.orgId } : {}),
extraHeaders: headers,
// requestId?: string; - not supported
};
Expand Down Expand Up @@ -79,7 +81,7 @@ async function createBundleAction(options: {

async function readBundleAction(
bundleHash: string,
options: { url: string; token: string; source: string; org?: string },
options: { url: string; token: string; source: string; org?: string; orgId?: string },
) {
const opts = {
...parseConnectionOptions(options),
Expand All @@ -95,7 +97,7 @@ async function readBundleAction(

async function analysisBundleAction(
bundleHash: string,
options: { url: string; token: string; source: string; org?: string },
options: { url: string; token: string; source: string; org?: string; orgId?: string },
) {
const opts = {
...parseConnectionOptions(options),
Expand Down
2 changes: 1 addition & 1 deletion src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function initAndPollReportGeneric(
while (true) {
// eslint-disable-next-line no-await-in-loop
apiResponse = await getReportFunc({
...pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'org']),
...pick(options, ['baseURL', 'sessionToken', 'source', 'requestId', 'org', 'orgId']),
pollId,
});

Expand Down

0 comments on commit 0fc951e

Please sign in to comment.