Skip to content

Commit

Permalink
fix: pass org as part of container monitor command
Browse files Browse the repository at this point in the history
The org was missing when doing the migration to container static analysis, resulting in the --org flag being ignored.
  • Loading branch information
ivanstanev committed Oct 16, 2020
1 parent 488e884 commit fd827fd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/ecosystems/monitor.ts
Expand Up @@ -80,6 +80,8 @@ async function monitorDependencies(
options,
);

const configOrg = config.org ? decodeURIComponent(config.org) : undefined;

const payload = {
method: 'PUT',
url: `${config.API}/monitor-dependencies`,
Expand All @@ -89,6 +91,9 @@ async function monitorDependencies(
authorization: 'token ' + snyk.api,
},
body: monitorDependenciesRequest,
qs: {
org: options.org || configOrg,
},
};
try {
const response = await makeRequest<MonitorDependenciesResponse>(
Expand Down
32 changes: 32 additions & 0 deletions test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts
Expand Up @@ -1825,6 +1825,38 @@ if (!isWindows) {
);
});

test('`monitor foo:latest --docker --org=fake-org`', async (t) => {
stubDockerPluginResponse(
{
scanResults: [
{
identity: {
type: 'rpm',
},
target: {
image: 'docker-image|foo',
},
facts: [{ type: 'depGraph', data: {} }],
},
],
},
t,
);

await cli.monitor('foo:latest', {
docker: true,
org: 'fake-org',
});
const req = server.popRequest();
t.deepEqual(
req.query,
{
org: 'fake-org',
},
'sends correct payload',
);
});

test('monitor --json multiple folders', async (t) => {
chdirWorkspaces('fail-on');

Expand Down

0 comments on commit fd827fd

Please sign in to comment.