-
Notifications
You must be signed in to change notification settings - Fork 7
Add Security_6_T23 test #265
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
base: python_testing
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,56 @@ def monitor_journalctl_for_message(self, service_name: str, message: str, | |
process.terminate() | ||
except: | ||
pass | ||
|
||
def restart_component(self, component_name: str, reset: bool): | ||
if reset: | ||
try: | ||
cmd = [ | ||
"sudo", | ||
"systemctl", | ||
"reset-failed" | ||
] | ||
|
||
# Run the command and stream output | ||
process = subprocess.Popen( | ||
cmd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True, | ||
) | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
finally: | ||
# Ensure process is terminated | ||
try: | ||
process.terminate() | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji. It appears that you are generically passing an
Similar issue at line number 160. |
||
pass | ||
|
||
print(f"Restarting component {component_name}") | ||
try: | ||
cmd = [ | ||
"sudo", | ||
"systemctl", | ||
"restart", | ||
f"ggl.{component_name}.service", | ||
] | ||
|
||
# Run the command and stream output | ||
process = subprocess.Popen( | ||
cmd, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True, | ||
) | ||
|
||
return True | ||
except Exception as e: | ||
print(f"Error: {e}") | ||
return False | ||
finally: | ||
# Ensure process is terminated | ||
try: | ||
process.terminate() | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji. Try, Except, Pass detected. https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html |
||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Try, Except, Pass detected. https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html