mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-19 07:44:44 +01:00
Added support for scanning of non-JAR packages from Maven
This commit is contained in:
@@ -54,7 +54,8 @@ class LibraryAdvisor @Inject() (
|
|||||||
val groupId = (xml \ "groupId").text
|
val groupId = (xml \ "groupId").text
|
||||||
val artifactId = (xml \ "artifactId").text
|
val artifactId = (xml \ "artifactId").text
|
||||||
val version = (xml \ "version").text
|
val version = (xml \ "version").text
|
||||||
Left(odcService.scanMaven(groupId, artifactId, version))
|
val depType = (xml \ "type").text
|
||||||
|
Left(odcService.scanMaven(groupId, artifactId, version, depType))
|
||||||
case other =>
|
case other =>
|
||||||
Right(s"Unknown root XML element: $other")
|
Right(s"Unknown root XML element: $other")
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ class LibraryAdvisor @Inject() (
|
|||||||
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/0.9.10
|
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic/0.9.10
|
||||||
url.getPath.split('/') match {
|
url.getPath.split('/') match {
|
||||||
case Array("", "artifact", groupId, artifactId, version) =>
|
case Array("", "artifact", groupId, artifactId, version) =>
|
||||||
Left(odcService.scanMaven(groupId, artifactId, version))
|
Left(odcService.scanMaven(groupId, artifactId, version, ""))
|
||||||
case _ =>
|
case _ =>
|
||||||
Right("Unknown path for mvnrepository.com: Expected https://mvnrepository.com/artifact/<groupId>/<artifactId>/<version>")
|
Right("Unknown path for mvnrepository.com: Expected https://mvnrepository.com/artifact/<groupId>/<artifactId>/<version>")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,12 +103,9 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
|
|||||||
result.copy(limitations = result.limitations ++ additionalLimitations)
|
result.copy(limitations = result.limitations ++ additionalLimitations)
|
||||||
}
|
}
|
||||||
|
|
||||||
def scanMaven(groupId: String, artifactId: String, version: String): Future[SingleLibraryScanResult] = scanInternal(
|
def scanMaven(groupId: String, artifactId: String, version: String, depType: String): Future[SingleLibraryScanResult] = {
|
||||||
createOdcCommand = createMavenOdcCommand,
|
val allowMultiple = depType != ""
|
||||||
isMainLibraryOption = Some(_.identifiers.exists(id => id.identifierType == "maven" && id.name == s"$groupId:$artifactId:$version")),
|
def pomXml(odcInstallation: OdcInstallation) = <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
logChecks = mavenLogChecks
|
|
||||||
){ (odcInstallation, dir) =>
|
|
||||||
val pomXml = <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.ysoft</groupId>
|
<groupId>com.ysoft</groupId>
|
||||||
<artifactId>odc-adhoc-project</artifactId>
|
<artifactId>odc-adhoc-project</artifactId>
|
||||||
@@ -147,12 +144,24 @@ class OdcService @Inject() (odcConfig: OdcConfig, odcDbConnectionConfig: OdcDbCo
|
|||||||
<groupId>{groupId}</groupId>
|
<groupId>{groupId}</groupId>
|
||||||
<artifactId>{artifactId}</artifactId>
|
<artifactId>{artifactId}</artifactId>
|
||||||
<version>{version}</version>
|
<version>{version}</version>
|
||||||
|
{if (depType != "") <type>{depType}</type>}
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
Files.write(dir.resolve("pom.xml"), pomXml.toString.getBytes(UTF_8))
|
scanInternal(
|
||||||
PreparationResult(includesTransitive = true)
|
createOdcCommand = createMavenOdcCommand,
|
||||||
}.map(addMavenLibsLimitations)
|
isMainLibraryOption = Some(isMainMavenLib(groupId, artifactId, version, allowMultiple)(_)),
|
||||||
|
logChecks = mavenLogChecks,
|
||||||
|
enableMultipleMainLibraries = allowMultiple
|
||||||
|
) { (odcInstallation, dir) =>
|
||||||
|
Files.write(dir.resolve("pom.xml"), pomXml(odcInstallation).toString.getBytes(UTF_8))
|
||||||
|
PreparationResult(includesTransitive = true)
|
||||||
|
}.map(addMavenLibsLimitations)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def isMainMavenLib(groupId: String, artifactId: String, version: String, allowMultiple: Boolean)(dep: AbstractDependency): Boolean = {
|
||||||
|
allowMultiple || dep.identifiers.exists(id => id.identifierType == "maven" && id.name == s"$groupId:$artifactId:$version")
|
||||||
|
}
|
||||||
|
|
||||||
private def nugetRestore(odcInstallation: OdcInstallation, dir: Path, packagesConfigFile: Path, packageName: String, version: String): Unit = {
|
private def nugetRestore(odcInstallation: OdcInstallation, dir: Path, packagesConfigFile: Path, packageName: String, version: String): Unit = {
|
||||||
val packagesConfig = <packages>
|
val packagesConfig = <packages>
|
||||||
|
|||||||
Reference in New Issue
Block a user