From patchwork Sun Mar 10 20:09:34 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: 61612 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 7A76E27BBE2; Sun, 10 Mar 2024 20:21:51 +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=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 675F027BBE9 for ; Sun, 10 Mar 2024 20:21:49 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjPfr-0005Vb-TJ; Sun, 10 Mar 2024 16:21:35 -0400 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 1rjPfp-0005UN-Hb for guix-patches@gnu.org; Sun, 10 Mar 2024 16:21:33 -0400 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 1rjPfp-0004PP-6D; Sun, 10 Mar 2024 16:21:33 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rjPgI-0003yk-RT; Sun, 10 Mar 2024 16:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69074] [PATCH v2 14/14] 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: Sun, 10 Mar 2024 20:22:02 +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: troy@troyfigiel.com, 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.171010207515217 (code B ref 69074); Sun, 10 Mar 2024 20:22:02 +0000 Received: (at 69074) by debbugs.gnu.org; 10 Mar 2024 20:21:15 +0000 Received: from localhost ([127.0.0.1]:38053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjPfV-0003xH-S3 for submit@debbugs.gnu.org; Sun, 10 Mar 2024 16:21:14 -0400 Received: from magnesium.8pit.net ([45.76.88.171]:44758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjPVz-0003eq-V3; Sun, 10 Mar 2024 16:11:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=8+ejuSuu DQXty7ycBZS/9OlreiFk0vzd7byOeyYGvXI=; h=references:in-reply-to:date: subject:cc:to:from; d=soeren-tempel.net; b=DN2ctufMWS+vWXVlDQTv7AOjYkW 0tK0H35FlfCHs4T/9YDXvsJs/Ke9Y+8KExOJkYUE5puTAQ76G4DD3tL2Z+J0B5pvQAM68e ZVyE3G482XxDEjav3TsGpw+TtnHuIVeyie6R2YAoZy0ZM8JIh4C4MB2F1UFpems8vdi7ZM +V1Q= Received: from localhost (dynamic-2a02-3102-49da-001b-9766-31d2-bfd2-3d82.310.pool.telefonica.de [2a02:3102:49da:1b:9766:31d2:bfd2:3d82]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 55f0c4f6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sun, 10 Mar 2024 21:10:45 +0100 (CET) From: soeren@soeren-tempel.net Date: Sun, 10 Mar 2024 21:09:34 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: <19ef0993fd8891d02402943609f70de73e0b233a.1710101374.git.soeren@soeren-tempel.net> References: <19ef0993fd8891d02402943609f70de73e0b233a.1710101374.git.soeren@soeren-tempel.net> 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/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 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 7c85404c2a..f4b0501187 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -32577,6 +32577,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")