Rename "required" permissions to "expected" permissions

This commit is contained in:
Shreya 2021-06-07 13:21:51 +05:30
parent 53a126482f
commit 4ad49d19c7
1 changed files with 3 additions and 3 deletions

View File

@ -9,14 +9,14 @@ def ensure_file_existence(file: str) -> None:
def ensure_file_permissions(file: str) -> None:
if not file_has_sufficient_permissions(path=file, required_permissions="0o400"):
if not file_has_expected_permissions(path=file, expected_permissions="0o400"):
raise InsecurePermissionsError(
f"{file} has insecure permissions. Required permissions: r--------. Exiting."
)
def file_has_sufficient_permissions(path: str, required_permissions: str) -> bool:
def file_has_expected_permissions(path: str, expected_permissions: str) -> bool:
file_mode = os.stat(path).st_mode
file_permissions = oct(file_mode & 0o777)
return file_permissions == required_permissions
return file_permissions == expected_permissions