[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#69074] [PATCH v3 14/14] gnu: Add python-angr.
From: |
soeren |
Subject: |
[bug#69074] [PATCH v3 14/14] gnu: Add python-angr. |
Date: |
Thu, 4 Jul 2024 22:05:23 +0200 |
From: Sören Tempel <soeren@soeren-tempel.net>
* gnu/packages/patches/python-angr-addition-type-error.patch:
New patch.
* gnu/packages/patches/python-angr-check-exec-deps.patch:
New patch.
* gnu/local.mk (dist_patch_DATA): Add them.
* gnu/packages/python-xyz.scm (python-angr): New variable.
---
gnu/local.mk | 2 +
.../python-angr-addition-type-error.patch | 18 ++++
.../patches/python-angr-check-exec-deps.patch | 93 ++++++++++++++++++
gnu/packages/python-xyz.scm | 96 +++++++++++++++++++
4 files changed, 209 insertions(+)
create mode 100644 gnu/packages/patches/python-angr-addition-type-error.patch
create mode 100644 gnu/packages/patches/python-angr-check-exec-deps.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index d41f635b73..faf278ba44 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1945,6 +1945,8 @@ dist_patch_DATA =
\
%D%/packages/patches/python-3-search-paths.patch \
%D%/packages/patches/python-3-fix-tests.patch \
%D%/packages/patches/python-3-hurd-configure.patch \
+ %D%/packages/patches/python-angr-addition-type-error.patch \
+ %D%/packages/patches/python-angr-check-exec-deps.patch \
%D%/packages/patches/python-aionotify-0.2.0-py3.8.patch \
%D%/packages/patches/python-argcomplete-1.11.1-fish31.patch \
%D%/packages/patches/python-capstone-fix-python-constants.patch \
diff --git a/gnu/packages/patches/python-angr-addition-type-error.patch
b/gnu/packages/patches/python-angr-addition-type-error.patch
new file mode 100644
index 0000000000..7301d8b505
--- /dev/null
+++ b/gnu/packages/patches/python-angr-addition-type-error.patch
@@ -0,0 +1,18 @@
+This fixes failures of the test_ln_gcc_O2 and other related tests
+in the angr test suite. The patch has been proposed upstream.
+
+Taken form: https://github.com/angr/angr/pull/4443
+
+diff --git a/angr/analyses/reassembler.py b/angr/analyses/reassembler.py
+index 7a2399a60..b09b3a8cb 100644
+--- a/angr/analyses/reassembler.py
++++ b/angr/analyses/reassembler.py
+@@ -730,7 +730,7 @@ class Instruction:
+ elif operand.type == capstone.CS_OP_MEM:
+ operand_offsets.append(capstone_instr.disp_offset)
+ else:
+- operand_offsets.append(None)
++ operand_offsets.append(0)
+
+ if self.addr is not None:
+ self._initialize(capstone_instr.operands, operand_offsets)
diff --git a/gnu/packages/patches/python-angr-check-exec-deps.patch
b/gnu/packages/patches/python-angr-check-exec-deps.patch
new file mode 100644
index 0000000000..438f8ef183
--- /dev/null
+++ b/gnu/packages/patches/python-angr-check-exec-deps.patch
@@ -0,0 +1,93 @@
+The angr test suite performs analysis on several pre-compiled binaries
+to ensure its binary analysis capabilities are working as intended.
+Some of these binaries are also executed as part of the test suite to
+test if the simulation engine provided by angr results in the same
+output as native execution of the binary.
+
+For Guix, this files as the glibc shared objects cannot be found.
+Additionally, we don't really want to execute pre-compiled binaries
+on Guix, hence we disable those tests.
+
+diff --git a/tests/test_ctype_locale.py b/tests/test_ctype_locale.py
+index 08cb89836..2b9233558 100644
+--- a/tests/test_ctype_locale.py
++++ b/tests/test_ctype_locale.py
+@@ -14,7 +14,7 @@ test_location = os.path.dirname(os.path.abspath(__file__))
+
+
+ class TestCtypeLocale(unittest.TestCase):
+- @skip_if_not_linux
++ @unittest.skip("test executes pre-compiled binaries")
+ def test_ctype_b_loc(self):
+ """
+ test_ctype_locale.test_ctype_b_loc
+@@ -60,7 +60,7 @@ class TestCtypeLocale(unittest.TestCase):
+ output = subprocess.check_output(bin_path, shell=True)
+ assert result == output
+
+- @skip_if_not_linux
++ @unittest.skip("test executes pre-compiled binaries")
+ def test_ctype_tolower_loc(self):
+ """
+ test_ctype_locale.test_ctype_tolower_loc
+@@ -109,7 +109,7 @@ class TestCtypeLocale(unittest.TestCase):
+ output = subprocess.check_output(bin_path, shell=True)
+ assert result == output
+
+- @skip_if_not_linux
++ @unittest.skip("test executes pre-compiled binaries")
+ def test_ctype_toupper_loc(self):
+ """
+ test_ctype_locale.test_ctype_toupper_loc
+diff --git a/tests/test_signed_div.py b/tests/test_signed_div.py
+index 59cb9b8d1..994ed9c65 100644
+--- a/tests/test_signed_div.py
++++ b/tests/test_signed_div.py
+@@ -1,6 +1,7 @@
+ import angr
+ import subprocess
+ import sys
++import pytest
+
+ import logging
+
+@@ -13,7 +14,7 @@ import os
+ test_location = os.path.dirname(os.path.realpath(__file__))
+
+
+-@skipUnless(sys.platform.startswith("linux"), "linux only")
++@pytest.mark.skip(reason="test executes pre-compiled binaries")
+ def test_signed_div():
+ test_bin = os.path.join(test_location, "..", "..", "binaries", "tests",
"x86_64", "test_signed_div")
+ b = angr.Project(test_bin, auto_load_libs=False)
+diff --git a/tests/test_sscanf.py b/tests/test_sscanf.py
+index 29d2c8403..ea799b310 100644
+--- a/tests/test_sscanf.py
++++ b/tests/test_sscanf.py
+@@ -1,3 +1,4 @@
++import pytest
+ import angr
+ import subprocess
+ import sys
+@@ -14,7 +15,7 @@ test_location = os.path.dirname(os.path.realpath(__file__))
+
+
+ class TestSscanf(unittest.TestCase):
+- @unittest.skipUnless(sys.platform.startswith("linux"), "linux only")
++ @unittest.skip("test executes pre-compiled binaries")
+ def test_sscanf(self):
+ test_bin = os.path.join(test_location, "..", "..", "binaries",
"tests", "x86_64", "sscanf_test")
+ b = angr.Project(test_bin, auto_load_libs=False)
+diff --git a/tests/test_strtol.py b/tests/test_strtol.py
+index 6c29cab22..f36181407 100644
+--- a/tests/test_strtol.py
++++ b/tests/test_strtol.py
+@@ -11,7 +11,7 @@ class TestStrtol(unittest.TestCase):
+ # pylint: disable=no-self-use
+
+ @slow_test
+- @unittest.skipUnless(sys.platform.startswith("linux"), "linux-only")
++ @unittest.skip("test executes pre-compiled binaries")
+ def test_strtol(self, threads=None):
+ test_bin = os.path.join(bin_location, "tests", "x86_64",
"strtol_test")
+ # disabling auto_load_libs increases the execution time of the test
case.
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 6797bba3bd..0e423c9f64 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -34079,6 +34079,102 @@ (define-public python-itanium-demangle
extracting type information.")
(license license:bsd-0)))
+(define-public python-angr
+ (package
+ (name "python-angr")
+ (version "9.2.46")
+ (source
+ (origin
+ (method git-fetch)
+ (patches (search-patches "python-angr-addition-type-error.patch"
+ "python-angr-check-exec-deps.patch"))
+ (uri (git-reference
+ (url "https://github.com/angr/angr")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "18y9wyf7va7gvp9zd6lhw82j9a2x2ajsvbawh96xnxzml0jwlwjm"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:phases #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-tests
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((coreutils (assoc-ref inputs "coreutils")))
+ (substitute* "tests/test_vault.py"
+ (("/bin/false")
+ (which "false")))
+ (substitute* "tests/common.py"
+ (("\\[\"cc\"\\]")
+ "[\"gcc\"]")))))
+ (replace 'check
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (when tests?
+ (copy-recursively #$(this-package-native-input
"binaries")
+ "../binaries")
+ (with-directory-excursion "tests"
+ ;; test_mips32_missing_offset_in_instructions fails
+ ;; with capstone 5 and passes with capstone 4. Might
+ ;; be a capstone regressions, needs investigation.
+ ;;
+ ;; test_concrete_memset is a non-deterministic
benchmark.
+ (invoke "pytest" "-vv" "-x" "--dist" "loadfile"
+ "-k" "not
test_mips32_missing_offset_in_instructions and not test_concrete_memset"
+ "-n" (number->string
(parallel-job-count)))))))
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC" "gcc"))))))
+ (propagated-inputs (list python-ailment
+ python-archinfo
+ python-cachetools
+ python-cffi
+ python-claripy
+ python-cle
+ python-colorama
+ python-cppheaderparser
+ python-dpkt
+ python-gitpython
+ python-mulpyplexer
+ python-nampa
+ python-networkx
+ python-protobuf
+ python-psutil
+ python-itanium-demangle
+ python-pycparser
+ python-pyvex
+ python-progressbar2
+ python-rpyc
+ python-sortedcontainers
+ python-sqlalchemy
+ python-sympy
+ unicorn))
+ (native-inputs `(("python-pytest" ,python-pytest)
+ ("python-pytest-xdist" ,python-pytest-xdist)
+ ("binaries"
+ ;; This repository ships several binaries used only for
testing
+ ;; purpose. The binaries are not executed and not part
of the
+ ;; angr distribution, they are only used to test angr's
binary
+ ;; analysis capabilities. In the context of the GNU
FSDG, these
+ ;; files should be considered non-functional data.
+ ,(origin
+ (method git-fetch)
+ (uri (git-reference (url
+
"https://github.com/angr/binaries")
+ (commit (string-append "v"
+ version))))
+ (file-name (git-file-name "angr-binaries" version))
+ (sha256 (base32
+
"1f286b2239zavxzwg1184hj1zs380cr9qr549mvy3vywvm8bsmgr"))))))
+ (home-page "https://github.com/angr/angr")
+ (synopsis "Multi-architecture binary analysis toolkit")
+ (description
+ "This package provides a versatile binary analysis platform with the
+ability to perform dynamic symbolic execution as well as various
+static analyses directly on binaries. As such, it can be used for all
+kinds of reverse engineering, vulnerability discovery, exploit
+generation, and software testing purposes.")
+ (license license:bsd-2)))
+
(define-public python-peachpy
;; There is no tag in this repo.
(let ((commit "913d74c35a6b1d330e90bfc055208ce5b06b35a0")
- [bug#69074] [PATCH v3 03/14] gnu: Add python-mulpyplexer., (continued)
- [bug#69074] [PATCH v3 03/14] gnu: Add python-mulpyplexer., soeren, 2024/07/04
- [bug#69074] [PATCH v3 04/14] gnu: Add python-nampa., soeren, 2024/07/04
- [bug#69074] [PATCH v3 08/14] gnu: Add python-archinfo., soeren, 2024/07/04
- [bug#69074] [PATCH v3 12/14] gnu: unicorn: Update to 2.0.1.post1., soeren, 2024/07/04
- [bug#69074] [PATCH v3 06/14] gnu: Add python-pysmt., soeren, 2024/07/04
- [bug#69074] [PATCH v3 13/14] gnu: capstone: Backport upstream fix for Python bindings., soeren, 2024/07/04
- [bug#69074] [PATCH v3 07/14] gnu: Add python-claripy., soeren, 2024/07/04
- [bug#69074] [PATCH v3 11/14] gnu: Add python-ailment., soeren, 2024/07/04
- [bug#69074] [PATCH v3 10/14] gnu: Add python-cle., soeren, 2024/07/04
- [bug#69074] [PATCH v3 09/14] gnu: Add python-pyvex., soeren, 2024/07/04
- [bug#69074] [PATCH v3 14/14] gnu: Add python-angr.,
soeren <=