-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature/simultaneous_queues] Improved version for scenario management #29
Conversation
…lt scenario configuration
scenario_commands_file = os.path.join( | ||
nebula_config_dir, scenario_name, "current_scenario_commands.sh" | ||
) | ||
if os.path.exists(scenario_commands_file): |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to validate the scenario_name
before using it to construct file paths. We can use the os.path.normpath
function to normalize the path and ensure it is contained within a safe root directory. Additionally, we can use a whitelist of allowed characters to further sanitize the scenario_name
.
- Normalize the
scenario_name
usingos.path.normpath
. - Ensure the normalized path starts with the expected base directory.
- Optionally, sanitize the
scenario_name
to allow only specific characters.
-
Copy modified lines R398-R401
@@ -397,2 +397,6 @@ | ||
if scenario_name: | ||
# Normalize and validate scenario_name | ||
scenario_name = os.path.normpath(scenario_name) | ||
if not scenario_name.startswith(nebula_config_dir): | ||
raise Exception("Invalid scenario name") | ||
if os.environ.get("NEBULA_HOST_PLATFORM") == "windows": |
nebula_config_dir, scenario_name, "current_scenario_commands.sh" | ||
) | ||
if os.path.exists(scenario_commands_file): | ||
os.remove(scenario_commands_file) |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to validate the scenario_name
before using it to construct file paths. We can use the os.path.normpath
function to normalize the path and ensure it is contained within a safe root directory. Additionally, we can use a whitelist of allowed characters to further sanitize the scenario_name
.
- Normalize the
scenario_name
usingos.path.normpath
. - Ensure the normalized path starts with the expected base directory.
- Use a whitelist of allowed characters to sanitize the
scenario_name
.
-
Copy modified lines R398-R401
@@ -397,2 +397,6 @@ | ||
if scenario_name: | ||
# Normalize and validate scenario_name | ||
scenario_name = os.path.normpath(scenario_name) | ||
if not scenario_name.isalnum(): | ||
raise ValueError("Invalid scenario name") | ||
if os.environ.get("NEBULA_HOST_PLATFORM") == "windows": |
No description provided.