c34dab2cca
Build and Push Docker Container / build-and-push (push) Successful in 4m28s
- Create missing note files before running property:set. - Default date-only datetime values to midnight. - Keep property names out of path authorization checks. - Split policy, vault, daily note, and command target helpers. - Split n8n node args, description, output, and API response helpers. - Split API tests by auth, command, daily note, and property behavior. - Bump API and n8n node versions.
25 lines
900 B
Python
25 lines
900 B
Python
def normalize_policy_path(value:str) -> str:
|
|
normalized = value.strip().replace("\\", "/").lstrip("/")
|
|
while "//" in normalized:
|
|
normalized = normalized.replace("//", "/")
|
|
return normalized
|
|
|
|
def is_path_allowed(path:str, allowed_patterns:tuple[str, ...]) -> bool:
|
|
normalized = normalize_policy_path(path)
|
|
|
|
for pattern in allowed_patterns:
|
|
pattern_normalized = normalize_policy_path(pattern)
|
|
if pattern_normalized == "*":
|
|
return True
|
|
if pattern_normalized.endswith("/**"):
|
|
prefix = pattern_normalized[:-3].rstrip("/")
|
|
if normalized == prefix or normalized.startswith(prefix + "/"):
|
|
return True
|
|
elif pattern_normalized.endswith("/"):
|
|
if normalized.startswith(pattern_normalized):
|
|
return True
|
|
elif normalized == pattern_normalized or normalized.startswith(pattern_normalized.rstrip("/") + "/"):
|
|
return True
|
|
|
|
return False
|