-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Security3 #10944
Security3 #10944
Conversation
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.
I don't think these changes make things any more secure; in fact, they will probably break things.
@@ -597,7 +598,8 @@ def main(opt, callbacks=Callbacks()): | |||
# ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices | |||
evolve_yaml, evolve_csv = save_dir / 'hyp_evolve.yaml', save_dir / 'evolve.csv' | |||
if opt.bucket: | |||
os.system(f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}') # download evolve.csv if exists | |||
subprocess.run( | |||
f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}'.split()) # download evolve.csv if exists |
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.
This will break if the bucket name or filename contains a space.
(This repeats for the other gsutil incantation.)
@@ -461,7 +462,7 @@ def main(opt): | |||
r, _, t = run(**vars(opt), plots=False) | |||
y.append(r + t) # results and times | |||
np.savetxt(f, y, fmt='%10.4g') # save | |||
os.system('zip -r study.zip study_*.txt') | |||
subprocess.run('zip -r study.zip study_*.txt'.split()) |
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.
I don't think this change really makes anything more secure.
(This repeats for the other zip.)
@@ -50,7 +50,8 @@ def safe_download(file, url, url2=None, min_bytes=1E0, error_msg=''): | |||
if file.exists(): | |||
file.unlink() # remove partial downloads | |||
LOGGER.info(f'ERROR: {e}\nRe-attempting {url2 or url} to {file}...') | |||
os.system(f"curl -# -L '{url2 or url}' -o '{file}' --retry 3 -C -") # curl download, retry and resume on fail | |||
subprocess.run( | |||
f"curl -# -L '{url2 or url}' -o '{file}' --retry 3 -C -".split()) # curl download, retry and resume on fail |
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.
Same space-brokenness here, not to mention there will now be quotes in the split arguments that wouldn't be there otherwise. (This repeats for the other curl.)
Subprocess.run does not return an integer. Regressed in ultralytics#10944
Subprocess.run does not return an integer. Regressed in #10944
* Use list-form arguments for subprocess.run calls where possible Augments #10944 * Deduplicate curl code * Avoid eval() to parse integer --------- Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Security improvements * Security improvements * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Subprocess.run does not return an integer. Regressed in ultralytics#10944
* Use list-form arguments for subprocess.run calls where possible Augments ultralytics#10944 * Deduplicate curl code * Avoid eval() to parse integer --------- Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
π οΈ PR Summary
Made with β€οΈ by Ultralytics Actions
π Summary
Upgraded system calls to subprocess module for better security and compliance.
π Key Changes
os.system
calls withsubprocess.run
in files such astrain.py
,val.py
, anddownloads.py
.subprocess
module in files where system calls have been replaced.π― Purpose & Impact
subprocess
prevents shell injection vulnerabilities that can occur withos.system
.subprocess
allows better handling of exceptions and program output.