diff --git a/lib/modules/java-find-secbugs/__tests__/findsecbugs-unit.js b/lib/modules/java-find-secbugs/__tests__/findsecbugs-unit.js index 9a01afb5..538057c4 100644 --- a/lib/modules/java-find-secbugs/__tests__/findsecbugs-unit.js +++ b/lib/modules/java-find-secbugs/__tests__/findsecbugs-unit.js @@ -44,6 +44,11 @@ describe('FindSecBugs Module', () => { expect(await handles(fm)).to.be.true }) + it('should handle scala sbt projects', async () => { + const fm = new FileManager({ target: path.join(__dirname, './sample/scala-sbt') }) + expect(await handles(fm)).to.be.true + }) + it('should not run on missing executable', async () => { exec.exists.withArgs('findsecbugs').resolves(false) const target = path.join(__dirname, './sample/java-gradle') diff --git a/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/build.sbt b/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/build.sbt new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/src/main/scala/Main.scala b/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/src/main/scala/Main.scala new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/target/scala-2.13/app.jar b/lib/modules/java-find-secbugs/__tests__/sample/scala-sbt/target/scala-2.13/app.jar new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-find-secbugs/index.js b/lib/modules/java-find-secbugs/index.js index ceb089cb..6e480acd 100644 --- a/lib/modules/java-find-secbugs/index.js +++ b/lib/modules/java-find-secbugs/index.js @@ -16,9 +16,12 @@ module.exports = { description: 'Finds common security issues in Java code with findsecbugs', enabled: true, handles: async fm => { - const isJavaProject = fm.all().some(file => file.endsWith('.java')) - const isKotlinProject = fm.all().some(file => file.endsWith('.kt')) - const isJvmProject = isJavaProject || isKotlinProject + const allFiles = fm.all() + const isJavaProject = allFiles.some(file => file.endsWith('.java')) + const isKotlinProject = allFiles.some(file => file.endsWith('.kt')) + const isScalaProject = allFiles.some(file => file.endsWith('.scala')) + + const isJvmProject = isJavaProject || isKotlinProject || isScalaProject const hasJarFiles = getProjectJars(fm).length > 0 const exists = await exec.exists('findsecbugs') diff --git a/lib/modules/java-owasp/__tests__/owasp-unit.js b/lib/modules/java-owasp/__tests__/owasp-unit.js index 010cab1f..1492a1d3 100644 --- a/lib/modules/java-owasp/__tests__/owasp-unit.js +++ b/lib/modules/java-owasp/__tests__/owasp-unit.js @@ -37,6 +37,11 @@ describe('Java OWASP Dependency Checker Module', () => { expect(await handles(fm)).to.be.true }) + it('should handle scala sbt projects', async () => { + const fm = new FileManager({ target: path.join(__dirname, './sample/scala-sbt') }) + expect(await handles(fm)).to.be.true + }) + it('should not run on missing executable', async () => { exec.exists.resolves(false) const fm = new FileManager({ target: path.join(__dirname, './sample/java-gradle') }) diff --git a/lib/modules/java-owasp/__tests__/sample/scala-sbt/build.sbt b/lib/modules/java-owasp/__tests__/sample/scala-sbt/build.sbt new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-owasp/__tests__/sample/scala-sbt/src/main/scala/Main.scala b/lib/modules/java-owasp/__tests__/sample/scala-sbt/src/main/scala/Main.scala new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-owasp/__tests__/sample/scala-sbt/target/scala-2.13/app.jar b/lib/modules/java-owasp/__tests__/sample/scala-sbt/target/scala-2.13/app.jar new file mode 100644 index 00000000..e69de29b diff --git a/lib/modules/java-owasp/index.js b/lib/modules/java-owasp/index.js index 085bafa6..5fb88630 100644 --- a/lib/modules/java-owasp/index.js +++ b/lib/modules/java-owasp/index.js @@ -13,9 +13,12 @@ module.exports = { description: 'Scans Java projects for gradle/maven dependencies with known vulnerabilities with the OWASP dependency checker', enabled: true, handles: async fm => { - const isJavaProject = fm.all().some(file => file.endsWith('.java')) - const isKotlinProject = fm.all().some(file => file.endsWith('.kt')) - const isJvmProject = isJavaProject || isKotlinProject + const allFiles = fm.all() + const isJavaProject = allFiles.some(file => file.endsWith('.java')) + const isKotlinProject = allFiles.some(file => file.endsWith('.kt')) + const isScalaProject = allFiles.some(file => file.endsWith('.scala')) + + const isJvmProject = isJavaProject || isKotlinProject || isScalaProject const hasJarFiles = getProjectJars(fm).length > 0 const hasCommand = await exec.exists('dependency-check')