Skip to content
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

converted elf_analysis plugin to new base class #1266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jstucke
Copy link
Collaborator

@jstucke jstucke commented Sep 11, 2024

No description provided.

@jstucke jstucke requested a review from maringuu September 11, 2024 15:39
@jstucke jstucke self-assigned this Sep 11, 2024
@jstucke jstucke force-pushed the elf-analysis-plugin-v1 branch from c14b112 to b307c7e Compare September 12, 2024 11:32
@jstucke jstucke force-pushed the elf-analysis-plugin-v1 branch from b307c7e to afec839 Compare December 3, 2024 08:46
@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 99.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.93%. Comparing base (bd5bdb0) to head (64db148).
Report is 28 commits behind head on master.

Files with missing lines Patch % Lines
...alysis/hardware_analysis/code/hardware_analysis.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1266      +/-   ##
==========================================
- Coverage   92.21%   91.93%   -0.29%     
==========================================
  Files         377      378       +1     
  Lines       23068    21104    -1964     
==========================================
- Hits        21273    19402    -1871     
+ Misses       1795     1702      -93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

for section in elf.sections:
if section.name == '.modinfo':
modinfo = section.content.tobytes()
modinfo = [entry.decode() for entry in modinfo.split(b'\x00') if entry]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle decoding errors here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will probably encounter only ascii but it won't hurt either

def normalize_lief_items(functions):
def normalize_lief_items(functions) -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we remove this function completely?
Why is this in helperFunctions.hash anyways?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed (or rather inlined)

Comment on lines 92 to 100
header: ElfHeader
sections: List[ElfSection]
segments: List[ElfSegment]
dynamic_entries: List[DynamicEntry]
exported_functions: List[ElfSymbol]
imported_functions: List[str]
mod_info: Optional[List[str]]
note_sections: List[InfoSectionData]
behavior_classes: List[str]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we document these?
Imo, we should at least document the non-standart ones like mod_info and behavior_classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documented both fields

Comment on lines 126 to 128
sections=[ElfSection.model_validate(s) for s in json_dict['sections']],
segments=[ElfSegment.model_validate(s) for s in json_dict['segments']],
dynamic_entries=[DynamicEntry.model_validate(e) for e in json_dict['dynamic_entries']],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo the code gets more readable if we do not serialize the lief elf representation to json.
E.g. like the exported_functions above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

and also removed the redundant normalize_lief_items method
@jstucke jstucke force-pushed the elf-analysis-plugin-v1 branch from 700a7d4 to 64db148 Compare December 31, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants