mirror of
https://github.com/QuasarApp/pe-parse.git
synced 2025-04-26 12:24:32 +00:00
Fix some sign conversions, CI cleanup (#170)
* cmake: add -Wconversion to default flags Signed-off-by: William Woodruff <william@trailofbits.com> * workflows/ci: use ubuntu-latest Signed-off-by: William Woodruff <william@trailofbits.com> * parse: avoid an implicit conversion Signed-off-by: William Woodruff <william@trailofbits.com> * parse: use static_cast Signed-off-by: William Woodruff <william@trailofbits.com> * include/parse: remove some more implicit conversions Signed-off-by: William Woodruff <william@trailofbits.com> * parse: clang-format Signed-off-by: William Woodruff <william@trailofbits.com> * cmake: remove -Wconversion Signed-off-by: William Woodruff <william@trailofbits.com> * pepy: Python 3.7 or newer Signed-off-by: William Woodruff <william@trailofbits.com> * workflows/ci: bump actions, use pypa/build Signed-off-by: William Woodruff <william@trailofbits.com> * workflows/ci: fix windows pepy matrix Signed-off-by: William Woodruff <william@trailofbits.com> * setup: macro tweaks Signed-off-by: William Woodruff <william@trailofbits.com> * setup: escape harder Signed-off-by: William Woodruff <william@trailofbits.com> * ci, setup: drop python 3.7 This setuptools bug isn't worth working around. Signed-off-by: William Woodruff <william@trailofbits.com> * Revert "ci, setup: drop python 3.7" This reverts commit d0599831a8adc739b94f41c0ab3d2833bd0bc27e. * workflows/ci: update setuptools Signed-off-by: William Woodruff <william@trailofbits.com> * setup: remove escape Signed-off-by: William Woodruff <william@trailofbits.com>
This commit is contained in:
parent
8d8daa5ccc
commit
eecdb3d36e
54
.github/workflows/ci.yml
vendored
54
.github/workflows/ci.yml
vendored
@ -7,13 +7,13 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
# run CI every day even if no PRs/merges occur
|
# run CI every day even if no PRs/merges occur
|
||||||
- cron: '0 12 * * *'
|
- cron: '0 12 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: deps
|
- name: deps
|
||||||
run: |
|
run: |
|
||||||
@ -30,7 +30,7 @@ jobs:
|
|||||||
pe-parse:
|
pe-parse:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: ["ubuntu-18.04", "macos-latest"]
|
platform: ["ubuntu-latest", "macos-latest"]
|
||||||
build-type: ["Debug", "Release"]
|
build-type: ["Debug", "Release"]
|
||||||
build-shared: ["0", "1"]
|
build-shared: ["0", "1"]
|
||||||
compiler:
|
compiler:
|
||||||
@ -41,14 +41,9 @@ jobs:
|
|||||||
compiler: { CC: "gcc", CXX: "g++" }
|
compiler: { CC: "gcc", CXX: "g++" }
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
# https://github.com/actions/virtual-environments/issues/3376
|
|
||||||
- name: Workaround GHA Issue with GCC 11
|
|
||||||
if: matrix.compiler.CC == 'clang' && matrix.platform == 'ubuntu-18.04'
|
|
||||||
run: |
|
|
||||||
sudo apt remove libgcc-11-dev gcc-11
|
|
||||||
- name: Enable ASan+UBSan Sanitizers
|
- name: Enable ASan+UBSan Sanitizers
|
||||||
if: matrix.build-type == 'Debug'
|
if: matrix.build-type == 'Debug'
|
||||||
run: |
|
run: |
|
||||||
@ -78,27 +73,32 @@ jobs:
|
|||||||
pepy:
|
pepy:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: ["ubuntu-18.04", "macos-latest"]
|
platform: ["ubuntu-latest", "macos-latest"]
|
||||||
python:
|
python:
|
||||||
- "3.6"
|
|
||||||
- "3.7"
|
- "3.7"
|
||||||
- "3.8"
|
- "3.8"
|
||||||
|
- "3.9"
|
||||||
|
- "3.10"
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v3
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
python3 setup.py build
|
python -m pip install build wheel setuptools
|
||||||
- name: sdist and install
|
python -m build
|
||||||
|
- name: test distributions
|
||||||
run: |
|
run: |
|
||||||
python3 setup.py sdist
|
for dist in dist/*; do
|
||||||
python3 -m pip install --user dist/*.tar.gz
|
python -m venv test-env
|
||||||
- name: test
|
|
||||||
run: |
|
./test-env/bin/python -m pip install "${dist}"
|
||||||
python3 tests/test_pepy.py tests/assets/example.exe
|
./test-env/bin/python tests/test_pepy.py tests/assets/example.exe
|
||||||
|
|
||||||
|
rm -rf test-env
|
||||||
|
done
|
||||||
|
|
||||||
pe-parse-windows:
|
pe-parse-windows:
|
||||||
strategy:
|
strategy:
|
||||||
@ -108,7 +108,7 @@ jobs:
|
|||||||
build-shared: ["0", "1"]
|
build-shared: ["0", "1"]
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
- name: Enable ASan Sanitizers
|
- name: Enable ASan Sanitizers
|
||||||
@ -147,18 +147,20 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python:
|
python:
|
||||||
- "3.6"
|
|
||||||
- "3.7"
|
- "3.7"
|
||||||
- "3.8"
|
- "3.8"
|
||||||
|
- "3.9"
|
||||||
|
- "3.10"
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v3
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
python setup.py build
|
python -m pip install --upgrade build wheel setuptools
|
||||||
|
python -m build
|
||||||
- name: install
|
- name: install
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --user .
|
python -m pip install --user .
|
||||||
|
@ -40,28 +40,38 @@ THE SOFTWARE.
|
|||||||
err_loc.assign(__func__); \
|
err_loc.assign(__func__); \
|
||||||
err_loc += ":" + to_string<std::uint32_t>(__LINE__, std::dec);
|
err_loc += ":" + to_string<std::uint32_t>(__LINE__, std::dec);
|
||||||
|
|
||||||
#define READ_WORD(b, o, inst, member) \
|
#define READ_WORD(b, o, inst, member) \
|
||||||
if (!readWord(b, o + offsetof(__typeof__(inst), member), inst.member)) { \
|
if (!readWord(b, \
|
||||||
PE_ERR(PEERR_READ); \
|
o + static_cast<uint32_t>(offsetof(__typeof__(inst), member)), \
|
||||||
return false; \
|
inst.member)) { \
|
||||||
|
PE_ERR(PEERR_READ); \
|
||||||
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_DWORD(b, o, inst, member) \
|
#define READ_DWORD(b, o, inst, member) \
|
||||||
if (!readDword(b, o + offsetof(__typeof__(inst), member), inst.member)) { \
|
if (!readDword( \
|
||||||
PE_ERR(PEERR_READ); \
|
b, \
|
||||||
return false; \
|
o + static_cast<uint32_t>(offsetof(__typeof__(inst), member)), \
|
||||||
|
inst.member)) { \
|
||||||
|
PE_ERR(PEERR_READ); \
|
||||||
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_QWORD(b, o, inst, member) \
|
#define READ_QWORD(b, o, inst, member) \
|
||||||
if (!readQword(b, o + offsetof(__typeof__(inst), member), inst.member)) { \
|
if (!readQword( \
|
||||||
PE_ERR(PEERR_READ); \
|
b, \
|
||||||
return false; \
|
o + static_cast<uint32_t>(offsetof(__typeof__(inst), member)), \
|
||||||
|
inst.member)) { \
|
||||||
|
PE_ERR(PEERR_READ); \
|
||||||
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_BYTE(b, o, inst, member) \
|
#define READ_BYTE(b, o, inst, member) \
|
||||||
if (!readByte(b, o + offsetof(__typeof__(inst), member), inst.member)) { \
|
if (!readByte(b, \
|
||||||
PE_ERR(PEERR_READ); \
|
o + static_cast<uint32_t>(offsetof(__typeof__(inst), member)), \
|
||||||
return false; \
|
inst.member)) { \
|
||||||
|
PE_ERR(PEERR_READ); \
|
||||||
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_MACHINE_CHARACTERISTICS(h, m, ch) \
|
#define TEST_MACHINE_CHARACTERISTICS(h, m, ch) \
|
||||||
|
@ -1777,7 +1777,7 @@ bool getRelocations(parsed_pe *p) {
|
|||||||
// Mask out the type and assign
|
// Mask out the type and assign
|
||||||
type = entry >> 12;
|
type = entry >> 12;
|
||||||
// Mask out the offset and assign
|
// Mask out the offset and assign
|
||||||
offset = entry & ~0xf000;
|
offset = entry & static_cast<std::uint16_t>(~0xf000);
|
||||||
|
|
||||||
// Produce the VA of the relocation
|
// Produce the VA of the relocation
|
||||||
VA relocVA;
|
VA relocVA;
|
||||||
|
10
setup.py
10
setup.py
@ -60,10 +60,7 @@ if platform.system() == "Windows":
|
|||||||
os.path.abspath(os.path.join(os.path.dirname(sys.executable), "libs")),
|
os.path.abspath(os.path.join(os.path.dirname(sys.executable), "libs")),
|
||||||
"C:\\usr\\lib",
|
"C:\\usr\\lib",
|
||||||
]
|
]
|
||||||
COMPILE_ARGS = [
|
COMPILE_ARGS = ["/EHsc"]
|
||||||
"/EHsc",
|
|
||||||
f'/D"PEPARSE_VERSION=\\"{VERSION}\\""',
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
SOURCE_FILES.append(
|
SOURCE_FILES.append(
|
||||||
os.path.join(here, "pe-parser-library", "src", "unicode_codecvt.cpp")
|
os.path.join(here, "pe-parser-library", "src", "unicode_codecvt.cpp")
|
||||||
@ -75,10 +72,11 @@ else:
|
|||||||
os.path.join(here, "pe-parser-library", "include"),
|
os.path.join(here, "pe-parser-library", "include"),
|
||||||
]
|
]
|
||||||
LIBRARY_DIRS += ["/usr/lib", "/usr/local/lib"]
|
LIBRARY_DIRS += ["/usr/lib", "/usr/local/lib"]
|
||||||
COMPILE_ARGS = ["-std=c++11", f'-DPEPARSE_VERSION="{VERSION}"']
|
COMPILE_ARGS = ["-std=c++17"]
|
||||||
|
|
||||||
extension_mod = Extension(
|
extension_mod = Extension(
|
||||||
"pepy",
|
"pepy",
|
||||||
|
define_macros=[("PEPARSE_VERSION", f'"{VERSION}"')],
|
||||||
sources=SOURCE_FILES,
|
sources=SOURCE_FILES,
|
||||||
extra_compile_args=COMPILE_ARGS,
|
extra_compile_args=COMPILE_ARGS,
|
||||||
language="c++",
|
language="c++",
|
||||||
@ -89,7 +87,7 @@ extension_mod = Extension(
|
|||||||
setup(
|
setup(
|
||||||
name="pepy",
|
name="pepy",
|
||||||
url="https://github.com/trailofbits/pe-parse",
|
url="https://github.com/trailofbits/pe-parse",
|
||||||
python_requires=">= 3.6",
|
python_requires=">=3.7",
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
description="Python bindings for pe-parse",
|
description="Python bindings for pe-parse",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user