mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-08-08 07:40:39 -09:00
GP-0 fix 7z cli tool wrapper to parse version info better
This commit is contained in:
@@ -37,7 +37,11 @@ public class SevenZipCliToolWrapper extends AbstractCliToolWrapper
|
|||||||
private static final List<String> NATIVE_UNIX_EXE_NAMES = List.of("7zz", "7zzs", "7z");
|
private static final List<String> NATIVE_UNIX_EXE_NAMES = List.of("7zz", "7zzs", "7z");
|
||||||
private static final List<String> NATIVE_WIN_EXE_NAMES = List.of("7z.exe");
|
private static final List<String> NATIVE_WIN_EXE_NAMES = List.of("7z.exe");
|
||||||
private static final Pattern SZ_VER_PATTERN =
|
private static final Pattern SZ_VER_PATTERN =
|
||||||
Pattern.compile(".*7-Zip \\(z\\) ([0-9.]+) .*Copyright \\(c\\).*");
|
Pattern.compile(".*7-Zip " + // const prefix
|
||||||
|
"(\\(.\\) )?" + // optional "(a|r|z)" specifier, group=1
|
||||||
|
"([0-9.]+) " + // 7z version number, eg. 23.01, group=2
|
||||||
|
".*Copyright \\(c\\).*" // const sufix
|
||||||
|
);
|
||||||
|
|
||||||
private static final List<String> getCurrentOSNativeExeNames() {
|
private static final List<String> getCurrentOSNativeExeNames() {
|
||||||
return switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {
|
return switch (OperatingSystem.CURRENT_OPERATING_SYSTEM) {
|
||||||
@@ -61,7 +65,7 @@ public class SevenZipCliToolWrapper extends AbstractCliToolWrapper
|
|||||||
if (execAndReadStdOut(List.of("--help"), monitor, sb::append) == 0) {
|
if (execAndReadStdOut(List.of("--help"), monitor, sb::append) == 0) {
|
||||||
Matcher m = SZ_VER_PATTERN.matcher(sb.toString());
|
Matcher m = SZ_VER_PATTERN.matcher(sb.toString());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
SemVer ver = SemVer.parse(m.group(1));
|
SemVer ver = SemVer.parse(m.group(2));
|
||||||
return ver != SemVer.INVALID && ver.compareTo(MIN_SUPPORTED_VER) >= 0;
|
return ver != SemVer.INVALID && ver.compareTo(MIN_SUPPORTED_VER) >= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package pdb.symbolserver;
|
package pdb.symbolserver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
import static org.junit.Assume.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -28,6 +28,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
|
|
||||||
|
import ghidra.file.formats.sevenzip.SevenZipCliToolWrapper;
|
||||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.CancelledException;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
@@ -57,11 +58,16 @@ public class SymbolServerService2Test extends AbstractGhidraHeadedIntegrationTes
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
|
// Don't cause test failure if 7z cli tool isn't installed on test env
|
||||||
|
assumeTrue("Missing 7z cli tool in testing env PATH, skipping",
|
||||||
|
SevenZipCliToolWrapper.findTool(TaskMonitor.DUMMY) != null);
|
||||||
|
|
||||||
temporaryDir = createTempDirectory("symbolservers");
|
temporaryDir = createTempDirectory("symbolservers");
|
||||||
localSymbolStore1Root = new File(temporaryDir, "symbols1");
|
localSymbolStore1Root = new File(temporaryDir, "symbols1");
|
||||||
LocalSymbolStore.create(localSymbolStore1Root, 1);
|
LocalSymbolStore.create(localSymbolStore1Root, 1);
|
||||||
|
|
||||||
localSymbolStore1 = new LocalSymbolStore(localSymbolStore1Root);
|
localSymbolStore1 = new LocalSymbolStore(localSymbolStore1Root);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user