-
Notifications
You must be signed in to change notification settings - Fork 1
new no watch PR #6
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
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| requests==2.32.0 | ||
| pandas==2.2.3 | ||
| jose==1.0.0 | ||
| Flask==2.2.2 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,16 +1,13 @@ | ||||||
| # src/app.py | ||||||
| import requests | ||||||
| import pandas as pd | ||||||
| from flask import Flask, request, render_template_string | ||||||
|
|
||||||
| def fetch_data(url): | ||||||
| response = requests.get(url) | ||||||
| return response.json() | ||||||
| app = Flask(__name__) | ||||||
|
|
||||||
| def main(): | ||||||
| url = 'https://api.github.com/events' | ||||||
| data = fetch_data(url) | ||||||
| df = pd.DataFrame(data) | ||||||
| print(df.head()) | ||||||
| # A simple route that renders user input without proper sanitization | ||||||
| @app.route('/greet', methods=['GET']) | ||||||
| def greet(): | ||||||
| user_name = request.args.get('name', 'Guest') | ||||||
| # Rendering user input directly without escaping | ||||||
| return render_template_string(f"<h1>Hello, {user_name}!</h1>") | ||||||
|
|
||||||
| if __name__ == '__main__': | ||||||
| main() | ||||||
| app.run(debug=True) | ||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Static Application Security Testing (SAST) VulnerabilityFull descriptionVulnerability Details
OverviewDebug mode in a Flask app is a feature that allows the developer to see detailed Query operationIn this query we look Flask applications that set the Vulnerable examplefrom flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World!'
if __name__ == '__main__':
app.run(debug=True)In this example, the Flask application is set to run in debug mode by passing RemediationWhen using if __name__ == '__main__':
- app.run(debug=True)
+ app.run() |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| test this out | ||
| let's update this | ||
|
|
||
| I have new check for PR |

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.
🎯 Static Application Security Testing (SAST) Vulnerability
High
Full description
Vulnerability Details
Overview
XSS, or Cross-Site Scripting, is a type of vulnerability that allows an attacker to
inject malicious code into a website or web application.
This can allow the attacker to steal sensitive information from users, such as their
cookies or login credentials, or to perform unauthorized actions on their behalf.
Query operation
In the query we look for any user input that flows into
a potential output of the application.
Vulnerable example
In the following example, the Flask application takes a user-supplied parameter (
name)from the query string and renders it directly into an HTML template using the
render_template_stringfunction. The issue is thatthe user input is not properly sanitized or escaped, making it vulnerable to XSS attacks.
An attacker can exploit this vulnerability by injecting malicious JavaScript code into the
nameparameter. For instance, they could modify the URL to include the following payload:http://localhost:5000/?name=<script>alert('XSS')</script>Remediation
When rendering templates, use parametrized variable assignments (which are automatically
escaped) instead of direct string manipulation -
@app.route('/') def index(): name = request.args.get('name', 'Guest') message = f'Hello, {name}!' - return render_template_string('<h1>{}</h1>'.format(message)) + return render_template_string('<h1>{{ message }}</h1>', message=message)Code Flows
Vulnerable data flow analysis result
request.args(at Projects/python-fb-example/src/app.py line 8)request.args.get('name', 'Guest')(at Projects/python-fb-example/src/app.py line 8)user_name(at Projects/python-fb-example/src/app.py line 10)f"<h1>Hello, {user_name}!</h1>"(at Projects/python-fb-example/src/app.py line 10)render_template_string(f"<h1>Hello, {user_name}!</h1>")(at Projects/python-fb-example/src/app.py line 10)return render_template_string(f"<h1>Hello, {user_name}!</h1>")(at Projects/python-fb-example/src/app.py line 10)🐸 JFrog Frogbot