Skip to content

Commit caedc99

Browse files
authored
Mypy CI setup and last fixes before release (#28)
1 parent 3983cda commit caedc99

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

.github/workflows/lint-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install flake8==3.8.3 pytest==5.4.1 black==19.10b0
24+
pip install flake8==3.8.3 pytest==5.4.1 black==19.10b0 mypy==0.782 mypy-extensions==0.4.3
2525
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2626
- name: Lint with flake8
2727
run: |
2828
flake8 malduck --count --max-line-length=88 --show-source --statistics
2929
- name: Check black format
3030
run: |
3131
black malduck --target-version py36 --check --diff
32+
- name: Check types
33+
run: |
34+
mypy malduck
3235
- name: Install
3336
run: |
3437
python setup.py install

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Improvements
1313
* Searching for wildcarded byte sequences
1414
* Support for x64 disassembly
1515
* Fixed-precision integer types
16-
* Supported both Python 2.x and 3.x
1716
* Many improvements in ProcessMemory
1817

1918
Usage

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'CERT Polska'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '3.2.0'
25+
release = '4.0.0'
2626

2727

2828
# -- General configuration ---------------------------------------------------

malduck/procmem/procmempe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _reload_as_image(self) -> None:
5050
# Reset regions
5151
if self.mapped_memory:
5252
self.close()
53-
self.memory = pe.data
53+
self.memory = bytearray(pe.data)
5454
self.imgbase = pe.optional_header.ImageBase
5555

5656
self.regions = [Region(self.imgbase, pe.headers_size, 0, 0, 0, 0)]

malduck/structure.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import ctypes
66

7+
from typing import List, Tuple, Type
8+
79
from .ints import (
810
IntTypeBase,
911
MultipliedIntTypeBase,
@@ -33,7 +35,7 @@
3335

3436
class Structure(object):
3537
_pack_ = 0
36-
_fields_ = []
38+
_fields_: List[Tuple[str, Type]] = []
3739

3840
def __init__(self):
3941
self.subfields, fields = {}, []
@@ -93,4 +95,6 @@ def from_buffer_copy(cls, buf):
9395
obj._values_ = obj.Klass.from_buffer_copy(buf)
9496
return obj
9597

96-
parse = from_buffer_copy
98+
@classmethod
99+
def parse(cls, buf):
100+
return cls.from_buffer_copy(buf)

setup.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,24 @@
22
ignore = E501,W503,E203
33
max-line-length = 88
44
exclude = tests/*
5+
6+
[mypy]
7+
python_version = 3.6
8+
9+
[mypy-capstone.*]
10+
ignore_missing_imports = True
11+
12+
[mypy-pefile.*]
13+
ignore_missing_imports = True
14+
15+
[mypy-elftools.*]
16+
ignore_missing_imports = True
17+
18+
[mypy-idautils.*]
19+
ignore_missing_imports = True
20+
21+
[mypy-idc.*]
22+
ignore_missing_imports = True
23+
24+
[mypy-ida_bytes.*]
25+
ignore_missing_imports = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="malduck",
8-
version="3.2.0",
8+
version="4.0.0",
99
description="Malduck is your ducky companion in malware analysis journeys",
1010
author="CERT Polska",
1111
author_email="[email protected]",

0 commit comments

Comments
 (0)