Changes os.path to pathlib.Path usage

changed args.rules , args.signatures types in handle_common_args.
This commit is contained in:
Aayush Goel
2023-07-06 05:12:50 +05:30
parent 66e2a225d2
commit c0d712acea
22 changed files with 165 additions and 173 deletions

View File

@@ -76,12 +76,12 @@ def test_ruleset_cache_save_load():
path = capa.rules.cache.get_cache_path(cache_dir, id)
try:
os.remove(path)
path.unlink()
except OSError:
pass
capa.rules.cache.cache_ruleset(cache_dir, rs)
assert os.path.exists(path)
assert path.exists()
assert capa.rules.cache.load_cached_ruleset(cache_dir, content) is not None
@@ -93,23 +93,23 @@ def test_ruleset_cache_invalid():
cache_dir = capa.rules.cache.get_default_cache_directory()
path = capa.rules.cache.get_cache_path(cache_dir, id)
try:
os.remove(path)
path.unlink()
except OSError:
pass
capa.rules.cache.cache_ruleset(cache_dir, rs)
assert os.path.exists(path)
assert path.exists()
with open(path, "rb") as f:
buf = f.read()
buf = path.read_bytes()
# corrupt the magic header
# Corrupt the magic header
buf = b"x" + buf[1:]
with open(path, "wb") as f:
f.write(buf)
# Write the modified contents back to the file
path.write_bytes(buf)
assert os.path.exists(path)
# Check if the file still exists
assert path.exists()
assert capa.rules.cache.load_cached_ruleset(cache_dir, content) is None
# the invalid cache should be deleted
assert not os.path.exists(path)
assert not path.exists()