mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-23 01:30:25 +01:00
.NET scans are now able to detect a missing library
This commit is contained in:
@@ -98,7 +98,6 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
|
|||||||
</packages>
|
</packages>
|
||||||
val packagesConfigFile = dir.resolve("..").resolve("packages.config")
|
val packagesConfigFile = dir.resolve("..").resolve("packages.config")
|
||||||
Files.write(packagesConfigFile, packagesConfig.toString().getBytes(UTF_8))
|
Files.write(packagesConfigFile, packagesConfig.toString().getBytes(UTF_8))
|
||||||
import sys.process._
|
|
||||||
val cmd = Seq(
|
val cmd = Seq(
|
||||||
nugetBin,
|
nugetBin,
|
||||||
"restore",
|
"restore",
|
||||||
@@ -106,7 +105,20 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
|
|||||||
"-PackagesDirectory",
|
"-PackagesDirectory",
|
||||||
dir.toString
|
dir.toString
|
||||||
) ++ odcConfig.dotNetNugetSource.fold(Seq[String]())(source => Seq("-source", source))
|
) ++ 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] = {
|
private def consumeStream(in: InputStream): Array[Byte] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user