generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 524
Ash test #482
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
Closed
Closed
Ash test #482
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Test file with intentional security issues for ASH testing | ||
| """ | ||
|
|
||
| import subprocess | ||
| import pickle | ||
| import os | ||
|
|
||
| # Hardcoded credentials (security issue) | ||
| API_KEY = "sk-1234567890abcdef" | ||
| PASSWORD = "admin123" | ||
| SECRET_TOKEN = "secret_abc123" | ||
|
|
||
| def unsafe_command_execution(user_input): | ||
| """Execute shell command with user input - command injection vulnerability""" | ||
| command = f"ls {user_input}" | ||
| result = subprocess.call(command, shell=True) # Security issue: shell=True | ||
| return result | ||
|
|
||
| def unsafe_pickle_load(data): | ||
| """Unsafe deserialization - pickle vulnerability""" | ||
| return pickle.loads(data) # Security issue: unsafe deserialization | ||
|
|
||
| def sql_injection_example(user_id): | ||
| """SQL injection vulnerability example""" | ||
| query = f"SELECT * FROM users WHERE id = {user_id}" # SQL injection | ||
| return query | ||
|
|
||
| def weak_random_generation(): | ||
| """Weak random number generation""" | ||
| import random | ||
| return random.random() # Security issue: weak PRNG | ||
|
|
||
| def path_traversal_vulnerability(filename): | ||
| """Path traversal vulnerability""" | ||
| file_path = f"/var/uploads/{filename}" | ||
| with open(file_path, 'r') as f: # No path validation | ||
| return f.read() | ||
|
|
||
| # Hardcoded URL with credentials | ||
| DATABASE_URL = "postgresql://admin:password123@localhost:5432/mydb" | ||
|
|
||
| if __name__ == "__main__": | ||
| # Test the vulnerable functions | ||
| unsafe_command_execution("../etc/passwd") | ||
| print(f"Using API key: {API_KEY}") | ||
| weak_random_generation() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.