PAGalaxyLab / vxhunter

ToolSet for VxWorks Based Embedded Device Analyses
BSD 2-Clause "Simplified" License
334 stars 70 forks source link

Logging improvements, Logic Error Fix and Performance #10

Closed svidovich closed 4 years ago

svidovich commented 4 years ago

Hello! I've prepared a PR as a potential improvement. This began as minor fixes to make vxhunter work with a particular VxWorks binary that wouldn't run all the way through.

This ended up being an out-of-range access problem due to logging in the _check_fix function in vxhunter_core. I fixed this problem, and on the way, added a ton of logging, and clarity around the logs.

Another problem was that logging in vxhunter_symbol didn't really work out of the box, so I added basicConfig to that module which can be turned on as desired. Some unnecessary exception handling was removed from vxhunter_symbol as well.

While digging around, I noticed that you had a TODO around improving the performance of the function called _check_is_func_name in vxhunter_core. I improved the logic to use regex instead of a list iteration for checking whether or not any of the characters matched a 'bad list', which you had provided before. I renamed the _check_is_func_name to _is_func_name for clarity, since it returns a boolean value. Using the new logic, this function will run faster, and if a failure occurs, will fail faster.

Also, the static _is_printable method of the VxTarget class now works on both strings and characters, which should help writing performance improvements around this in the future. Instead of checking whether each character of a string is within ascii range, we can simply try to decode it to ascii. If an exception occurs, the function will return false; otherwise it will return true.

At times, I noticed that * imports lead to confusion, so where I could, I eliminated these in place of explicit imports from given modules.

Other changes you'll notice are mostly due to autoformatting, such as indentation, spacing, etc.

I have found that with my changes, firmwares old and new run through successfully. I hope this finds you well!

dark-lbp commented 4 years ago

Hi @svidovich thanks for the PR, please submit this PR on the 'dev' branch.

svidovich commented 4 years ago

I have made changes as requested, and the code still runs quite well locally for me. Let me know if it gives you any difficulties, or if you'd like more changes. Thank you!

dark-lbp commented 4 years ago

Merged, thanks for the pr.