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

feat: add orchestrator logic to the gem #128

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlanAlvarez21
Copy link
Collaborator

Added orchestrator logic to manage and execute scheduled scripts based on time intervals, specific times, and days. Includes a manager class to handle the execution flow and corresponding tests.

project_root = File.expand_path(File.join(__dir__, '..', '..', '..', '..', 'bas_use_cases', 'src', 'use_cases_execution'))
script_path = File.expand_path(File.join(project_root, script[:path].sub(%r{^src/use_cases_execution/}, '')))
puts "Executing #{script_path} at #{current_time}"
if system("ruby #{script_path}")

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This string construction which depends on
library input
is later used in a
shell command
.

Copilot Autofix AI about 8 hours ago

To fix the problem, we should avoid directly interpolating the script_path into the system command. Instead, we can pass the script_path as a separate argument to the system command, which will prevent the shell from interpreting any special characters in the path.

  • Modify the execute method in the Manager class to use the safer method of passing arguments to the system command.
  • Specifically, change the system("ruby #{script_path}") line to system("ruby", script_path).
Suggested changeset 1
lib/bas/orchestrator/manager.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/lib/bas/orchestrator/manager.rb b/lib/bas/orchestrator/manager.rb
--- a/lib/bas/orchestrator/manager.rb
+++ b/lib/bas/orchestrator/manager.rb
@@ -38,3 +38,3 @@
 
-        if system("ruby #{script_path}")
+        if system("ruby", script_path)
           @last_executions[script[:path]] = time_in_milliseconds
EOF
@@ -38,3 +38,3 @@

if system("ruby #{script_path}")
if system("ruby", script_path)
@last_executions[script[:path]] = time_in_milliseconds
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
@AlanAlvarez21 AlanAlvarez21 marked this pull request as draft February 1, 2025 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant