MCPcopy Create free account
hub / github.com/CheckPointSW/Karta / isValidCandidate

Method isValidCandidate

src/function_context.py:559–585  ·  view source on GitHub ↗

Check if the given binary context is a valid match candidate. Args: bin_ctx (ComparableContext): context representing a binary function (potential match) Return Value: False iff the binary context was found as an invalid match candidate

(self, bin_ctx)

Source from the content-addressed store, hash-verified

557 return None
558
559 def isValidCandidate(self, bin_ctx):
560 """Check if the given binary context is a valid match candidate.
561
562 Args:
563 bin_ctx (ComparableContext): context representing a binary function (potential match)
564
565 Return Value:
566 False iff the binary context was found as an invalid match candidate
567 """
568 # 0. Both must be in the game
569 if not self.active() or not bin_ctx.active():
570 return False
571
572 # 1. They must be in the same file
573 if not bin_ctx.isFileSuitable(self):
574 return False
575
576 # 2. A static function can not have an xref from outside the library (weak because of possible inlining)
577 if self.is_static and not bin_ctx.is_static:
578 return False
579
580 # 3. A collision candidate must not conflict with the previous matches
581 if not bin_ctx.isPartial() and bin_ctx.matched() and self.hash != bin_ctx.match.hash:
582 return False
583
584 # If reached this line, the candidate is probably fine
585 return True
586
587 def compare(self, bin_ctx, logger):
588 """Compare our (source) function to a potential binary match.

Callers 10

selfCheckMethod · 0.80
addHintsMethod · 0.80
declareMatchMethod · 0.80
updateHintsMethod · 0.80
roundMatchResultsMethod · 0.80
matchAttemptMethod · 0.80
matchFilesMethod · 0.80
attemptMatchesMethod · 0.80
attemptFindFileHintsMethod · 0.80
attemptFindAgentsMethod · 0.80

Calls 4

isFileSuitableMethod · 0.80
activeMethod · 0.45
isPartialMethod · 0.45
matchedMethod · 0.45

Tested by

no test coverage detected