Example #1
0
def test_secure_delete_capability(config):
    assert rm.check_secure_delete_capability() is True

    path = os.environ["PATH"]
    try:
        os.environ["PATH"] = "{}".format(config.TEMP_DIR)
        assert rm.check_secure_delete_capability() is False
        fakeshred = os.path.join(config.TEMP_DIR, "shred")
        with open(fakeshred, "w") as f:
            f.write("#!/bin/bash\nexit 1\n")
        os.chmod(fakeshred, 0o700)
        assert rm.check_secure_delete_capability() is False
    finally:
        os.environ["PATH"] = path
Example #2
0
    def __init__(self, storage_path: str, temp_dir: str) -> None:
        if not os.path.isabs(storage_path):
            raise PathException("storage_path {} is not absolute".format(storage_path))
        self.__storage_path = storage_path

        if not os.path.isabs(temp_dir):
            raise PathException("temp_dir {} is not absolute".format(temp_dir))
        self.__temp_dir = temp_dir

        # where files and directories are sent to be securely deleted
        self.__shredder_path = os.path.abspath(os.path.join(self.__storage_path, "../shredder"))
        os.makedirs(self.__shredder_path, mode=0o700, exist_ok=True)

        # crash if we don't have a way to securely remove files
        if not rm.check_secure_delete_capability():
            raise AssertionError("Secure file deletion is not possible.")
Example #3
0
 def do_runtime_tests(self) -> None:
     if self.scrypt_id_pepper == self.scrypt_gpg_pepper:
         raise AssertionError('scrypt_id_pepper == scrypt_gpg_pepper')
     # crash if we don't have a way to securely remove files
     if not rm.check_secure_delete_capability():
         raise AssertionError("Secure file deletion is not possible.")