.NET scans are now able to detect a missing library

This commit is contained in:
Šesták Vít
2017-08-01 16:24:18 +02:00
parent 4ac4b7b501
commit f8e073cc54

View File

@@ -98,7 +98,6 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
</packages>
val packagesConfigFile = dir.resolve("..").resolve("packages.config")
Files.write(packagesConfigFile, packagesConfig.toString().getBytes(UTF_8))
import sys.process._
val cmd = Seq(
nugetBin,
"restore",
@@ -106,7 +105,20 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
"-PackagesDirectory",
dir.toString
) ++ odcConfig.dotNetNugetSource.fold(Seq[String]())(source => Seq("-source", source))
cmd.!!
val process = new ProcessBuilder(cmd: _*).
directory(new File(odcConfig.workingDirectory)).
redirectErrorStream(true).
start()
val rawLog = consumeStream(process.getInputStream)
val res = process.waitFor()
if(res != 0){
val log = new String(rawLog)
val NotFoundRegex = """Unable to find version '([^']+)' of package '([^']+)'.""".r
log.lines.toStream.head match {
case NotFoundRegex(version, packageName) => throw DependencyNotFoundException(s"$packageName:$version")
case _ => sys.error(s"Bad return code from NuGet: $res. Output: $log")
}
}
}
private def consumeStream(in: InputStream): Array[Byte] = {