unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: soeren@soeren-tempel.net
To: 69074@debbugs.gnu.org
Cc: troy@troyfigiel.com, Lars-Dominik Braun <lars@6xq.net>,
	Marius Bakke <marius@gnu.org>,
	Munyoki Kilyungi <me@bonfacemunyoki.com>,
	Sharlatan Hellseher <sharlatanus@gmail.com>,
	jgart <jgart@dismail.de>
Subject: [bug#69074] [PATCH v2 14/14] gnu: Add python-angr.
Date: Sun, 10 Mar 2024 21:09:34 +0100	[thread overview]
Message-ID: <cfe1e1ee6829877978e1f86b8172024e70bd34ec.1710101374.git.soeren@soeren-tempel.net> (raw)
In-Reply-To: <19ef0993fd8891d02402943609f70de73e0b233a.1710101374.git.soeren@soeren-tempel.net>

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 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")




  parent reply	other threads:[~2024-03-10 20:21 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 14:55 [bug#69074] [PATCH] Add python-angr soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-itanium-demangle soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-keystone-engine soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-mulpyplexer soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-nampa soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-rpyc soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-pysmt soeren
2024-02-12 14:58 ` Troy Figiel
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-claripy soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-archinfo soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-pyvex soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-cle soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-ailment soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: unicorn: Update to 2.0.1.post1 soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: capstone: Backport upstream fix for Python bindings soeren
2024-02-12 14:58 ` [bug#69074] [PATCH] gnu: Add python-angr Troy Figiel
2024-02-12 14:58 ` soeren
2024-02-12 22:53 ` [bug#69074] [PATCH] " Troy Figiel
2024-02-13  9:53   ` [bug#69074] " Sören Tempel
2024-02-13 11:52     ` Troy Figiel
2024-02-15 21:39       ` Troy Figiel
2024-02-15 22:09         ` Troy Figiel
2024-03-01 12:02 ` Sören Tempel
2024-03-10 20:09 ` [bug#69074] [PATCH v2 01/14] gnu: Add python-itanium-demangle soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 02/14] gnu: Add python-keystone-engine soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 03/14] gnu: Add python-mulpyplexer soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 04/14] gnu: Add python-nampa soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 05/14] gnu: Add python-rpyc soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 06/14] gnu: Add python-pysmt soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 07/14] gnu: Add python-claripy soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 08/14] gnu: Add python-archinfo soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 09/14] gnu: Add python-pyvex soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 10/14] gnu: Add python-cle soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 11/14] gnu: Add python-ailment soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 12/14] gnu: unicorn: Update to 2.0.1.post1 soeren
2024-03-10 20:09   ` [bug#69074] [PATCH v2 13/14] gnu: capstone: Backport upstream fix for Python bindings soeren
2024-03-10 20:09   ` soeren [this message]
2024-03-10 20:12 ` [bug#69074] [PATCH] Add python-angr Sören Tempel
2024-03-10 22:46   ` Troy Figiel
2024-03-11  8:50     ` Sören Tempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfe1e1ee6829877978e1f86b8172024e70bd34ec.1710101374.git.soeren@soeren-tempel.net \
    --to=soeren@soeren-tempel.net \
    --cc=69074@debbugs.gnu.org \
    --cc=jgart@dismail.de \
    --cc=lars@6xq.net \
    --cc=marius@gnu.org \
    --cc=me@bonfacemunyoki.com \
    --cc=sharlatanus@gmail.com \
    --cc=troy@troyfigiel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).