Ghidra is a software reverse engineering (SRE) framework
Handle changes to allow for certification headers on bash type source files (e.g., *.py) and gradle files
ghidra1d2c39513c3b9
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/Range.java b/Ghidra/Framework/Utility/src/main/java/ghidra/util/datastruct/Range.javasimilarity index 100%rename from Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/Range.javarename to Ghidra/Framework/Utility/src/main/java/ghidra/util/datastruct/Range.javadiff --git a/gradle/certification.manifest b/gradle/certification.manifestindex 430baa7114..0970bcd7da 100644--- a/gradle/certification.manifest+++ b/gradle/certification.manifest@@ -23,7 +23,6 @@ support/distributionCommon.gradle||GHIDRA||||END|support/eclipseLauncher.gradle||GHIDRA||||END|support/extensionCommon.gradle||GHIDRA||||END|support/fetchDependencies.gradle||GHIDRA||||END|-support/ip.gradle||GHIDRA||||END|support/jacoco.excludes.src.txt||GHIDRA||||END|support/loadApplicationProperties.gradle||GHIDRA||||END|support/settingsUtil.gradle||GHIDRA||||END|diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradleindex 2125091554..1e4bbe6e05 100644--- a/gradle/support/ip.gradle+++ b/gradle/support/ip.gradle@@ -1,4 +1,18 @@-+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ *//********************************************************************************** ip.gradle*@@ -152,12 +166,13 @@ def addToMap(Map<String, List<String>> map, String ip, String path) {/********************************************************************************** checks if a file supports a C style header based on its extension.*********************************************************************************/-def isSourceFile(File file) {+def isCSourceFile(File file) {String filename = file.getName().toLowerCase();return filename.endsWith(".java") ||filename.endsWith(".c") ||+ filename.endsWith(".gradle") ||filename.endsWith(".groovy") ||filename.endsWith(".cpp") ||filename.endsWith(".cc") ||@@ -166,16 +181,38 @@ def isSourceFile(File file) {filename.endsWith(".l") ||filename.endsWith(".hh") ||filename.endsWith(".css") ||- filename.endsWith(".jj");+ filename.endsWith(".jj") ||+ filename.endsWith(".proto");+}++/*********************************************************************************+ * checks if a file supports a Bash style header based on its extension.+ *********************************************************************************/+def isBashSourceFile(File file) {++ String filename = file.getName().toLowerCase();++ // NOTE: bash/shell scripts without extension will not utilize a header+ return filename.endsWith(".py") ||+ filename.endsWith(".sh") ||+ filename.endsWith(".bash") ||+ filename.endsWith(".command");}/*********************************************************************************- * Gets the ip for a file in the module from its header (or certification.manifest+ * Gets the ip for a file in the module from its header (or certification.manifest)*********************************************************************************/def getIp(File projectDir, File file) {- if (isSourceFile(file)) {- return getIpForSourceFile(file);+ if (isCSourceFile(file)) {+ return getIpForSourceFile(file, " * IP:");+ }+ if (isBashSourceFile(file)) {+ String ip = getIpForSourceFile(file, "# IP:");+ // allow transition from certification.manifest entry+ if (ip != null) {+ return ip;+ }}return getIpForNonSourceFile(projectDir, file);}@@ -183,12 +220,14 @@ def getIp(File projectDir, File file) {/********************************************************************************** Gets the ip from a file that has a certification header*********************************************************************************/-def getIpForSourceFile(File file) {+def getIpForSourceFile(File file, String prefix) {+ // IP marking occurs within first 4-lines of fileString ip =nullString line;+ int lineNum = 0;file.withReader { reader ->- while((line = reader.readLine()) != null) {- if (line.startsWith(" * IP:")) {+ while(++lineNum < 5 && (line = reader.readLine()) != null) {+ if (line.startsWith(prefix)) {ip = line.substring(7).trim();break;}