Ghidra is a software reverse engineering (SRE) framework
GP-0: Validating Python wheel Module.manifest IP
Ryan Kurtz0d24ae38aabb
diff --git a/build.gradle b/build.gradleindex 65d028f0c4..2d75307a08 100644--- a/build.gradle+++ b/build.gradle@@ -50,7 +50,7 @@ if ("32".equals(System.getProperty("sun.arch.data.model"))) {* Identify supported Python command***************************************************************************************/project.ext.PYTHON3 = findPython3(true)-project.ext.PYTHON_DEPS = new HashSet<String>()+project.ext.PYTHON_DEPS = new HashMap<Project, Set<File>>()/********************************************************************************** Define the location of bin repodiff --git a/gradle/hasPythonPackage.gradle b/gradle/hasPythonPackage.gradleindex b88c8bb85a..9e09c4818b 100644--- a/gradle/hasPythonPackage.gradle+++ b/gradle/hasPythonPackage.gradle@@ -80,8 +80,13 @@ rootProject.assembleDistribution {}ext.distributePyDep = { name ->+ Set<File> wheelFiles = PYTHON_DEPS.get(project)+ if (wheelFiles == null) {+ wheelFiles = new HashSet<>()+ PYTHON_DEPS.put(project, wheelFiles)+ }File dep = findPyDep(name)- PYTHON_DEPS.add(dep)+ wheelFiles.add(dep)def zipPath = getZipPath(project)rootProject.assembleDistribution {into ("${zipPath}/pypkg/dist") {diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradleindex b7639bf87b..f753473419 100644--- a/gradle/support/ip.gradle+++ b/gradle/support/ip.gradle@@ -43,6 +43,9 @@ task ip {// gets the external libs from gradle and verifies they are accounted for in the Module.manifest filecheckExternalLibsInMap(moduleManifestIpMap, project)+ // gets the declared external python wheels and verifies they are accounted for in the Module.manifest file+ checkExternalPythonWheelsInMap(moduleManifestIpMap, p)+// adds the ip info from the Module.manifest file to the map generated from scanning the module files.addModuleManifestIp(ipToFileMap, moduleManifestIpMap)@@ -105,6 +108,18 @@ def checkExternalLibsInMap(Map<String, String> map, Project project) {}}+/**********************************************************************************+ * Gets the python dependences and makes sure each external wheel is accounted for in+ * the map from the Module.manifest file+ *********************************************************************************/+def checkExternalPythonWheelsInMap(Map<String, String> map, Project project) {+ PYTHON_DEPS.getOrDefault(project, List.of()).each { dep ->+ String name = dep.getName() // get just the filename without the path+ String relativePath = "pypkg/dist/"+name;+ assert map.containsKey(relativePath) : "No License specified for external python wheel: "+relativePath+ " in module "+project.projectDir+ }+}+/********************************************************************************** Examines all the files in the module, reads their ip from the header, verifies* that the ip is allowed, and adds an entry to a mapping of the ip to a list of