Skip to content

Ghidra is a software reverse engineering (SRE) framework

Merge remote-tracking branch 'origin/GP-7320_ryanmkurtz_hashes-2'

Ryan Kurtzbeda94db30f2
diff --cc gradle/support/ip.gradle
index 13c2b5e25e,c4d079d23b..7d0b15e8fe
--- a/gradle/support/ip.gradle
+++ b/gradle/support/ip.gradle
@@@ -55,8 -55,66 +55,65 @@@ task ip
writeLicenseInfo(p, ipToFileMap)
}
}
-rootProject.prepDev.dependsOn ip
rootProject.assembleDistribution.dependsOn ip
+ /*********************************************************************************
+ * Verifies the ip of each external jar when the classpath is resolved
+ *********************************************************************************/
+ plugins.withType(JavaPlugin) {
+ def p = project
+ Throwable failure = null
+ configurations.matching { it.name in ['compileClasspath', 'runtimeClasspath'] }.configureEach { c ->
+ c.incoming.afterResolve { ResolvableDependencies rd ->
+ if (failure == null) {
+ try {
+ checkExternalLibIp(p, rd)
+ }
+ catch (Throwable t) {
+ failure = t
+ }
+ }
+ if (failure != null) {
+ throw failure
+ }
+ }
+ }
+
+ // The root project forces classpaths to be resolved when the task graph is ready, and
+ // ignores any exceptions when it does, so rethrow any failure that occurred then
+ gradle.taskGraph.whenReady {
+ if (failure != null) {
+ throw failure
+ }
+ }
+ }
+
+ /*********************************************************************************
+ * Verifies that each external jar in the resolved classpath that is directly declared
+ * as a dependency of the project has an allowed ip in the Module.manifest file
+ *********************************************************************************/
+ def checkExternalLibIp(Project project, ResolvableDependencies rd) {
+
+ // reads the ip info from the Module.manifest file and verifies each ip
+ def moduleManifestIpMap = getModuleManifestIp(project)
+
+ Set<String> declared = new HashSet<>()
+ ['api', 'implementation', 'runtimeOnly'].each { name ->
+ project.configurations.findByName(name)?.dependencies?.withType(ExternalDependency)?.each { dep ->
+ declared.add((dep.group ?: "") + ":" + dep.name)
+ }
+ }
+
+ rd.artifacts.artifacts.each { artifact ->
+ def id = artifact.id.componentIdentifier
+ if (id instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier &&
+ declared.contains((id.group ?: "") + ":" + id.module)) {
+ String relativePath = "lib/" + artifact.file.name
+ assert moduleManifestIpMap.containsKey(relativePath) : "No License specified for external library: "+relativePath+ " in module "+project.projectDir
+ }
+ }
+ }
+
/*********************************************************************************
* Addes the ip information from the Module.manifest file into the ipToFileMap