Skip to content
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

Merged
merged 6 commits into from
Nov 26, 2024
Merged

Conversation

ashton22305
Copy link
Contributor

Fixes #3921

Changes variables with script in the name to instead say launcher if actually referring to launchers.
Updates user messages to reflect using launchers, not scripts.

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

This path depends on a
user-provided value
.

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.

  1. Add a custom validation method to sanitize the template attribute.
  2. Update the project_template_invalid method to include the new validation.
  3. Ensure that the template attribute is sanitized before being used in the save_new_launchers method.
Suggested changeset 1
apps/dashboard/app/models/project.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/dashboard/app/models/project.rb b/apps/dashboard/app/models/project.rb
--- a/apps/dashboard/app/models/project.rb
+++ b/apps/dashboard/app/models/project.rb
@@ -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
EOF
@@ -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
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@johrstrom
Copy link
Contributor

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.

@ashton22305 ashton22305 marked this pull request as draft November 25, 2024 16:08
@ashton22305
Copy link
Contributor Author

Tests pass but the naming of system tests should probably be updated and possibly something about this security vulnerability as well.

@ashton22305 ashton22305 marked this pull request as ready for review November 25, 2024 19:33
@johrstrom johrstrom merged commit 049daeb into master Nov 26, 2024
24 of 25 checks passed
@johrstrom johrstrom deleted the script-to-launcher branch November 26, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In launchers_controller.rb, rename '@script' to '@launcher'
3 participants