-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3705 from KBVE/dev
Preparing Alpha Branch
- Loading branch information
Showing
11 changed files
with
203 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .api import Routes, CORS | ||
from .apps import TursoDatabase, DiscordServerManager | ||
from .api import SetupSchema, Hero, DiscordServer, Health, SchemaEngine | ||
from .api import SetupSchema, Hero, DiscordServer, Health, SchemaEngine, Utils |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .cors import CORS | ||
from .routes import Routes | ||
from .schema import SetupSchema, Hero, DiscordServer, SchemaEngine | ||
from .heath import Health | ||
from .heath import Health | ||
from .utils import Utils |
This file contains 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 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,46 @@ | ||
import re | ||
from urllib.parse import urlparse, unquote | ||
|
||
class Utils: | ||
@staticmethod | ||
def validate_url(value: str, allow_encoded: bool = False) -> str: | ||
""" | ||
Validates and sanitizes a URL, rejecting any URLs with percent-encoded characters. | ||
Args: | ||
value (str): The input URL to validate. | ||
allow_encoded (bool): If True, allow encoded characters; otherwise, decode them. | ||
Returns: | ||
str: The validated and sanitized URL. | ||
Raises: | ||
ValueError: If the URL is invalid or contains unsafe content. | ||
""" | ||
if not value: | ||
raise ValueError("URL cannot be empty.") | ||
# If encoded characters are not allowed, ensure no '%' character is present | ||
if '%' in value: | ||
raise ValueError(f"URL contains percent-encoded characters, which are not allowed: {value}") | ||
# Decode the URL if encoded characters are not allowed | ||
if not allow_encoded: | ||
value = unquote(value) | ||
# Parse the URL | ||
parsed = urlparse(value) | ||
# Check for valid scheme and netloc | ||
if not parsed.scheme or not parsed.netloc: | ||
raise ValueError(f"Invalid URL structure: {value}") | ||
# Ensure the scheme is HTTP or HTTPS | ||
if parsed.scheme not in {"http", "https"}: | ||
raise ValueError(f"URL must start with http:// or https://. Got: {value}") | ||
# Check if the netloc (domain) is not just a single character or empty | ||
if len(parsed.netloc) < 3 or '.' not in parsed.netloc: | ||
raise ValueError(f"Invalid URL domain: {value}") | ||
# Check if the netloc is just a scheme (like "https://") | ||
if parsed.netloc == "": | ||
raise ValueError(f"Invalid URL, missing domain: {value}") | ||
# Additional sanitization (remove unsafe characters) | ||
sanitized_url = re.sub(r'[^a-zA-Z0-9:/?&=_\-.,]', '', value) | ||
if sanitized_url != value: | ||
raise ValueError(f"URL contains unsafe characters: {value}") | ||
return sanitized_url |
Empty file.
This file contains 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 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
14 changes: 14 additions & 0 deletions
14
migrations/kube/charts/discordsh/discord/templates/turso-sealed-secrets.yaml
This file contains 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,14 @@ | ||
--- | ||
apiVersion: bitnami.com/v1alpha1 | ||
kind: SealedSecret | ||
metadata: | ||
name: discord-turso | ||
namespace: discordsh | ||
spec: | ||
encryptedData: | ||
TURSO_AUTH_TOKEN: AgBh1IY+fPAezWP1ibvObhf/fSuif1FN73MIs6LI9k1+lJAs1Abjnjx8Qxjb5YdgJ60RgO37kmKGVCrtiPT2Y5fYU4ydsR7mh2WOdOMxWLqKw39N4QrfVCAQX/1N/NszskkPLse40pv2xK+8YBIEOkoqDSq/qHM6UHndj4+Ogn0iJL7oSvERB86za83HvDHsU4CkHWNET8cPdFi3QlbeBRXmniKl9/Qtz2ZKyk8DPfJmOF3eAE4Y31Xyz/xkM4/JVaphCdxLDt58SIEBpSpSuiFMqvgkozX820qGlVR8uNAiJh5IaRguaOrpcUaKcvh1mGnLvIhKw2gRhBXVc+1glBaXab1FWehXkwO527IFuBfdAO1ARDAiMv3leuEwu2p4C0oVuGsKmBf+74WIj28NLw4T7TMjstdwkmiCHNlkbDBiz6i6cgdOQJy+ddlcwz117d0aorlwa7IfxaXt0JH/v5+5Mo2FCziZeH2P7eYzqvXeuBb+gunsUTFIAtI/Jjxvmv+EOH+bntjKeNQmiOFiSotnUTvCzTEcts4jH8QknvKGKUFqdN5q3QIGP5G/HKwe8D+4ShHQyIvV6kmtYt1pCmj0Pfm0kB/ji8AWR1I0zKsnW9Fj3LJm+C+uLByi0yy9oyiyPOjW60Og9FfO3PEUw7M9rZg1LUGem6sS6O2RPAFu97DvT3NzZW67hHXOLzk2qON71Y7tdyhTJaL0cwvBbJqZIDoTi453EHSyeZz27CkqyS5sbo4aShbz2zQRNubFsBxkX0RR7C1lJzXcFpRotHNRnUakuR9gJwJsKaAISHVKVzfF49arcK8/wYbQ7p7xlSnYRzF/HAnl3/9vrJLRsA6L2Cq3NGf20LDISeS1D//9cnFEX2MjmAl23i5a2iPQPheo6agGRU/An/kiRJgfpjcXhwq6qrT4bZYwqpqQL/cxjMW3DTmY4rW45WqRo/GSNyJg69S0rfigdQIco20xdH+P+aOK6unWx2mvfkk= | ||
TURSO_DATABASE_URL: AgCeIXgWJMh367RfLyvnZMcJItaojsaOPoygUUu34ON5UZF9oWsxCKDjirhZ8medPRL9qSzLVuXpbN/ZHCrwwms1O/wqIuq/zBabI6WzKpiKC2qfN3jIlMiFk5S9nOvpsZSdWw05KK9GJddMeEmu4pkCpQeDEPvjR0N+sD6e1QDzGXrWR0uIDOSbvcnO1JaKyNHh65UKPSLhpuo6D8DxxrfjqmT3PGZDAiq65uUZtTqV7wTJjL0ryCZctZu23yHKjXigLQBWtOVSnLeYLAh9Tm6/schbTL0l5+5UdAaIdH7Rs3MsQ+SXgsz5Ouuxrjj9dBqMQS38PCOk7spEglAfhfsu/QWDqyCTjB1cuPzUOCHkRtaQ7QATeuCkurlwRqlwPaGXHKQpC38a65AowTTvqKHBHwqLoShUfiQDW8qt1ot4MZU0gUqzkkVaRvEWNLdps04b6EhxR34388Xfr3gqmEZmcx9SJZjWUHxvqhwPu2L1ExDWAVLpEivFqziJBU4ByXWjzqFGhR2Cz9gp1aT33Pth0ZbG7XgJvrU44kYbXfnP/xTRvq16uhH9xxWQpaiP0tOI6+U4Csf7UPM2vZk21Od9Na1RR0fWhM8yZYp/Bq1d8+NMxsfhg4uixnMOlkBzQjtdVlgKwiTmjoOy44m8oTRUyI6ijF72I6cT9quRyFrSiBodIGjDrTIadKwalUZdHfNizdGqbUpxpHrb1P6NrJ+v9pBHTodMcBz5ue226SXh | ||
template: | ||
metadata: | ||
name: discord-turso | ||
namespace: discordsh |