Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable cocoapods to send graphs for cli monitor #5487

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/package-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const GRAPH_SUPPORTED_PACKAGE_MANAGERS: SupportedPackageManagers[] = [
'yarn',
'rubygems',
'poetry',
'cocoapods',
];
// For ecosystems with a flat set of libraries (e.g. Python, JVM), one can
// "pin" a transitive dependency
Expand Down
68 changes: 64 additions & 4 deletions test/tap/cli-monitor.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ if (!isWindows) {
async inspect() {
return {
plugin: { name: 'sbt' },
package: require(
getWorkspacePath('sbt-simple-struts/monitor-graph-result.json'),
),
package: require(getWorkspacePath(
'sbt-simple-struts/monitor-graph-result.json',
)),
};
},
};
Expand Down Expand Up @@ -1475,6 +1475,62 @@ if (!isWindows) {
);
});

test('`monitor cocoapods-app with just Podfile.lock`', async (t) => {
chdirWorkspaces('cocoapods-app');
const plugin = {
async inspect() {
return {
plugin: {
targetFile: 'Podfile.lock',
name: 'snyk-cocoapods-plugin',
runtime: 'cocoapods',
},
package: {},
};
},
};

const spyPlugin = sinon.spy(plugin, 'inspect');

const loadPlugin = sinon.stub(plugins, 'loadPlugin');
t.teardown(loadPlugin.restore);
loadPlugin.withArgs('cocoapods').returns(plugin);

await cli.monitor('./', {
file: 'Podfile.lock',
});
const req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.equal(
req.headers['x-snyk-cli-version'],
versionNumber,
'sends version number',
);
const depGraphJSON = req.body.depGraphJSON;
t.ok(depGraphJSON);
t.match(req.url, '/monitor/cocoapods/graph', 'puts at correct url');
t.equal(
req.body.targetFile,
'Podfile.lock',
'sends the targetFile (Podfile)',
);
t.same(
spyPlugin.getCall(0).args,
[
'./',
'Podfile.lock',
{
args: null,
file: 'Podfile.lock',
packageManager: 'cocoapods',
path: './',
},
snykHttpClient,
],
'calls CocoaPods plugin',
);
});

test('`monitor large-mono-repo --file=bundler-app/Gemfile` suggest to use --all-projects', async (t) => {
chdirWorkspaces('large-mono-repo');
const res = await cli.monitor({ file: 'bundler-app/Gemfile' });
Expand Down Expand Up @@ -1512,7 +1568,11 @@ if (!isWindows) {
'sends version number',
);
t.match(req.url, '/monitor/cocoapods', 'puts at correct url');
t.equal(req.body.targetFile, 'Podfile', 'sends the targetFile (Podfile)');
t.equal(
req.body.targetFile,
'Podfile.lock',
'sends the targetFile (Podfile.lock)',
);
t.same(
spyPlugin.getCall(0).args,
[
Expand Down
Loading