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

Method attemptFindFileHints

src/file_layer.py:187–217  ·  view source on GitHub ↗

Attempt to find matches using file name hint strings.

(self)

Source from the content-addressed store, hash-verified

185 return self._engine.matchAttempt(matched_src_index + 1, self._bin_functions_ctx[matched_bin_index + 1].ea, file_match=self)
186
187 def attemptFindFileHints(self):
188 """Attempt to find matches using file name hint strings."""
189 # can't match anything if already matched them all (or was disabled)
190 if not self.active():
191 return
192 # check if there is a hint pointing at my file
193 our_str_hint = None
194 for file_hint in self._engine._str_file_hints:
195 if self.name.split(os.path.sep)[-1].split(".")[0] == file_hint.split(".")[0]:
196 our_str_hint = file_hint
197 break
198 if our_str_hint is None:
199 return
200 # now try to match every hinted source function, with every hinted binary functions
201 for src_index in range(self._src_index_start, self._src_index_end + 1):
202 src_ctx = self._engine.src_functions_ctx[src_index]
203 # skip matched / unhinted functions
204 if not src_ctx.active() or src_ctx.file_hint is None:
205 return
206 # find the hinted binary candidates
207 for bin_ctx in (self._bin_functions_ctx if self.located else self._engine.floatingBinFunctions()):
208 # skip unhinted functions
209 if our_str_hint not in bin_ctx.strings:
210 continue
211 # filter it, before giving it a matching score
212 if not src_ctx.isValidCandidate(bin_ctx):
213 continue
214 # now attempt to score them (the boost is embedded in the scoring of the matched hint string)
215 score = src_ctx.compare(bin_ctx, self._engine.logger)
216 # record the result (the final decision about it will be received later)
217 self._engine.recordRoundMatchAttempt(src_index, bin_ctx.ea, 0, score, REASON_FILE_HINT)
218
219 def attemptFindAgents(self):
220 """Attempt to find "agents" functions according to unique file artifacts."""

Callers 1

matchFilesMethod · 0.80

Calls 5

floatingBinFunctionsMethod · 0.80
isValidCandidateMethod · 0.80
activeMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected