You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use absolute imports to allow separate modules to run independently without having to manually specify the package via python3 -m.
In exception scenarios, use logging.Logger.exception() that automatically attaches the relevant traceback, instead of manually concatenating it to the log message on the ERROR logging level.
Generally use isinstance(x, T) and issubclass(X, T) instead of raw type(X) is/== type(T) comparisons in order to follow the Liskov substitution principle. Document exceptional cases.
Consistently use ABC/ABCMeta for abstract classes.
Use f"{obj!r}" instead of f"'{obj}'".
Use %-style formatting in logging.
Delivery plan
The fixes from the Refactor section require the most analysis. Those will be delivered in a PR after the first PR (Modernize, Reformat, Improve performance) is accepted and merged.
Refactoring might potentially require re-adjusting the test suite. That PR should be based on the initially-improved codebase to ensure an insightful code review and avoid merge conflicts.
A series of PRs will land shortly. π
General overview
class T(object):
βclass T:
.typing.List
,typing.Dict
etc. See PEP 585 and typing docs on built-in types aliases.X | Y
union type syntax.typing.TYPE_CHECKING
to separate typing-related imports from the actual runtime requirements.super()
inside methods.Path(...).read_(text|bytes)()
andPath(...).write_(text|bytes)()
instead of theopen()
context manager where possible.f"{i:x}"
instead ofhex(i)[2:]
. Act analogically for other numeral systems. More information here.map
/filter
where applicable.type(X)
instead ofX.__class__
where the__class__
's descriptor behavior doesn't matter.StopIteration
when usingnext()
, simply pass a default value as the other argument.mypy malduck --strict
to pass.Exception
.typing.NamedTuple
instead ofcollections.namedtuple
.python3 -m
.logging.Logger.exception()
that automatically attaches the relevant traceback, instead of manually concatenating it to the log message on theERROR
logging level.isinstance(x, T)
andissubclass(X, T)
instead of rawtype(X) is/== type(T)
comparisons in order to follow the Liskov substitution principle. Document exceptional cases.ABC
/ABCMeta
for abstract classes.f"{obj!r}"
instead off"'{obj}'"
.Delivery plan
The fixes from the Refactor section require the most analysis. Those will be delivered in a PR after the first PR (Modernize, Reformat, Improve performance) is accepted and merged.
Refactoring might potentially require re-adjusting the test suite. That PR should be based on the initially-improved codebase to ensure an insightful code review and avoid merge conflicts.
Measuring quality assurance
ruff check malduck --select=ALL
,ruff format malduck --check --select=ALL
,mypy malduck --strict
.Progress
malduck
__init__.py
bits.py
compression/
__init__.py
aplib.py
components/
__init__.py
aplib.py
lznt1.py
gzip.py
lznt1.py
crypto/
__init__.py
aes.py
blowfish.py
camellia.py
chacha20.py
components/
__init__.py
pyserpent.py
des3.py
rabbit.py
rc.py
rsa.py
salsa20.py
serpent.py
winhdr.py
xor.py
disasm.py
dnpe.py
extractor/
__init__.py
config_utils.py
extract_manager.py
extractor.py
extractor.pyi
modules.py
hash/
__init__.py
crc.py
sha.py
ints.py
main.py
pe.py
procmem/
__init__.py
binmem.py
cuckoomem.py
idamem.py
procmem.py
procmem.pyi
procmemdnpe.py
procmemelf.py
procmempe.py
region.py
py.typed
string/
__init__.py
bin.py
inet.py
ops.py
structure.py
verify.py
yara.py
yara.pyi
The text was updated successfully, but these errors were encountered: