Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 79 additions & 37 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,25 +397,34 @@
return text


def is_valid_profile_id_format(profile_id: str) -> bool:
if not re.match(r"^[a-zA-Z0-9_-]+$", profile_id):
return False
if len(profile_id) > 64:
def validate_resource_id(
resource_id: str, type_name: str = "ID", log_errors: bool = True

Check warning

Code scanning / Pylint (reported by Codacy)

Wrong hanging indentation before block (add 4 spaces). Warning

Wrong hanging indentation before block (add 4 spaces).
) -> bool:
Comment on lines +400 to +402

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type hint for resource_id is str, but the function's logic correctly handles None and the new tests pass None as a valid input. To align the function signature with its implementation and tests, and to satisfy static type checkers, the type hint should be changed to Optional[str]. The Optional type is already imported in this file.

Suggested change
def validate_resource_id(
resource_id: str, type_name: str = "ID", log_errors: bool = True
) -> bool:
def validate_resource_id(
resource_id: Optional[str], type_name: str = "ID", log_errors: bool = True
) -> bool:

"""
Validates a resource ID (Profile ID, Folder ID/PK).
Allowed: Alphanumeric, hyphen, underscore.
Max Length: 64
"""
if not resource_id:

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning

Missing function docstring
return False
return True

if len(resource_id) > 64:
if log_errors:
log.error(f"Invalid {type_name} length (max 64 chars)")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
return False

def validate_profile_id(profile_id: str, log_errors: bool = True) -> bool:
if not is_valid_profile_id_format(profile_id):
if not re.match(r"^[a-zA-Z0-9_-]+$", resource_id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The regular expression used for validation uses the $ anchor, which in Python's re module matches the end of the string or the position just before a newline at the end of the string. This allows an ID with a trailing newline (e.g., "abc\n") to pass validation, even though the newline character is not in the allowed character set [a-zA-Z0-9_-]. Since these IDs are used to construct API URLs (e.g., in delete_folder and list_existing_folders), an ID with a newline could lead to CRLF injection or malformed HTTP requests. It is recommended to use re.fullmatch() to ensure the entire string matches the allowed character set.

Suggested change
if not re.match(r"^[a-zA-Z0-9_-]+$", resource_id):
if not re.fullmatch(r"[a-zA-Z0-9_-]+", resource_id):

Comment on lines +411 to +416
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate_resource_id assumes resource_id is a string, but it is called with raw PK values from JSON in list_existing_folders, so if the API ever returns a non-string (e.g., numeric PK), this len()/re.match() path will raise a TypeError instead of cleanly rejecting the ID. To make this defensive validator robust against unexpected types, consider coercing resource_id to str (or explicitly checking isinstance(resource_id, str) and returning False for non-strings) before the length and regex checks.

Copilot uses AI. Check for mistakes.
if log_errors:
if not re.match(r"^[a-zA-Z0-9_-]+$", profile_id):
log.error("Invalid profile ID format (contains unsafe characters)")
elif len(profile_id) > 64:
log.error("Invalid profile ID length (max 64 chars)")
log.error(f"Invalid {type_name} format (contains unsafe characters)")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
return False

return True


def validate_profile_id(profile_id: str, log_errors: bool = True) -> bool:
return validate_resource_id(profile_id, "profile ID", log_errors)


def is_valid_rule(rule: str) -> bool:
"""
Validates that a rule is safe to use.
Expand All @@ -436,15 +445,17 @@
def is_valid_folder_name(name: str) -> bool:
"""
Validates folder name to prevent XSS and ensure printability.
Allowed: Anything printable except < > " ' `
Allowed: Alphanumeric, space, hyphen, dot, underscore, parens, brackets, braces.
Max Length: 64
"""
if not name or not name.strip() or not name.isprintable():
return False

# Block XSS and HTML injection characters
# Allow: ( ) [ ] { } for folder names (e.g. "Work (Private)")
dangerous_chars = set("<>\"'`")
if any(c in dangerous_chars for c in name):
if len(name) > 64:
return False

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

# Whitelist: Alphanumeric, space, hyphen, dot, underscore, parens, brackets, braces
if not re.match(r"^[a-zA-Z0-9 \-_.()\[\]{}]+$", name):
return False

return True
Expand All @@ -461,7 +472,7 @@
return False
if not isinstance(data["group"], dict):
log.error(
f"Invalid data from {sanitize_for_log(url)}: 'group' must be an object."

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
)
return False
if "group" not in data["group"]:
Expand Down Expand Up @@ -627,11 +638,18 @@
try:
data = _api_get(client, f"{API_BASE}/{profile_id}/groups").json()
folders = data.get("body", {}).get("groups", [])
return {
f["group"].strip(): f["PK"]
for f in folders
if f.get("group") and f.get("PK")
}
result = {}
for f in folders:

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "f" doesn't conform to snake_case naming style Warning

Variable name "f" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "f" doesn't conform to snake_case naming style Warning

Variable name "f" doesn't conform to snake_case naming style
name = f.get("group")
pk = f.get("PK")

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style
if name and pk:
if validate_resource_id(pk, "Folder PK", log_errors=False):
result[name.strip()] = pk
else:
log.warning(
f"Skipping folder '{sanitize_for_log(name)}' with unsafe PK: {sanitize_for_log(pk)}"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (108/100) Warning

Line too long (108/100)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (108/100) Warning

Line too long (108/100)
)
Comment on lines +641 to +651
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new defense-in-depth logic in list_existing_folders that filters out folders with unsafe PKs and logs a warning is not covered by tests; current tests only exercise validate_resource_id in isolation. Given the security focus of this change and existing coverage for other main.py behaviors, consider adding tests that simulate folder lists containing valid and invalid PKs to verify that valid entries are kept, invalid ones are skipped, and the appropriate log warnings are emitted.

Copilot uses AI. Check for mistakes.
return result
except (httpx.HTTPError, KeyError) as e:
log.error(f"Failed to list existing folders: {sanitize_for_log(e)}")
return {}
Expand Down Expand Up @@ -725,7 +743,7 @@
return None

completed = 0
with concurrent.futures.ThreadPoolExecutor() as executor:

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
futures = {
executor.submit(_validate_and_fetch, url): url for url in urls_to_process
}
Expand All @@ -746,7 +764,7 @@
log.warning(
f"Failed to pre-fetch {sanitize_for_log(futures[future])}: {e}"
)
# Restore progress bar after warning

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
render_progress_bar(completed, total, "Warming up cache", prefix="⏳")

if USE_COLORS:
Expand All @@ -759,6 +777,10 @@
def delete_folder(
client: httpx.Client, profile_id: str, name: str, folder_id: str
) -> bool:
if not validate_resource_id(folder_id, "Folder ID to delete"):
log.error(f"Aborting deletion of {sanitize_for_log(name)}: Unsafe Folder ID")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
return False
Comment on lines +780 to +782
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new pre-validation in delete_folder that aborts when folder_id fails validate_resource_id is not covered by tests, so regressions here could go unnoticed (e.g., if validation is accidentally relaxed or removed). It would be helpful to add tests that call delete_folder with both valid and invalid folder IDs, asserting that invalid IDs trigger the early False return and log the expected error without invoking _api_delete.

Copilot uses AI. Check for mistakes.

try:
_api_delete(client, f"{API_BASE}/{profile_id}/groups/{folder_id}")
log.info("Deleted folder %s (ID %s)", sanitize_for_log(name), folder_id)
Expand All @@ -770,44 +792,57 @@
return False


def create_folder(
client: httpx.Client, profile_id: str, name: str, do: int, status: int
) -> Optional[str]:
"""
Create a new folder and return its ID.
Attempts to read ID from response first, then falls back to polling.
"""
try:
# 1. Send the Create Request
response = _api_post(
client,
f"{API_BASE}/{profile_id}/groups",
data={"name": name, "do": do, "status": status},
)

# OPTIMIZATION: Try to grab ID directly from response to avoid the wait loop
try:
resp_data = response.json()
body = resp_data.get("body", {})

# Check if it returned a single group object
if isinstance(body, dict) and "group" in body and "PK" in body["group"]:
pk = body["group"]["PK"]
log.info(
"Created folder %s (ID %s) [Direct]", sanitize_for_log(name), pk
)
return str(pk)
if validate_resource_id(str(pk), "New Folder PK"):

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Pylint (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Prospector (reported by Codacy)

Unnecessary "else" after "return" (no-else-return) Warning

Unnecessary "else" after "return" (no-else-return)
log.info(
"Created folder %s (ID %s) [Direct]", sanitize_for_log(name), pk
)
return str(pk)
Comment on lines +818 to +822
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new checks in create_folder that validate the returned PK and either return it or log an "unsafe PK" error (here and in the similar branches below for list-based and polled responses) are not covered by tests. To guard this critical security behavior, consider adding tests that exercise responses with valid PKs, responses with malformed PKs, and the polling fallback, asserting both the returned ID/None and the corresponding log messages.

Copilot uses AI. Check for mistakes.
else:
log.error(
f"API returned unsafe PK for folder {sanitize_for_log(name)}: {sanitize_for_log(pk)}"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (109/100) Warning

Line too long (109/100)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (109/100) Warning

Line too long (109/100)
)
return None
Comment on lines 816 to +827

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code for validating the returned PK is substantially repeated twice more within this function (for the list-based response and the polling fallback). This duplication harms maintainability. Consider extracting this logic into a nested helper function to reduce repetition.

For example:

def _validate_and_log_pk(pk: Any, source: str) -> Optional[str]:
    pk_str = str(pk)
    if validate_resource_id(pk_str, f"{source} Folder PK"):
        log.info(
            "Created folder %s (ID %s) [%s]", sanitize_for_log(name), pk, source
        )
        return pk_str
    else:
        log.error(
            f"API returned unsafe PK for folder {sanitize_for_log(name)}: {sanitize_for_log(pk)}"
        )
        return None

This helper could then be called from all three locations, simplifying the main function body.


# Check if it returned a list containing our group
if isinstance(body, dict) and "groups" in body:
for grp in body["groups"]:
if grp.get("group") == name:
log.info(
"Created folder %s (ID %s) [Direct]",
sanitize_for_log(name),
grp["PK"],
)
return str(grp["PK"])
pk = grp["PK"]

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style
if validate_resource_id(str(pk), "New Folder PK"):

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Pylint (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Prospector (reported by Codacy)

Unnecessary "else" after "return" (no-else-return) Warning

Unnecessary "else" after "return" (no-else-return)
log.info(
"Created folder %s (ID %s) [Direct]",
sanitize_for_log(name),
pk,
)
return str(pk)
else:
log.error(
f"API returned unsafe PK for folder {sanitize_for_log(name)}: {sanitize_for_log(pk)}"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (117/100) Warning

Line too long (117/100)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (117/100) Warning

Line too long (117/100)
)

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
return None
except Exception as e:
log.debug(f"Could not extract ID from POST response: {e}")

Expand All @@ -819,12 +854,19 @@

for grp in groups:
if grp["group"].strip() == name.strip():
log.info(
"Created folder %s (ID %s) [Polled]",
sanitize_for_log(name),
grp["PK"],
)
return str(grp["PK"])
pk = grp["PK"]

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "pk" doesn't conform to snake_case naming style Warning

Variable name "pk" doesn't conform to snake_case naming style
if validate_resource_id(str(pk), "Polled Folder PK"):

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Pylint (reported by Codacy)

Unnecessary "else" after "return" Warning

Unnecessary "else" after "return"

Check warning

Code scanning / Prospector (reported by Codacy)

Unnecessary "else" after "return" (no-else-return) Warning

Unnecessary "else" after "return" (no-else-return)
log.info(
"Created folder %s (ID %s) [Polled]",
sanitize_for_log(name),
pk,
)
return str(pk)
else:
log.error(

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
f"API returned unsafe PK for folder {sanitize_for_log(name)}: {sanitize_for_log(pk)}"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (117/100) Warning

Line too long (117/100)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (117/100) Warning

Line too long (117/100)
)
return None
except Exception as e:
log.warning(f"Error fetching groups on attempt {attempt}: {e}")

Expand Down
44 changes: 44 additions & 0 deletions tests/test_id_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from unittest.mock import MagicMock

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing module docstring Warning test

Missing module docstring

Check warning

Code scanning / Pylint (reported by Codacy)

Missing module docstring Warning test

Missing module docstring

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Unused MagicMock imported from unittest.mock Note test

Unused MagicMock imported from unittest.mock

Check notice

Code scanning / Pylint (reported by Codacy)

Unused MagicMock imported from unittest.mock Note test

Unused MagicMock imported from unittest.mock

Check warning

Code scanning / Prospector (reported by Codacy)

Unused MagicMock imported from unittest.mock (unused-import) Warning test

Unused MagicMock imported from unittest.mock (unused-import)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The MagicMock import is not used in this file and can be removed to keep the imports clean.

Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MagicMock is imported but never used in this test module, which adds noise and may confuse readers about intended mocking. Consider removing the unused import to keep the test file minimal and focused.

Suggested change
from unittest.mock import MagicMock

Copilot uses AI. Check for mistakes.
import main

def test_validate_resource_id_valid():

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring
assert main.validate_resource_id("12345", "Test ID") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.validate_resource_id("abc_def-123", "Test ID") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.validate_resource_id("test_id", "Test ID") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_validate_resource_id_invalid_format():

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring
assert main.validate_resource_id("invalid/id", "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.validate_resource_id("invalid id", "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.validate_resource_id("invalid.id", "Test ID", log_errors=False) is False # dot not allowed in PK

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (112/100) Warning test

Line too long (112/100)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (112/100) Warning test

Line too long (112/100)
assert main.validate_resource_id("<script>", "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_validate_resource_id_invalid_length():

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring
long_id = "a" * 65
assert main.validate_resource_id(long_id, "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_validate_resource_id_empty():

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring
assert main.validate_resource_id("", "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.validate_resource_id(None, "Test ID", log_errors=False) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_is_valid_folder_name_whitelist():

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring
# Valid
assert main.is_valid_folder_name("My Folder") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder (Work)") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder_123") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder-Home") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder [Special]") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("domain.com") is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

# Invalid
assert main.is_valid_folder_name("Folder/Slash") is False # Slash not in whitelist

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder@At") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder&Amp") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder;Semi") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder<Tags>") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder'Quote") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder`Backtick") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert main.is_valid_folder_name("Folder$Dollar") is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_is_valid_folder_name_length():

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning test

Missing function docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning test

Missing function or method docstring
long_name = "a" * 65
assert main.is_valid_folder_name(long_name) is False

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

Check notice

Code scanning / Bandit (reported by Codacy)

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Loading