From patchwork Mon Feb 12 14:58:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Tempel?= X-Patchwork-Id: 60204 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B1BF027BBE9; Mon, 12 Feb 2024 15:11:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id ACCFF27BBE2 for ; Mon, 12 Feb 2024 15:11:37 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZXxL-0000vM-0G; Mon, 12 Feb 2024 10:10:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZXxJ-0000ul-La for guix-patches@gnu.org; Mon, 12 Feb 2024 10:10:49 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZXxJ-0006HY-D9; Mon, 12 Feb 2024 10:10:49 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZXxZ-0001x5-11; Mon, 12 Feb 2024 10:11:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69074] [PATCH] gnu: Add python-angr. Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, marius@gnu.org, me@bonfacemunyoki.com, sharlatanus@gmail.com, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Mon, 12 Feb 2024 15:11:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69074 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69074@debbugs.gnu.org Cc: Lars-Dominik Braun , Marius Bakke , Munyoki Kilyungi , Sharlatan Hellseher , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , Marius Bakke , Munyoki Kilyungi , Sharlatan Hellseher , jgart Received: via spool by 69074-submit@debbugs.gnu.org id=B69074.17077506227296 (code B ref 69074); Mon, 12 Feb 2024 15:11:04 +0000 Received: (at 69074) by debbugs.gnu.org; 12 Feb 2024 15:10:22 +0000 Received: from localhost ([127.0.0.1]:35933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZXwr-0001tS-BM for submit@debbugs.gnu.org; Mon, 12 Feb 2024 10:10:22 -0500 Received: from magnesium.8pit.net ([2001:19f0:6c01:4ae:5400:ff:fe66:af9d]:2956) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZXm9-0006m9-6r; Mon, 12 Feb 2024 09:59:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=KsSjqFrES5 19CwEacsO0SkFgYJ1eq+Z+kCvVrxx0YJQ=; h=references:in-reply-to:date: subject:to:from; d=soeren-tempel.net; b=vMj/3WShRqBoQ2hPwC7f7luxr2M7x8 ekw+KNL+vdQrlsQAOu6FDB10trelFpj2KNDpkyVFIgPnxesWtMw70TEKUF1matsp0tQrHN JXTzUrrx44KWT99rlc8mwlZQabc9VSaxRUUQFBmd63RJjFpV29zx1zrAnaTnKuL0B/gaZ7 8= Received: from localhost (dynamic-2a02-3102-49da-001b-6371-147f-665b-ad6e.310.pool.telefonica.de [2a02:3102:49da:1b:6371:147f:665b:ad6e]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id fe00d855 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Mon, 12 Feb 2024 15:58:54 +0100 (CET) From: soeren@soeren-tempel.net Date: Mon, 12 Feb 2024 15:58:29 +0100 Message-ID: <2d88c47aba75ad57d3e4c5aa341a975d5109c376.1707749005.git.soeren@soeren-tempel.net> X-Mailer: git-send-email 2.43.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Sören Tempel * 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 ce0f1994c5..8bbf66cc1e 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1899,6 +1899,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 92c08020fb..902312584a 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -189,6 +189,7 @@ (define-module (gnu packages python-xyz) #:use-module (gnu packages djvu) #:use-module (gnu packages docker) #:use-module (gnu packages documentation) + #:use-module (gnu packages emulators) #:use-module (gnu packages engineering) #:use-module (gnu packages enchant) #:use-module (gnu packages file) @@ -32390,6 +32391,101 @@ (define-public python-pyvex to enable all kinds of binary analysis tasks.") (license license:bsd-2))) +(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") + (string-append coreutils "/bin/false"))) + (substitute* "tests/common.py" + (("\\[\"cc\"\\]") + "[\"gcc\"]"))))) + (replace 'check + (lambda* (#:key inputs tests? #:allow-other-keys) + (when tests? + (copy-recursively (assoc-ref inputs "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. + (invoke "pytest" "-vv" "-x" "--dist" "loadfile" + "-k" "not test_mips32_missing_offset_in_instructions" + "-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-capstone + 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-archinfo (package (name "python-archinfo")