Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit e3c062d

Browse files
committed
Fix build failures
1 parent 405a9b2 commit e3c062d

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

Diff for: tests/test_import.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
class TestImport(unittest.TestCase):
1010
system: BaseSystem
11-
zip_path: str
1211

1312
@classmethod
1413
def setUpClass(cls) -> None:
1514
cls.system = acquire_system()
16-
cls.zip_path = cls.system.acquire_volatile()
15+
cls.system.acquire_volatile()
1716

1817
@classmethod
1918
def tearDownClass(cls) -> None:
@@ -29,5 +28,5 @@ def test_get_network(self) -> None:
2928

3029
def test_got_files(self) -> None:
3130
# Check we got atleast 10 files
32-
with ZipFile(self.zip_path) as z:
31+
with ZipFile(self.system.output_path) as z:
3332
self.assertGreater(len(z.namelist()), 10)

Diff for: tests/test_linux/test_base.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55

66
class TestBaseCases(unittest.TestCase):
77
system: BaseSystem
8-
zip_path: str
98

109
@classmethod
1110
def setUpClass(cls) -> None:
1211
cls.system = acquire_system()
13-
cls.zip_path = cls.system.acquire_volatile()
12+
cls.system.acquire_volatile()
1413

1514

16-
@classmethod
17-
def tearDownClass(cls) -> None:
18-
pass
19-
2015
def test_some_processes(self) -> None:
2116
processes = self.system.get_processes()
2217
self.assertTrue(len(processes) > 0)
@@ -28,7 +23,7 @@ def test_dump_files(self) -> None:
2823
open_files = self.system.dump_loaded_files()
2924
self.assertTrue(len(open_files) > 0)
3025
# Check we pulled at least one file from /bin/
31-
with ZipFile(self.zip_path) as z:
26+
with ZipFile(self.system.output_path) as z:
3227
binary_files = [binary for binary in z.namelist() if ("/bin/" in binary in binary.lower())]
3328
self.assertGreater(len(binary_files), 0)
3429

Diff for: tests/test_shared.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
class TestBaseCases(unittest.TestCase):
88
system: BaseSystem
9-
zip_path: str
109

1110
@classmethod
1211
def setUpClass(cls) -> None:
1312
cls.system = acquire_system()
14-
cls.zip_path = cls.system.acquire_volatile()
13+
cls.system.acquire_volatile()
1514

1615
@classmethod
1716
def tearDownClass(cls) -> None:
@@ -27,5 +26,5 @@ def test_get_network(self) -> None:
2726

2827
def test_got_files(self) -> None:
2928
# Check we got atleast 10 files
30-
with ZipFile(self.zip_path) as z:
29+
with ZipFile(self.system.output_path) as z:
3130
self.assertGreater(len(z.namelist()), 10)

Diff for: varc_core/systems/base_system.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import zipfile
1919
from base64 import b64encode
2020
from datetime import datetime
21-
from typing import Any, List, Optional
21+
from typing import IO, Any, List, Optional, Union
2222

2323
import lz4.frame
2424
import mss
@@ -40,12 +40,12 @@ class _TarLz4Wrapper:
4040

4141
def __init__(self, path) -> None:
4242
self._lz4 = lz4.frame.open(path, 'wb')
43-
self._tar = tarfile.open(fileobj=self._lz4f, mode="w")
43+
self._tar = tarfile.open(fileobj=self._lz4, mode="w")
4444

45-
def writestr(self, path: str, value: str | bytes):
45+
def writestr(self, path: str, value: Union[str, bytes]):
4646
info = tarfile.TarInfo(path)
4747
info.size = len(value)
48-
self._tar.addfile(info, io.BytesIO(value))
48+
self._tar.addfile(info, io.BytesIO(value if isinstance(value, bytes) else value.encode()))
4949

5050
def write(self, path: str, arcname: str):
5151
self._tar.add(path, arcname)
@@ -339,7 +339,7 @@ def acquire_volatile(self) -> None:
339339
except FileNotFoundError:
340340
logging.warning(f"Could not open {file_path} for reading")
341341

342-
def _open_output(self) -> zipfile.ZipFile | _TarLz4Wrapper:
342+
def _open_output(self) -> Union[zipfile.ZipFile, _TarLz4Wrapper]:
343343
if self.output_path.endswith('.tar.lz4'):
344344
return _TarLz4Wrapper(self.output_path)
345345
else:

0 commit comments

Comments
 (0)