-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add code signature, string table, and symbol table sizes #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #451 +/- ##
==========================================
+ Coverage 80.46% 80.50% +0.03%
==========================================
Files 159 159
Lines 13410 13462 +52
Branches 1414 1424 +10
==========================================
+ Hits 10790 10837 +47
Misses 2086 2086
- Partials 534 539 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if self.binary.has_code_signature: | ||
| cs = self.binary.code_signature | ||
| code_signature_size = cs.data_size | ||
| code_signature_offset = cs.data_offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: AttributeError occurs if self.binary.code_signature is None despite has_code_signature being True when accessing cs.data_size.
Severity: CRITICAL | Confidence: 0.95
🔍 Detailed Analysis
The code attempts to access cs.data_size on line 335 without ensuring cs is not None. This occurs when self.binary.has_code_signature is True but self.binary.code_signature returns None, leading to an AttributeError: 'NoneType' object has no attribute 'data_size'. This can happen if the LIEF library returns None for code_signature under certain conditions, such as with malformed binaries, causing an unexpected AttributeError that will propagate up.
💡 Suggested Fix
Add a null check for self.binary.code_signature after the has_code_signature check. Modify if self.binary.has_code_signature: to if self.binary.has_code_signature and self.binary.code_signature:.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/launchpad/parsers/apple/macho_parser.py#L333-L336
Potential issue: The code attempts to access `cs.data_size` on line 335 without ensuring
`cs` is not `None`. This occurs when `self.binary.has_code_signature` is `True` but
`self.binary.code_signature` returns `None`, leading to an `AttributeError: 'NoneType'
object has no attribute 'data_size'`. This can happen if the LIEF library returns `None`
for `code_signature` under certain conditions, such as with malformed binaries, causing
an unexpected `AttributeError` that will propagate up.
Did we get this right? 👍 / 👎 to inform future reviews.
Adds some extra breakdown of the LINKEDIT segment to match our old behavior: