From f93cc2bf93ca512a50828e3b9d644be5fcb58721 Mon Sep 17 00:00:00 2001 From: lakshayletsgo <121108594+lakshayletsgo@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:25:15 +0530 Subject: [PATCH 1/3] #2119 issue: use bytes.fromhex instead of binascii --- capa/rules/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index e2f0a8102..f053de85a 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -456,7 +456,7 @@ def parse_feature(key: str): def parse_bytes(s: str) -> bytes: try: - b = codecs.decode(s.replace(" ", "").encode("ascii"), "hex") + b = bytes.fromhex(s) except binascii.Error: raise InvalidRule(f'unexpected bytes value: must be a valid hex sequence: "{s}"') From f83100e4557f64c93f91ad55bf28c4fb553fe95b Mon Sep 17 00:00:00 2001 From: lakshay Date: Wed, 31 Jul 2024 01:13:51 +0530 Subject: [PATCH 2/3] Update capa/rules/__init__.py Co-authored-by: Moritz --- capa/rules/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index f053de85a..ebda69547 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -456,7 +456,7 @@ def parse_feature(key: str): def parse_bytes(s: str) -> bytes: try: - b = bytes.fromhex(s) + b = bytes.fromhex(s.replace(" ", "")) except binascii.Error: raise InvalidRule(f'unexpected bytes value: must be a valid hex sequence: "{s}"') From 3dd79d03c0bf598aa429f5142e43a7c79d886d25 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 9 Aug 2024 11:26:03 +0200 Subject: [PATCH 3/3] remove unneeded codecs import --- capa/rules/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index ebda69547..5f567ea10 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -11,7 +11,6 @@ import re import copy import uuid -import codecs import logging import binascii import collections