From e8d24952781b2d25d833dffe1b3890aa90bf38b3 Mon Sep 17 00:00:00 2001 From: orbisai0security Date: Tue, 28 Apr 2026 10:34:17 +0000 Subject: [PATCH 1/3] fix: V-002 security vulnerability Automated security fix generated by Orbis Security AI --- backtracking/all_permutations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backtracking/all_permutations.py b/backtracking/all_permutations.py index f376e6fa0945..4a61b562a721 100644 --- a/backtracking/all_permutations.py +++ b/backtracking/all_permutations.py @@ -78,7 +78,11 @@ def create_state_space_tree( remove the comment to take an input from the user print("Enter the elements") -sequence = list(map(int, input().split())) +MAX_SEQUENCE_LENGTH = 8 +user_input = list(map(int, input().split())) +if len(user_input) > MAX_SEQUENCE_LENGTH: + raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).") +sequence = user_input """ sequence: list[int | str] = [3, 1, 2, 4] From 61d15e379c26c3125db1702ded47dfc6fa2cccd5 Mon Sep 17 00:00:00 2001 From: OrbisAI Security Date: Sat, 2 May 2026 12:54:55 +0530 Subject: [PATCH 2/3] moving max_sequence_length to model, length check + doctest, cli block now checks length --- backtracking/all_permutations.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backtracking/all_permutations.py b/backtracking/all_permutations.py index 4a61b562a721..821898989543 100644 --- a/backtracking/all_permutations.py +++ b/backtracking/all_permutations.py @@ -8,8 +8,18 @@ from __future__ import annotations +MAX_SEQUENCE_LENGTH = 8 + def generate_all_permutations(sequence: list[int | str]) -> None: + """ + >>> generate_all_permutations([1] * 9) + Traceback (most recent call last): + ... + ValueError: Input sequence too long (max 8 elements). + """ + if len(sequence) > MAX_SEQUENCE_LENGTH: + raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).") create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))]) @@ -78,11 +88,11 @@ def create_state_space_tree( remove the comment to take an input from the user print("Enter the elements") -MAX_SEQUENCE_LENGTH = 8 -user_input = list(map(int, input().split())) -if len(user_input) > MAX_SEQUENCE_LENGTH: +raw = input().split() +if len(raw) > MAX_SEQUENCE_LENGTH: raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).") -sequence = user_input +sequence: list[int | str] = raw +generate_all_permutations(sequence) """ sequence: list[int | str] = [3, 1, 2, 4] From 1640999e8102717b39a2d14caab2bb39d55b9c1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 2 May 2026 07:25:22 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- backtracking/all_permutations.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backtracking/all_permutations.py b/backtracking/all_permutations.py index 821898989543..565c263ea283 100644 --- a/backtracking/all_permutations.py +++ b/backtracking/all_permutations.py @@ -19,7 +19,9 @@ def generate_all_permutations(sequence: list[int | str]) -> None: ValueError: Input sequence too long (max 8 elements). """ if len(sequence) > MAX_SEQUENCE_LENGTH: - raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).") + raise ValueError( + f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements)." + ) create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])