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

Class ExternalFunction

src/function_context.py:6–81  ·  view source on GitHub ↗

A context that describes a source-code point of view of an external function, using references from/to it. Attributes ---------- hints (set): set of possible match (bin) candidates represented as eas xrefs (set): set of xrefs to this external function, as seen in the source

Source from the content-addressed store, hash-verified

4import config.libc_config as libc
5
6class ExternalFunction(CodeContext):
7 """A context that describes a source-code point of view of an external function, using references from/to it.
8
9 Attributes
10 ----------
11 hints (set): set of possible match (bin) candidates represented as eas
12 xrefs (set): set of xrefs to this external function, as seen in the source project
13 """
14
15 def __init__(self, name):
16 """Create a class instance using only the name (ea is unknown until we will have a match).
17
18 Args:
19 name (str): name of the external function
20 """
21 super(ExternalFunction, self).__init__(name)
22 self.hints = None
23 self.xrefs = set()
24
25 # Overridden base function
26 def declareMatch(self, match):
27 """Declare a match between our source external and a binary function.
28
29 Args:
30 match (ea): the match ea
31 """
32 self.match = match
33
34 # Overridden base function
35 def valid(self):
36 """Check if the function is still valid (still active).
37
38 Return Value:
39 True iff the function still exists in the file matching process
40 """
41 return True
42
43 def addXref(self, xref):
44 """Add an xref to the function.
45
46 Args:
47 xref (CodeContext): code context that calls (xrefs) our function
48 """
49 self.xrefs.add(xref)
50
51 def removeXref(self, xref):
52 """Remove an xref from the function (the caller was probably found irrelevant for our search).
53
54 Args:
55 xref (CodeContext): code context that calls (xrefs) our function
56 """
57 if xref in self.xrefs:
58 self.xrefs.remove(xref)
59
60 def used(self):
61 """Check if our external function is still used by active functions.
62
63 Return Value:

Callers 1

loadAndPrepareSourceMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected