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

Safety problem in Code #17

Open
zhenlongDai opened this issue Oct 22, 2024 · 1 comment
Open

Safety problem in Code #17

zhenlongDai opened this issue Oct 22, 2024 · 1 comment

Comments

@zhenlongDai
Copy link

While using the tear_down function in your code, I noticed some potential security risks, especially when the code is executed via a Bash script in an external directory. The function uses os.listdir() to list the files in the current working directory and deletes files or folders that are not in the reserved_files list. However, if the script is executed in an unintended directory (such as the root directory or a system directory), it could mistakenly delete important files or directories, which could lead to severe system issues or data loss.

Specifically, the current code does not verify whether the current working directory is the expected project directory. As a result, if the script is executed in an incorrect path, it may unnecessarily clean up files in that directory. To avoid potential risks, I recommend adding an explicit check of the path before performing deletion operations, ensuring that the actions are only executed in the target directory. Additionally, it may be helpful to include logging to facilitate debugging and prevent the accidental deletion of irreplaceable files.

@wkx228
Copy link
Collaborator

wkx228 commented Oct 24, 2024

Yeah, it's a problem. I have updated the script. Thanks!

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

No branches or pull requests

2 participants