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

Remove more python2-specific stuff #665

Merged
merged 2 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Refresh environment
- name: Install python and toolchain
run: |
sudo apt-get update
sudo apt-get install -y gdb-multiarch python3-dev python3-pip python3-wheel python3-setuptools git cmake gcc g++ pkg-config libglib2.0-dev
Expand All @@ -33,29 +33,27 @@ jobs:
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
echo "::set-output name=dir::$(python3 -m pip cache dir)"

- name: Cache trinity libs
- name: Cache dependencies
uses: actions/cache@v2
id: cache-libs
id: cache-deps
env:
cache-name: cache-trinity-libs-and-python-modules
cache-name: cache-deps
with:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
path: |
${{ steps.pip-cache.outputs.dir }}
~/.cache/pip
restore-keys:
${{ runner.os }}-pip-${{ env.cache-name }}-
${{ runner.os }}-pip-
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-

- name: Compile Capstone/Keystone/Unicorn and install Python modules
if: steps.cache-libs.outputs.cache-hit != 'true'
- name: Install Python modules (Capstone, Keystone, Unicorn, Ropper)
run: |
mkdir -p ~/.cache/pip || echo ok
python3 -c 'import capstone, keystone, unicorn' || python3 -m pip install --user --upgrade -r ./requirements.txt
mkdir -p ${{ steps.pip-cache.outputs.dir }}
python3 -m pip install --user --upgrade -r ./requirements.txt
Grazfather marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup GEF
run: |
Expand Down
22 changes: 8 additions & 14 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#

from __future__ import print_function, division, absolute_import

import abc
import argparse
Expand Down Expand Up @@ -5085,10 +5081,10 @@ def load_module(self, file_path):
return module

def enumerate_structures_from_module(self, module):
_invalid = set(["BigEndianStructure", "LittleEndianStructure", "Structure"])
_structs = set([x for x in dir(module) \
_invalid = {"BigEndianStructure", "LittleEndianStructure", "Structure"}
_structs = {x for x in dir(module) \
if inspect.isclass(getattr(module, x)) \
and issubclass(getattr(module, x), ctypes.Structure)])
and issubclass(getattr(module, x), ctypes.Structure)}
return _structs - _invalid


Expand Down Expand Up @@ -5945,7 +5941,6 @@ def set_fs(uc, addr): return set_msr(uc, FSMSR, addr)
#
# @_hugsy_
#
from __future__ import print_function
import collections
import capstone, unicorn

Expand Down Expand Up @@ -9832,9 +9827,8 @@ def get_zone_base_address(name):

return None

class GenericFunction(gdb.Function):
class GenericFunction(gdb.Function, metaclass=abc.ABCMeta):
"""This is an abstract class for invoking convenience functions, should not be instantiated."""
__metaclass__ = abc.ABCMeta

@abc.abstractproperty
def _function_(self): pass
Expand Down Expand Up @@ -10074,7 +10068,7 @@ def load(self, initial=False):
self.loaded_functions.append(function_class_name())

def is_loaded(x):
return any(filter(lambda u: x == u[0], self.loaded_commands))
return any(u for u in self.loaded_commands if x == u[0])

for cmd, class_name in self.commands:
if is_loaded(cmd):
Expand All @@ -10098,7 +10092,7 @@ def is_loaded(x):
if initial:
gef_print("{:s} for {:s} ready, type `{:s}' to start, `{:s}' to configure"
.format(Color.greenify("GEF"), get_os(),
Color.colorify("gef","underline yellow"),
Color.colorify("gef", "underline yellow"),
Color.colorify("gef config", "underline pink")))

ver = "{:d}.{:d}".format(sys.version_info.major, sys.version_info.minor)
Expand Down Expand Up @@ -10190,7 +10184,7 @@ def invoke(self, args, from_tty):

if argc == 1:
prefix = argv[0]
names = list(filter(lambda x: x.startswith(prefix), __config__.keys()))
names = [x for x in __config__.keys() if x.startswith(prefix)]
if names:
if len(names) == 1:
gef_print(titlify("GEF configuration setting: {:s}".format(names[0])))
Expand Down Expand Up @@ -10447,7 +10441,7 @@ def __init__(self, alias, command, completer_class=gdb.COMPLETE_NONE, command_cl
if not p:
return

if list(filter(lambda x: x._alias == alias, __aliases__)):
if any(x for x in __aliases__ if x._alias == alias):
return

self._command = command
Expand Down