Class ExecutableScorerSingle
java.lang.Object
ghidra.features.bsim.query.client.ExecutableScorer
ghidra.features.bsim.query.client.ExecutableScorerSingle
ExecutableComparison scorer to use when we are comparing exactly one executable
against a set of other executables (one to many). We override the
ExecutableScorer
(compare many to many) so that it effectively accesses only a single row
of the scoring matrix to get the "one to many" behavior we want.
The getNormalizedScore() methods on the base class require that executable self-scores,
other than the singled-out executable's self-score, be cached in some way.
Thus this scorer needs a ScoreCaching class.-
Nested Class Summary
Nested classes/interfaces inherited from class ghidra.features.bsim.query.client.ExecutableScorer
ExecutableScorer.FunctionPair -
Field Summary
Fields inherited from class ghidra.features.bsim.query.client.ExecutableScorer
executableSet, index2ExeMap, sigThreshold, simThreshold, singleExe, singleExeXref -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckPreliminaryPairThreshold(int hitcount, int pairThreshold) Make check if we are going to have too many pairs.voidCommit the singled out executables self-significance score to permanent storageprotected voidcommitSelfScore(String md5, float selfScore) Commit a self-significance score for a specific executable to permanent storageintfloatgetScore(int a) Get score of executable (as compared to our singled out executable)floatgetScore(int a, int b) Return the similarity score between two executablesfloatgetSelfScore(int a) Retrieve the similarity score of an executable with itselffloatprotected voidInitialize the scoring matrix with zero.protected List<ExecutableScorer.FunctionPair> pairFunctions(LSHVectorFactory vectorFactory, List<DescriptionManager> vec2func, List<VectorResult> vectors, int hitcount, int pairThreshold) Generate all pairs of functions for any function associated with a list of vectors For each pair of functions generate the FunctionPair object with corresponding similarity and significance.voidprefetchSelfScores(List<ExecutableRecord> missing) Pre-load self-scores of the registered executables.voidresetStorage(double simThresh, double sigThresh) Clear any persistent storage for self-significance scores, and establish new thresholdsprotected voidGiven a pair of score contributing functions that have been fully filtered, add the score into the matrixvoidSet a single executable as focus to enable the single parameter getScore(int)Methods inherited from class ghidra.features.bsim.query.client.ExecutableScorer
addExecutable, getExecutable, getExecutable, getNormalizedScore, getNormalizedScore, getSigThreshold, getSimThreshold, getSingularExecutable, labelAndFilter, numExecutables, populateExecutableIndex, scoreCluster, transferSettings
-
Constructor Details
-
ExecutableScorerSingle
Construct the scorer. If normalized scores are required, a self-score cacher must be provided.- Parameters:
cache- is the self-score cacher or null- Throws:
LSHException- for problems initializing the cache
-
-
Method Details
-
setSingleExecutable
Description copied from class:ExecutableScorerSet a single executable as focus to enable the single parameter getScore(int)- Overrides:
setSingleExecutablein classExecutableScorer- Parameters:
md5- is the 32-character md5 hash of the executable single out- Throws:
LSHException- if we can't find the executable
-
countSelfScores
public int countSelfScores()- Overrides:
countSelfScoresin classExecutableScorer- Returns:
- number of executable self-significance scores are (will be) available
-
resetStorage
Description copied from class:ExecutableScorerClear any persistent storage for self-significance scores, and establish new thresholds- Overrides:
resetStoragein classExecutableScorer- Parameters:
simThresh- is the new similarity thresholdsigThresh- is the new significance threshold- Throws:
LSHException- if there's a problem clearing storage
-
getSingularSelfScore
public float getSingularSelfScore()- Overrides:
getSingularSelfScorein classExecutableScorer
-
initializeScores
protected void initializeScores()Description copied from class:ExecutableScorerInitialize the scoring matrix with zero. The matrix size is the number of executables registered with addExecutable()- Overrides:
initializeScoresin classExecutableScorer
-
checkPreliminaryPairThreshold
protected boolean checkPreliminaryPairThreshold(int hitcount, int pairThreshold) Description copied from class:ExecutableScorerMake check if we are going to have too many pairs. This is preliminary because we haven't yet fetched the functions- Overrides:
checkPreliminaryPairThresholdin classExecutableScorer- Parameters:
hitcount- is the total number of pairs to fetchpairThreshold- is the maximum number of pairs allowed- Returns:
- true if the pair threshold is not exceeded
-
scorePair
Description copied from class:ExecutableScorerGiven a pair of score contributing functions that have been fully filtered, add the score into the matrix- Overrides:
scorePairin classExecutableScorer- Parameters:
pair- is the pair of functions
-
pairFunctions
protected List<ExecutableScorer.FunctionPair> pairFunctions(LSHVectorFactory vectorFactory, List<DescriptionManager> vec2func, List<VectorResult> vectors, int hitcount, int pairThreshold) Description copied from class:ExecutableScorerGenerate all pairs of functions for any function associated with a list of vectors For each pair of functions generate the FunctionPair object with corresponding similarity and significance. This is inherently quadratic, but we try to be efficient. Duplicate vector pairs are only compared once and the similarity cached, and each function pair is generated only once, ie. (funcA,funcB) but not (funcB,funcA)- Overrides:
pairFunctionsin classExecutableScorer- Parameters:
vectorFactory- provides weights for significance scoresvec2func- is the list of FunctionDescription sets associated with each vectorvectors- is the list of vectorshitcount- is the cumulative total of functionspairThreshold- is the maximum number of pairs that can be produced- Returns:
- the array of FunctionPairs or null if pairThreshold is exceeded
-
getScore
public float getScore(int a) Description copied from class:ExecutableScorerGet score of executable (as compared to our singled out executable)- Overrides:
getScorein classExecutableScorer- Parameters:
a- is the index of the executable- Returns:
- the score
-
getSelfScore
Description copied from class:ExecutableScorerRetrieve the similarity score of an executable with itself- Overrides:
getSelfScorein classExecutableScorer- Parameters:
a- is the index of the executable- Returns:
- its self-similarity score
- Throws:
LSHException- if the score is not accessible
-
commitSelfScore
Description copied from class:ExecutableScorerCommit the singled out executables self-significance score to permanent storage- Overrides:
commitSelfScorein classExecutableScorer- Throws:
LSHException- if there's a problem writing, or the operation isn't supported
-
commitSelfScore
Description copied from class:ExecutableScorerCommit a self-significance score for a specific executable to permanent storage- Overrides:
commitSelfScorein classExecutableScorer- Parameters:
md5- is the 32-character md5 hash of the executableselfScore- is the self-significance score- Throws:
LSHException- if there's a problem writing, or the operation isn't supported
-
getScore
public float getScore(int a, int b) Description copied from class:ExecutableScorerReturn the similarity score between two executables- Overrides:
getScorein classExecutableScorer- Parameters:
a- is the index matching getXrefIndex() of the first executableb- is the index matching getXrefIndex() of the second executable- Returns:
- the similarity score
-
prefetchSelfScores
Pre-load self-scores of the registered executables.- Parameters:
missing- (optional - may be null) will contain the list of exes missing a score- Throws:
LSHException- if there are problems loading scores
-