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 boolean
checkPreliminaryPairThreshold
(int hitcount, int pairThreshold) Make check if we are going to have too many pairs.void
Commit the singled out executables self-significance score to permanent storageprotected void
commitSelfScore
(String md5, float selfScore) Commit a self-significance score for a specific executable to permanent storageint
float
getScore
(int a) Get score of executable (as compared to our singled out executable)float
getScore
(int a, int b) Return the similarity score between two executablesfloat
getSelfScore
(int a) Retrieve the similarity score of an executable with itselffloat
protected void
Initialize 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.void
prefetchSelfScores
(List<ExecutableRecord> missing) Pre-load self-scores of the registered executables.void
resetStorage
(double simThresh, double sigThresh) Clear any persistent storage for self-significance scores, and establish new thresholdsprotected void
Given a pair of score contributing functions that have been fully filtered, add the score into the matrixvoid
Set 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:ExecutableScorer
Set a single executable as focus to enable the single parameter getScore(int)- Overrides:
setSingleExecutable
in 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:
countSelfScores
in classExecutableScorer
- Returns:
- number of executable self-significance scores are (will be) available
-
resetStorage
Description copied from class:ExecutableScorer
Clear any persistent storage for self-significance scores, and establish new thresholds- Overrides:
resetStorage
in 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:
getSingularSelfScore
in classExecutableScorer
-
initializeScores
protected void initializeScores()Description copied from class:ExecutableScorer
Initialize the scoring matrix with zero. The matrix size is the number of executables registered with addExecutable()- Overrides:
initializeScores
in classExecutableScorer
-
checkPreliminaryPairThreshold
protected boolean checkPreliminaryPairThreshold(int hitcount, int pairThreshold) Description copied from class:ExecutableScorer
Make check if we are going to have too many pairs. This is preliminary because we haven't yet fetched the functions- Overrides:
checkPreliminaryPairThreshold
in 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:ExecutableScorer
Given a pair of score contributing functions that have been fully filtered, add the score into the matrix- Overrides:
scorePair
in 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:ExecutableScorer
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. 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:
pairFunctions
in 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:ExecutableScorer
Get score of executable (as compared to our singled out executable)- Overrides:
getScore
in classExecutableScorer
- Parameters:
a
- is the index of the executable- Returns:
- the score
-
getSelfScore
Description copied from class:ExecutableScorer
Retrieve the similarity score of an executable with itself- Overrides:
getSelfScore
in 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:ExecutableScorer
Commit the singled out executables self-significance score to permanent storage- Overrides:
commitSelfScore
in classExecutableScorer
- Throws:
LSHException
- if there's a problem writing, or the operation isn't supported
-
commitSelfScore
Description copied from class:ExecutableScorer
Commit a self-significance score for a specific executable to permanent storage- Overrides:
commitSelfScore
in 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:ExecutableScorer
Return the similarity score between two executables- Overrides:
getScore
in 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
-