Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
importosdirectory="/tmp"# Use of unsanitized data to execute a processos.system("/bin/ls")os.system("/bin/ls "+directory)os.system(f'mv {saved_file_path}{public_upload_file_path}')deffile_upload_api(request,app):file=request.files['file']ifnot_validate_file(file.filename):return{'message':'Invalid file extension','allowed_ext':ALLOWED_EXTENSIONS,'filename':file.filename},422saved_file_result=_save_temp_file(file,app)saved_file_path=saved_file_result['saved_path']file_name=Path(saved_file_path).namepublic_upload_file_path=os.path.join(app.config['PUBLIC_UPLOAD_FOLDER'],file_name)os.system(f'mv {saved_file_path}{public_upload_file_path}')returnrender_template('file_upload.html',file_url=f'{get_uploads_folder_url()}/{file_name}')
Compliant Code Examples
importosimportshlex# Use of shlex() to sanitize dataos.system(shlex.escape("/bin/ls"))
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- python-security # Rules to enforce Python security.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines