mirror of
https://github.com/mandiant/capa.git
synced 2026-03-12 21:23:12 -07:00
Changes os.path to pathlib.Path usage
changed args.rules , args.signatures types in handle_common_args.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user