Commit 90ba1b0
address: add optional id field for unique tracking of recycled PID/TID lifecycles
Adds an optional `id` field to `ProcessAddress` and `ThreadAddress` that
sandbox backends can populate with a sandbox-specific unique identifier
(e.g. VMRay monitor_id, or a sequential counter for CAPE). When set, this
field becomes part of equality/hashing so that two process or thread
instances that share the same OS-assigned PID/TID are treated as distinct
addresses throughout capa's pipeline.
This comprehensively fixes the ValueError crash in render (#2619) by solving
the root uniqueness problem described in #2361: rather than merging recycled
lifecycles into a single entry, each instance now gets its own identity.
Changes:
- address.py: add optional `id` to ProcessAddress and ThreadAddress; update
__eq__, __hash__, __lt__, __repr__ accordingly; backward-compatible (id=None
by default)
- freeze/__init__.py: extend from_capa/to_capa to encode/decode the new id
fields using extended tuple lengths; old 2/3/4-element tuples still decoded
correctly for backward compatibility
- vmray/extractor.py: pass monitor_id as id to both ProcessAddress and
ThreadAddress so each VMRay monitor instance is uniquely tracked
- cape/file.py: detect PID reuse via two-pass counting and assign sequential
ids; processes with unique PIDs keep id=None (no behavior change)
- render/verbose.py: add _format_process_fields / _format_thread_fields helpers
that include the id in rendered output when present
- tests/test_address_uniqueness.py: 35 unit tests covering identity, hashing,
sorting, freeze roundtrip (incl. backward compat), and compute_dynamic_layout
behavior for both recycled TIDs and recycled PIDs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent da1abed commit 90ba1b0
File tree
7 files changed
+749
-70
lines changed- capa
- features
- extractors
- cape
- vmray
- freeze
- render
- tests
7 files changed
+749
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
56 | 66 | | |
57 | 67 | | |
58 | 68 | | |
59 | 69 | | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | | - | |
| 82 | + | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
72 | | - | |
| 86 | + | |
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
76 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
77 | 94 | | |
78 | 95 | | |
79 | 96 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
83 | 109 | | |
84 | 110 | | |
85 | 111 | | |
| 112 | + | |
86 | 113 | | |
87 | 114 | | |
88 | | - | |
| 115 | + | |
| 116 | + | |
89 | 117 | | |
90 | 118 | | |
91 | | - | |
| 119 | + | |
92 | 120 | | |
93 | 121 | | |
94 | 122 | | |
95 | | - | |
| 123 | + | |
96 | 124 | | |
97 | 125 | | |
98 | 126 | | |
99 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
100 | 131 | | |
101 | 132 | | |
102 | 133 | | |
| |||
114 | 145 | | |
115 | 146 | | |
116 | 147 | | |
117 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
118 | 152 | | |
119 | 153 | | |
120 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | | - | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | | - | |
36 | | - | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
47 | 58 | | |
48 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
117 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
0 commit comments