BinaryIdentifier: s/.Name/.CanonicalPath/g

This commit is contained in:
Alessandro Di Federico
2026-04-07 17:54:39 +02:00
parent 7b3a80155e
commit 5b43a23060
6 changed files with 19 additions and 8 deletions
+12 -3
View File
@@ -668,10 +668,19 @@ definitions:
doc: The size of the binary (in bytes)
type: uint64_t
- name: Name
- name: CanonicalPath
doc: |-
The binary's filename at the time when it was imported. This is kept
as an heuristic to re-search the file if it is missing.
The path of the binary in its "canonical" position (if sensible).
For instance, for `sh`, it makes sense to use `/bin/sh`.
This enables to lookup debug information and libraries relative to its
"canonical" position.
Moreover, if `Hash` is not enough to obtain the actual content of the
binary, this field will be used to perform a fuzzy search in sensible
place.
In case of Windows binaries, use UNIX paths relative to C:\ (e.g., use
/Windows for C:\Windows).
type: string
- name: Segment
+1 -1
View File
@@ -37,7 +37,7 @@ public:
// reliable than the filename of the file on disk (this is still used as a
// fallback in order to be compatible with the old pipeline).
if (Reference.isValid())
return Reference.get()->Name();
return Reference.get()->Path();
else if (not InputPath.empty())
return InputPath;
else if (not ObjectFile.getFileName().empty())
+3 -1
View File
@@ -58,7 +58,9 @@ def generate_model_with_binaries(binaries: list[Path]):
with open(binary, "rb") as f:
hash_ = compute_hash(f)
size = f.seek(0, os.SEEK_END)
result.append({"Index": index, "Hash": hash_, "Size": size, "Name": str(binary.resolve())})
result.append(
{"Index": index, "Hash": hash_, "Size": size, "CanonicalPath": str(binary.resolve())}
)
return {"Binaries": result}
+1 -1
View File
@@ -104,7 +104,7 @@ class ImportFiles(Pipe):
requests: list[FileRequest] = []
for binary in model_obj.Binaries:
indexes.append(binary.Index)
requests.append(FileRequest(binary.Hash, binary.Name, binary.Size))
requests.append(FileRequest(binary.Hash, binary.CanonicalPath, binary.Size))
return (indexes, requests)
+1 -1
View File
@@ -196,7 +196,7 @@ class Project(ABC):
size = Path(binary_path).stat().st_size
self.model.Binaries.append(
BinaryIdentifier(Index=0, Hash=hash_, Size=size, Name=Path(binary_path).name)
BinaryIdentifier(Index=0, Hash=hash_, Size=size, CanonicalPath=Path(binary_path).name)
)
self._commit()
self._analyze("initial-auto-analysis")
@@ -41,7 +41,7 @@ The first thing rev.ng needs to know is which binary to load, this is done by sp
```yaml title="model.yml"
Binaries:
- Index: 0
Name: sum
CanonicalPath: sum
# Output of `sha256sum sum`
Hash: bba591a825f58c1b94fc4d8c13f5d3531a89282cb3319a1418ee3f8396880567
# Output of `wc -c sum`