Datasets:
Download raw/python/cwe_250_0_secure.py from amazon/AutoSUIT: direct link, hf CLI and curl.
- Browser
- Download file 627 Bytes
-
https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/python/cwe_250_0_secure.py
- Command line
-
hf download hf://datasets/amazon/AutoSUIT/raw/python/cwe_250_0_secure.py
-
curl -L -o cwe_250_0_secure.py https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/python/cwe_250_0_secure.py
627 Bytes
| import os | |
| def create_user_directory(username, username_check, raise_privileges, lower_privileges): | |
| # Check if the username is invalid using the provided check | |
| if username_check(username): | |
| return False | |
| success = False # Track success status | |
| try: | |
| # Always raise and lower privileges even if creation fails | |
| raise_privileges() | |
| os.mkdir(username) # Attempt to create the directory | |
| success = True | |
| except OSError: | |
| success = False | |
| finally: | |
| # Always lower privileges after attempting directory creation | |
| lower_privileges() | |
| return success | |