mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-3199 - Updated Version Tracking classes to make them public
(Closes #4950)
This commit is contained in:
parent
41533b29a1
commit
faf73e8ecb
8 changed files with 37 additions and 43 deletions
|
@ -39,7 +39,7 @@ public class CombinedFunctionAndDataReferenceProgramCorrelator extends
|
||||||
* @param correlatorName The correlator name string passed from the factory.
|
* @param correlatorName The correlator name string passed from the factory.
|
||||||
* @param options {@code ToolOptions}
|
* @param options {@code ToolOptions}
|
||||||
*/
|
*/
|
||||||
CombinedFunctionAndDataReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
public CombinedFunctionAndDataReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DataReferenceProgramCorrelator extends VTAbstractReferenceProgramCo
|
||||||
* @param correlatorName The correlator name string passed from the factory.
|
* @param correlatorName The correlator name string passed from the factory.
|
||||||
* @param options {@code ToolOptions}
|
* @param options {@code ToolOptions}
|
||||||
*/
|
*/
|
||||||
DataReferenceProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
public DataReferenceProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class FunctionReferenceProgramCorrelator extends VTAbstractReferenceProgr
|
||||||
* @param correlatorName The correlator name string passed from the factory.
|
* @param correlatorName The correlator name string passed from the factory.
|
||||||
* @param options {@code ToolOptions}
|
* @param options {@code ToolOptions}
|
||||||
*/
|
*/
|
||||||
FunctionReferenceProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
public FunctionReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||||
|
Program sourceProgram,
|
||||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||||
|
|
|
@ -15,11 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.feature.vt.api.correlator.program;
|
package ghidra.feature.vt.api.correlator.program;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import generic.DominantPair;
|
import generic.DominantPair;
|
||||||
import generic.hash.FNV1a64MessageDigest;
|
import generic.hash.FNV1a64MessageDigest;
|
||||||
|
@ -28,19 +25,13 @@ import generic.lsh.KandL;
|
||||||
import generic.lsh.LSHMemoryModel;
|
import generic.lsh.LSHMemoryModel;
|
||||||
import generic.lsh.vector.LSHCosineVectorAccum;
|
import generic.lsh.vector.LSHCosineVectorAccum;
|
||||||
import generic.lsh.vector.VectorCompare;
|
import generic.lsh.vector.VectorCompare;
|
||||||
import ghidra.feature.vt.api.main.VTAssociationType;
|
import ghidra.feature.vt.api.main.*;
|
||||||
import ghidra.feature.vt.api.main.VTMatchInfo;
|
|
||||||
import ghidra.feature.vt.api.main.VTMatchSet;
|
|
||||||
import ghidra.feature.vt.api.main.VTScore;
|
|
||||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||||
import ghidra.framework.options.ToolOptions;
|
import ghidra.framework.options.ToolOptions;
|
||||||
import ghidra.framework.plugintool.ServiceProvider;
|
import ghidra.framework.plugintool.ServiceProvider;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressSetView;
|
import ghidra.program.model.address.AddressSetView;
|
||||||
import ghidra.program.model.listing.Data;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.listing.DataIterator;
|
|
||||||
import ghidra.program.model.listing.Listing;
|
|
||||||
import ghidra.program.model.listing.Program;
|
|
||||||
import ghidra.program.model.mem.MemoryAccessException;
|
import ghidra.program.model.mem.MemoryAccessException;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.CancelledException;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
|
@ -49,13 +40,6 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
|
|
||||||
public static final double SIMILARITY_THRESHOLD = 0.5;
|
public static final double SIMILARITY_THRESHOLD = 0.5;
|
||||||
|
|
||||||
protected SimilarDataProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
|
||||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
|
||||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
|
||||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
|
||||||
destinationAddressSet, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<Address, LSHCosineVectorAccum> sourceMap;
|
HashMap<Address, LSHCosineVectorAccum> sourceMap;
|
||||||
HashMap<Address, LSHCosineVectorAccum> destinationMap;
|
HashMap<Address, LSHCosineVectorAccum> destinationMap;
|
||||||
|
|
||||||
|
@ -64,6 +48,13 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
int featureID = 0;
|
int featureID = 0;
|
||||||
int minDataLength;
|
int minDataLength;
|
||||||
|
|
||||||
|
public SimilarDataProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||||
|
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
|
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||||
|
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||||
|
destinationAddressSet, options);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doCorrelate(VTMatchSet matchSet, TaskMonitor monitor) throws CancelledException {
|
protected void doCorrelate(VTMatchSet matchSet, TaskMonitor monitor) throws CancelledException {
|
||||||
minDataLength =
|
minDataLength =
|
||||||
|
@ -92,9 +83,9 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
|
|
||||||
private void extractNGramFeatures(VTMatchSet matchSet, boolean skipHomogenousData,
|
private void extractNGramFeatures(VTMatchSet matchSet, boolean skipHomogenousData,
|
||||||
TaskMonitor monitor, int n) throws CancelledException {
|
TaskMonitor monitor, int n) throws CancelledException {
|
||||||
sourceMap = new HashMap<Address, LSHCosineVectorAccum>();
|
sourceMap = new HashMap<>();
|
||||||
destinationMap = new HashMap<Address, LSHCosineVectorAccum>();
|
destinationMap = new HashMap<>();
|
||||||
idMap = new HashMap<Long, Integer>();
|
idMap = new HashMap<>();
|
||||||
|
|
||||||
final Program sourceProgram = getSourceProgram();
|
final Program sourceProgram = getSourceProgram();
|
||||||
final Program destinationProgram = getDestinationProgram();
|
final Program destinationProgram = getDestinationProgram();
|
||||||
|
@ -233,7 +224,7 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
LSHCosineVectorAccum destinationVector,
|
LSHCosineVectorAccum destinationVector,
|
||||||
Set<DominantPair<Address, LSHCosineVectorAccum>> neighbors, double threshold,
|
Set<DominantPair<Address, LSHCosineVectorAccum>> neighbors, double threshold,
|
||||||
TaskMonitor monitor) {
|
TaskMonitor monitor) {
|
||||||
List<VTMatchInfo> result = new ArrayList<VTMatchInfo>();
|
List<VTMatchInfo> result = new ArrayList<>();
|
||||||
|
|
||||||
Listing sourceListing = getSourceProgram().getListing();
|
Listing sourceListing = getSourceProgram().getListing();
|
||||||
Listing destinationListing = getDestinationProgram().getListing();
|
Listing destinationListing = getDestinationProgram().getListing();
|
||||||
|
@ -289,7 +280,7 @@ public class SimilarDataProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
getOptions().getEnum(SimilarDataProgramCorrelatorFactory.MEMORY_MODEL,
|
getOptions().getEnum(SimilarDataProgramCorrelatorFactory.MEMORY_MODEL,
|
||||||
SimilarDataProgramCorrelatorFactory.MEMORY_MODEL_DEFAULT);
|
SimilarDataProgramCorrelatorFactory.MEMORY_MODEL_DEFAULT);
|
||||||
int L = KandL.memoryModelToL(model);
|
int L = KandL.memoryModelToL(model);
|
||||||
return new LSHMultiHash<Address>(model.getK(), L);
|
return new LSHMultiHash<>(model.getK(), L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,13 +38,6 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
||||||
|
|
||||||
public static double SIMILARITY_THRESHOLD = 0.5;
|
public static double SIMILARITY_THRESHOLD = 0.5;
|
||||||
|
|
||||||
protected SimilarSymbolNameProgramCorrelator(ServiceProvider serviceProvider,
|
|
||||||
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
|
||||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
|
||||||
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
|
||||||
destinationAddressSet, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<Symbol, LSHCosineVectorAccum> sourceMap;
|
HashMap<Symbol, LSHCosineVectorAccum> sourceMap;
|
||||||
HashMap<Symbol, LSHCosineVectorAccum> destinationMap;
|
HashMap<Symbol, LSHCosineVectorAccum> destinationMap;
|
||||||
|
|
||||||
|
@ -53,6 +46,13 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
||||||
int featureID = 0;
|
int featureID = 0;
|
||||||
int minNameLength;
|
int minNameLength;
|
||||||
|
|
||||||
|
public SimilarSymbolNameProgramCorrelator(ServiceProvider serviceProvider,
|
||||||
|
Program sourceProgram, AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
|
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||||
|
super(serviceProvider, sourceProgram, sourceAddressSet, destinationProgram,
|
||||||
|
destinationAddressSet, options);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doCorrelate(VTMatchSet matchSet, TaskMonitor monitor) throws CancelledException {
|
protected void doCorrelate(VTMatchSet matchSet, TaskMonitor monitor) throws CancelledException {
|
||||||
minNameLength =
|
minNameLength =
|
||||||
|
@ -68,9 +68,9 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractNGramFeatures(VTMatchSet matchSet, TaskMonitor monitor, int n) {
|
private void extractNGramFeatures(VTMatchSet matchSet, TaskMonitor monitor, int n) {
|
||||||
sourceMap = new HashMap<Symbol, LSHCosineVectorAccum>();
|
sourceMap = new HashMap<>();
|
||||||
destinationMap = new HashMap<Symbol, LSHCosineVectorAccum>();
|
destinationMap = new HashMap<>();
|
||||||
idMap = new HashMap<String, Integer>();
|
idMap = new HashMap<>();
|
||||||
|
|
||||||
final Program sourceProgram = getSourceProgram();
|
final Program sourceProgram = getSourceProgram();
|
||||||
final Program destinationProgram = getDestinationProgram();
|
final Program destinationProgram = getDestinationProgram();
|
||||||
|
@ -183,7 +183,7 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
||||||
LSHCosineVectorAccum destinationVector,
|
LSHCosineVectorAccum destinationVector,
|
||||||
Set<DominantPair<Symbol, LSHCosineVectorAccum>> neighbors, double threshold,
|
Set<DominantPair<Symbol, LSHCosineVectorAccum>> neighbors, double threshold,
|
||||||
TaskMonitor monitor) {
|
TaskMonitor monitor) {
|
||||||
List<VTMatchInfo> result = new ArrayList<VTMatchInfo>();
|
List<VTMatchInfo> result = new ArrayList<>();
|
||||||
int sourceLength = 0;
|
int sourceLength = 0;
|
||||||
int destinationLength = 0;
|
int destinationLength = 0;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
|
||||||
getOptions().getEnum(SimilarSymbolNameProgramCorrelatorFactory.MEMORY_MODEL,
|
getOptions().getEnum(SimilarSymbolNameProgramCorrelatorFactory.MEMORY_MODEL,
|
||||||
SimilarSymbolNameProgramCorrelatorFactory.MEMORY_MODEL_DEFAULT);
|
SimilarSymbolNameProgramCorrelatorFactory.MEMORY_MODEL_DEFAULT);
|
||||||
int L = KandL.memoryModelToL(model);
|
int L = KandL.memoryModelToL(model);
|
||||||
return new LSHMultiHash<Symbol>(model.getK(), L);
|
return new LSHMultiHash<>(model.getK(), L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -70,7 +70,8 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro
|
||||||
* @param correlatorName the correlator name
|
* @param correlatorName the correlator name
|
||||||
* @param options the tool options
|
* @param options the tool options
|
||||||
*/
|
*/
|
||||||
VTAbstractReferenceProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
public VTAbstractReferenceProgramCorrelator(ServiceProvider serviceProvider,
|
||||||
|
Program sourceProgram,
|
||||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
AddressSetView destinationAddressSet, String correlatorName, ToolOptions options) {
|
||||||
// Call the constructor for the parent class.
|
// Call the constructor for the parent class.
|
||||||
|
|
|
@ -51,7 +51,7 @@ public abstract class VTAbstractProgramCorrelator implements VTProgramCorrelator
|
||||||
* @param options An Options object that contains the set of options to be used by the
|
* @param options An Options object that contains the set of options to be used by the
|
||||||
* correlating algorithm.
|
* correlating algorithm.
|
||||||
*/
|
*/
|
||||||
protected VTAbstractProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
public VTAbstractProgramCorrelator(ServiceProvider serviceProvider, Program sourceProgram,
|
||||||
AddressSetView sourceAddressSet, Program destinationProgram,
|
AddressSetView sourceAddressSet, Program destinationProgram,
|
||||||
AddressSetView destinationAddressSet, ToolOptions options) {
|
AddressSetView destinationAddressSet, ToolOptions options) {
|
||||||
this.serviceProvider = serviceProvider;
|
this.serviceProvider = serviceProvider;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class DummyTestProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
|
|
||||||
private int matchCount = 1;
|
private int matchCount = 1;
|
||||||
|
|
||||||
protected DummyTestProgramCorrelator() {
|
public DummyTestProgramCorrelator() {
|
||||||
this(1);
|
this(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class DummyTestProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
createAddressSet(), createOptions());
|
createAddressSet(), createOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DummyTestProgramCorrelator(int matchCount) {
|
public DummyTestProgramCorrelator(int matchCount) {
|
||||||
super(null, null, createAddressSet(), null, createAddressSet(), createOptions());
|
super(null, null, createAddressSet(), null, createAddressSet(), createOptions());
|
||||||
this.matchCount = matchCount;
|
this.matchCount = matchCount;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ public class DummyTestProgramCorrelator extends VTAbstractProgramCorrelator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "DummyTestProgramCorrelator";
|
return "DummyTestProgramCorrelator";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue