-
Notifications
You must be signed in to change notification settings - Fork 108
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
Change "script" to "launcher" in variables #3976
Conversation
end.map do |script| | ||
saved_successfully = script.save | ||
errors.add(:save, script.errors.full_messages) unless saved_successfully | ||
Dir.glob("#{dir}/*/form.yml").map do |launcher_yml| |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to ensure that the template
attribute is properly validated and sanitized before being used to construct file paths. This can be achieved by implementing additional validation rules to restrict the format of the template
attribute, ensuring it does not contain any directory traversal sequences or other potentially harmful characters.
- Add a custom validation method to sanitize the
template
attribute. - Update the
project_template_invalid
method to include the new validation. - Ensure that the
template
attribute is sanitized before being used in thesave_new_launchers
method.
-
Copy modified line R273 -
Copy modified line R312 -
Copy modified lines R317-R321
@@ -272,2 +272,3 @@ | ||
def save_new_launchers | ||
sanitize_template | ||
dir = Launcher.launchers_dir(template) | ||
@@ -310,2 +311,3 @@ | ||
|
||
sanitize_template | ||
template_path = Pathname.new(template) | ||
@@ -314,2 +316,7 @@ | ||
end | ||
|
||
def sanitize_template | ||
# Remove any directory traversal sequences and ensure the template is a valid directory name | ||
self.template = template.gsub(/(\.\.\/|\/|\\)/, '') | ||
end | ||
end |
Given tests fail you may want to reduce the scope of the change to maybe 1 file at a time and pick this apart piecemeal. |
Tests pass but the naming of system tests should probably be updated and possibly something about this security vulnerability as well. |
Fixes #3921
Changes variables with
script
in the name to instead saylauncher
if actually referring to launchers.Updates user messages to reflect using launchers, not scripts.