Skip to content

Commit

Permalink
Merge pull request snyk#395 from snyk/feat/support-gradle-kotlin-script
Browse files Browse the repository at this point in the history
Feat: add build.gradle.kts support
  • Loading branch information
Kirill89 committed Mar 18, 2019
2 parents d956d67 + c6fbfb1 commit f551106
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions help/file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ looking for files in following order:
pom.xml
requirements.txt
build.gradle
build.gradle.kts
build.sbt
Gopkg.lock
vendor/vendor.json
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"snyk-config": "2.2.1",
"snyk-docker-plugin": "1.22.0",
"snyk-go-plugin": "1.6.1",
"snyk-gradle-plugin": "2.1.4",
"snyk-gradle-plugin": "2.1.5",
"snyk-module": "1.9.1",
"snyk-mvn-plugin": "2.0.1",
"snyk-nodejs-lockfile-parser": "1.11.0",
Expand Down
2 changes: 2 additions & 0 deletions src/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DETECTABLE_FILES = [
'Gemfile.lock',
'pom.xml',
'build.gradle',
'build.gradle.kts',
'build.sbt',
'Pipfile',
'requirements.txt',
Expand All @@ -34,6 +35,7 @@ const DETECTABLE_PACKAGE_MANAGERS = {
'package-lock.json': 'npm',
'pom.xml': 'maven',
'build.gradle': 'gradle',
'build.gradle.kts': 'gradle',
'build.sbt': 'sbt',
'yarn.lock': 'yarn',
'package.json': 'npm',
Expand Down
26 changes: 26 additions & 0 deletions test/acceptance/cli.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,30 @@ test('`test ruby-app-no-vulns`', async (t) => {
t.deepEqual(res, expected, '--json output is the same');
});

test('`test gradle-kotlin-dsl-app` returns correct meta', async (t) => {
chdirWorkspaces();
const plugin = {
async inspect() {
return {package: {}};
},
};
const spyPlugin = sinon.spy(plugin, 'inspect');
const loadPlugin = sinon.stub(plugins, 'loadPlugin');
t.teardown(loadPlugin.restore);
loadPlugin.withArgs('gradle').returns(plugin);

const res = await cli.test('gradle-kotlin-dsl-app');
const meta = res.slice(res.indexOf('Organisation:')).split('\n');
t.match(meta[0], /Organisation:\s+test-org/, 'organisation displayed');
t.match(meta[1], /Package manager:\s+gradle/,
'package manager displayed');
t.match(meta[2], /Target file:\s+build.gradle.kts/, 'target file displayed');
t.match(meta[3], /Open source:\s+no/, 'open source displayed');
t.match(meta[4], /Project path:\s+gradle-kotlin-dsl-app/, 'path displayed');
t.notMatch(meta[5], /Local Snyk policy:\s+found/,
'local policy not displayed');
});

test('`test gradle-app` returns correct meta', async (t) => {
chdirWorkspaces();
const plugin = {
Expand Down Expand Up @@ -2425,6 +2449,7 @@ test('`wizard` for unsupported package managers', async (t) => {
{ file: 'pip-app/requirements.txt', type: 'Python' },
{ file: 'sbt-app/build.sbt', type: 'SBT' },
{ file: 'gradle-app/build.gradle', type: 'Gradle' },
{ file: 'gradle-kotlin-dsl-app/build.gradle.kts', type: 'Gradle' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang/Dep' },
{ file: 'golang-app/vendor/vendor.json', type: 'Govendor' },
{ file: 'composer-app/composer.lock', type: 'Composer' },
Expand Down Expand Up @@ -2453,6 +2478,7 @@ test('`protect` for unsupported package managers', async (t) => {
{ file: 'pip-app/requirements.txt', type: 'Python' },
{ file: 'sbt-app/build.sbt', type: 'SBT' },
{ file: 'gradle-app/build.gradle', type: 'Gradle' },
{ file: 'gradle-kotlin-dsl-app/build.gradle.kts', type: 'Gradle' },
{ file: 'golang-app/Gopkg.lock', type: 'Golang/Dep' },
{ file: 'golang-app/vendor/vendor.json', type: 'Govendor' },
{ file: 'composer-app/composer.lock', type: 'Composer' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// not a real Gradle build file

0 comments on commit f551106

Please sign in to comment.