-
Notifications
You must be signed in to change notification settings - Fork 0
Add awesome new feature #1
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 |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| import re | ||
| import sqlite3 | ||
|
|
||
| from pokedex.utils import is_pikachu | ||
|
|
||
|
|
||
| class ConnectionWrapper: | ||
| """A simple connection wrapper class""" | ||
|
|
||
| def __init__(self, db_path): | ||
| self.__conn = sqlite3.connect(db_path) | ||
|
|
||
| def get_single_pokemon(self, pokemon_id): | ||
| statement = f"SELECT * FROM POKEDEX WHERE id = '{pokemon_id}'" | ||
| return self.__conn.execute(statement).fetchone() | ||
|
Check failure on line 15 in pokedex/helper.py
|
||
Check failureCode scanning / SonarCloudDev7 Database queries should not be vulnerable to injection attacks High
Change this code to not construct SQL queries directly from user-controlled data. See more on SonarQube Cloud
|
||
|
|
||
| def get_all_pokemons(self): | ||
| statement = "SELECT * FROM POKEDEX" | ||
| return self.__conn.execute(statement).fetchall() | ||
|
|
@@ -36,3 +42,14 @@ | |
| ValueError("Invalid email!") | ||
| wrapper.register_subscriber(email) | ||
| pass | ||
|
|
||
|
|
||
| def fetch_pokemon(wrapper: ConnectionWrapper, pokemon_id: str): | ||
| result = wrapper.get_single_pokemon(pokemon_id) | ||
| if result is None: | ||
| raise "Pokemon not found" | ||
|
Check failure on line 50 in pokedex/helper.py
|
||
| if pokemon_id == 25: | ||
|
Check warning on line 51 in pokedex/helper.py
|
||
| if is_pikachu(result): | ||
|
Check failure on line 52 in pokedex/helper.py
|
||
| # Team Rocket is trying to steal Pikachu (#25)! | ||
| result = ("", "We stole Pikachu!", "", "") | ||
| return result | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {% extends "base.html" %} | ||
| {% block styles %} | ||
| {{ super() }} | ||
| <link rel= "stylesheet" type= "text/css" href= "{{ url_for('static', filename='css/style.css') }}"> | ||
| {% endblock %} | ||
| {% block content %} | ||
| <div class="full-page d-flex flex-wrap justify-content-center align-items-center"> | ||
| <div class="container d-flex flex-column flex-wrap justify-content-start align-items-center text-center py-5 m-auto margin-mobile"> | ||
| <h1>{{ name }} # {% autoescape false %} {{ pokemon_id }} {% endautoescape %}</h1> | ||
|
Check warning on line 9 in pokedex/templates/pokemon.html
|
||
Check failureCode scanning / SonarCloud Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High
Change this code to not reflect user-controlled data. See more on SonarQube Cloud
Check failureCode scanning / SonarCloudDev7 Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High
Change this code to not reflect unsanitized user-controlled data. See more on SonarQube Cloud
Check warningCode scanning / SonarCloudDev7 Auto-escaping in HTML template engines should not be disabled Medium
Make sure disabling auto-escaping feature is safe here. See more on SonarQube Cloud
|
||
| <div class="flex-row container d-flex flex-wrap justify-content-center align-items-center text-center mt-2"> | ||
| <img src="{{ sprites[0] }}" alt=""> | ||
| </div> | ||
| <p>{{ description }}</p> | ||
| </div> | ||
| </div> | ||
| {% endblock %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def is_pikachu(pokemon_id, pokemon_name): | ||
| return pokemon_id == 25 and pokemon_name == "Pikachu" |
Check failure
Code scanning / SonarCloud
Database queries should not be vulnerable to injection attacks High