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