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

GEF code quality improvement, with support with GDB 8+ and Python3.6+ #779

Merged
merged 65 commits into from
Jan 16, 2022

Conversation

hugsy
Copy link
Owner

@hugsy hugsy commented Jan 12, 2022

Description/Motivation/Screenshots

Brace yourselves, this is a damn big PR.
It aims to improve the code quality and readability that are allowed by bumping our minimum version requirement for GDB.

This PR:

  • Bumps GEF to require a GDB 8.0+ compiled against Python 3.6+
  • Creates a unified gef root namespace allowing to simplify the session information through sub-namespaces like
    • gef.config
    • gef.heap
    • gef.session
    • gef.memory
    • gef.ui
    • etc.
  • Adds Type Hinting
  • Replaces string formatting with f-string
  • Replaces most hardcoded paths to pathlib.Path objects
  • Updates the documentation accordingly, mostly in docs/api.md and created a new docs/api/gef.md with the entire API of functions/classes exposed by GEF to facilitate even more 3rd party command development
  • Moved non-Linux support for GEF to gef-extras/os
  • Adds a nice contributor image on the README

Fixes #316
Fixes #536
Fixes #767

How Has This Been Tested?

Architecture Yes/No Comments
x86-32 ✔️
x86-64 ✔️
ARM ✔️
AARCH64 ✔️
MIPS ✖️ Failed to reasons unrelated to this PR
POWERPC ✔️
SPARC ✖️
RISC-V ✖️
make test ✔️

Checklist

  • My PR was done against the dev branch, not master.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • My change adds tests as appropriate.
  • I have read and agree to the CONTRIBUTING document.

hugsy and others added 30 commits December 11, 2021 17:56
…used to make the API simpler and more Pythonic. Also adds memory access (via `gef.memory`) and settings (via `gef.config`)
 - creates a `GefHeapManager` class
 - deprecates many functions to an equivalent more readable
 - made `GlibcArena` and `GlibcChunk` classes iterable
- Add `gef.session` which includes many runtime info (`.pagesize`, `.canary`, `.constants`, etc.)
- Add more docstrings
- The GDB command objects are now in the namespace `gef.gdb`
- Adjust some gef functions to check result
- Make `endian_str`, `gef_pagesize`, `gef_read_canary`, `set_gef_setting` and `get_gef_setting` deprecated APIs
- new context manager for output redirection: `RedirectOutputContext`
* refactor: use dict comprehension (PEP 274)

* refactor: use generator expressions (PEP 289)

* refactor: use yield from syntax (PEP 380)
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@daniellimws daniellimws left a comment

Choose a reason for hiding this comment

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

Missed these earlier

gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
@theguy147
Copy link
Collaborator

theguy147 commented Jan 13, 2022

I'll remove all my type hint suggestions from this review as I'm feeling like I'm creating more confusion then helping with them here and go back to the initial plan of making a new PR once this one has been merged to get the type hints finalized.

@hugsy
Copy link
Owner Author

hugsy commented Jan 13, 2022

Good idea @theguy147 (although I already fixed some yesterday). Like I mentioned, I don't see any problem for adding (or fixing) the type hinting gradually.

Also this PR is big enough with changes on its own (which need to be reviewed and tested). Please refrain from just commenting for just basic linting changes that can be fixed any time.

Not everything has to be done in this PR.

Copy link
Collaborator

@theguy147 theguy147 left a comment

Choose a reason for hiding this comment

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

in regards to the heap bins commands...

gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
Copy link
Collaborator

@theguy147 theguy147 left a comment

Choose a reason for hiding this comment

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

Found some deprecated stuff still being actively used inside GEF

gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
tests/runtests.py Show resolved Hide resolved
tests/runtests.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Outdated Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
gef.py Show resolved Hide resolved
@Grazfather
Copy link
Collaborator

Done my review!

hugsy and others added 2 commits January 16, 2022 15:53
Co-authored-by: theguy147 <37738506+theguy147@users.noreply.github.com>
Co-authored-by: Grazfather <grazfather@gmail.com>
- minor type adjustments
@Grazfather Grazfather merged commit 5f31516 into dev Jan 16, 2022
@Grazfather Grazfather deleted the gdb_8_py36_code_refactor branch January 16, 2022 22:55
@hugsy hugsy mentioned this pull request Jan 21, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code refactoring plan for release 2022.01 - GDB 8/Python 3.6) Add 'unknown arch' that is the default
4 participants