-
Notifications
You must be signed in to change notification settings - Fork 0
Create test1.py with intentional variable error #2
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,8 @@ | ||||||||||||
| # Intentional error: variable 'result' is used before being defined , | ||||||||||||
|
|
||||||||||||
| def add_numbers(a, b): | ||||||||||||
| return a + b | ||||||||||||
|
|
||||||||||||
| print("Sum is the:", result) # <-- ERROR: 'result' is not defined | ||||||||||||
|
|
||||||||||||
| result = add_numbers(5, 10) | ||||||||||||
|
Comment on lines
+6
to
+8
|
||||||||||||
| print("Sum is the:", result) # <-- ERROR: 'result' is not defined | |
| result = add_numbers(5, 10) | |
| result = add_numbers(5, 10) | |
| print("Sum is the:", result) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||||||||||
| # app.py | ||||||||||||||||||||||||
| # INTENTIONAL_VULN: HARD_CODED_SECRET, SQL_INJECTION, STORED_XSS | ||||||||||||||||||||||||
| from flask import Flask, request, render_template_string | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| import sqlite3 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| app = Flask(__name__) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # INTENTIONAL_VULN: hard-coded secret | ||||||||||||||||||||||||
| API_KEY = "supersecretapikey123" # INTENTIONAL_VULN: HARD_CODED_SECRET | ||||||||||||||||||||||||
|
Comment on lines
+5
to
+9
|
||||||||||||||||||||||||
| app = Flask(__name__) | |
| # INTENTIONAL_VULN: hard-coded secret | |
| API_KEY = "supersecretapikey123" # INTENTIONAL_VULN: HARD_CODED_SECRET | |
| import os | |
| app = Flask(__name__) | |
| # FIXED: API key loaded from environment variable | |
| API_KEY = os.environ.get("API_KEY") |
Copilot
AI
Dec 11, 2025
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.
Missing authentication check on the search endpoint. The route is publicly accessible without any authorization, which may expose sensitive data or functionality.
Copilot
AI
Dec 11, 2025
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.
SQL injection vulnerability detected. User input 'q' is concatenated directly into the SQL query without sanitization or parameterization. Use parameterized queries instead to prevent SQL injection attacks.
| sql = "SELECT id, title FROM articles WHERE title LIKE '%" + q + "%';" | |
| cursor.execute(sql) | |
| sql = "SELECT id, title FROM articles WHERE title LIKE ?;" | |
| cursor.execute(sql, ('%' + q + '%',)) |
Copilot
AI
Dec 11, 2025
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.
Cross-Site Scripting (XSS) vulnerability. Database content is rendered directly into the HTML template without escaping, allowing malicious scripts in the database to execute in users' browsers. The data should be properly escaped or use a safer templating approach.
Copilot
AI
Dec 11, 2025
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.
Running Flask with debug=True in production is a security risk. Debug mode exposes sensitive information and provides an interactive debugger that could be exploited. This should only be enabled in development environments.
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.
Trailing comma found at the end of the comment. This should be removed for cleaner documentation.