Skip to content
5 changes: 0 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ services:
networks:
app_net:
ipv4_address: 192.168.0.2
healthcheck:
test: ["CMD-SHELL", "pg_isready -U balancer -d balancer_dev"]
interval: 5s
timeout: 5s
retries: 5

pgadmin:
image: dpage/pgadmin4
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ function Footer() {
>
Leave feedback
</Link>
<a href="https://www.flipcause.com/secure/cause_pdetails/MjMyMTIw"
<a href="https://github.com/CodeForPhilly/balancer-main"
target="_blank"
className="flex justify-center text-black hover:border-blue-600 hover:text-blue-600 hover:no-underline"
className="flex justify-center text-center text-black hover:border-blue-600 hover:text-blue-600 hover:no-underline"
>
Donate
Support Development
</a>
<Link
to="/help"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ const Header: React.FC<LoginFormProps> = ({ isAuthenticated, isSuperuser }) => {
Leave Feedback
</Link>
<a
href="https://www.flipcause.com/secure/cause_pdetails/MjMyMTIw"
href="https://github.com/CodeForPhilly/balancer-main"
target="_blank"
className="header-nav-item"
>
Donate
Support Development
</a>
{isAuthenticated && isSuperuser && (
<div
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Header/MdNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const MdNavBar = (props: LoginFormProps) => {
</Link>
</li>
<li className="border-b border-gray-300 p-4">
<a href="https://www.flipcause.com/secure/cause_pdetails/MjMyMTIw"
<a href="https://github.com/CodeForPhilly/balancer-main"
target="_blank"
className="mr-9 text-black hover:border-b-2 hover:border-blue-600 hover:text-black hover:no-underline"
>
Donate
Support Development
</a>
</li>
{isAuthenticated &&
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ function About() {
</div>
</div>
<div className="mb-20 mt-5 flex flex-row flex-wrap justify-center gap-4">
<a href="https://www.flipcause.com/secure/cause_pdetails/MjMyMTIw" target="_blank">
<a href="https://github.com/CodeForPhilly/balancer-main" target="_blank">
<button className="btnBlue transition-transform focus:outline-none focus:ring focus:ring-blue-200">
Donate
Support Development
</button>
</a>

Expand Down
9 changes: 2 additions & 7 deletions frontend/src/pages/DocumentManager/UploadFile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useRef } from "react";
import axios from "axios";
import { adminApi } from "../../api/apiClient";
import TypingAnimation from "../../components/Header/components/TypingAnimation.tsx";
import Layout from "../Layout/Layout.tsx";

Expand All @@ -22,14 +22,9 @@ const UploadFile: React.FC = () => {
formData.append("file", file);

try {
const response = await axios.post(
const response = await adminApi.post(
`/api/v1/api/uploadFile`,
formData,
{
headers: {
"Content-Type": "multipart/form-data"
},
}
);
console.log("File uploaded successfully", response.data);
} catch (error) {
Expand Down
62 changes: 56 additions & 6 deletions server/api/views/assistant/sanitizer.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,76 @@
import re
import logging

logger = logging.getLogger(__name__)
def sanitize_input(user_input:str) -> str:
"""
Sanitize user input to prevent injection attacks and remove unwanted characters.

Args:
user_input (str): The raw input string from the user.

Returns:
str: The sanitized input string.
"""
try:
# Remove any script tags
sanitized = re.sub(r'<script.*?>.*?</script>', '', user_input, flags=re.IGNORECASE)
# Remove any HTML tags
sanitized = user_input

# Remove any style tags
sanitized = re.sub(r'<style.*?>.*?</style>', '', sanitized, flags=re.IGNORECASE)

# Remove any HTML/script tags
sanitized = re.sub(r'<.*?>', '', sanitized)

# Remove Phone Numbers
sanitized = re.sub(r'\+?\d[\d -]{8,}\d', '[Phone Number]', sanitized)

# Remove Email Addresses
sanitized = re.sub(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', '[Email Address]', sanitized)

# Remove Medical Record Numbers (simple pattern)
sanitized = re.sub(r'\bMRN[:\s]*\d+\b', '[Medical Record Number]', sanitized, flags=re.IGNORECASE)

# Normalize pronouns
sanitized = normalize_pronouns(sanitized)

# Escape special characters
sanitized = re.sub(r'["\'\\]', '', sanitized)
sanitized = re.sub(r'\s+', '', sanitized)

# Limit length to prevent buffer overflow attacks
max_length = 1000
max_length = 5000
if len(sanitized) > max_length:
sanitized = sanitized[:max_length]

return sanitized.strip()
except Exception as e:
logger.error(f"Error sanitizing input: {e}")
return ""
return ""

def normalize_pronouns(text:str) -> str:
"""
Normalize first and second person pronouns to third person clinical language.

Converts patient centric pronouns to a more neutral form.
Args:
text (str): The input text containing pronouns.
Returns:
str: The text with normalized pronouns.
"""
# Normalize first person possessives: I, me, my, mine -> the patient
text = re.sub(r'\bMy\b', 'The patient\'s', text)
text = re.sub(r'\bmy\b', 'the patient\'s', text)

# First person subject: I -> the patient
text = re.sub(r'\bI\b', 'the patient', text)

# First person object: me -> the patient
text = re.sub(r'\bme\b', 'the patient', text)

# First person reflexive: myself -> the patient
text = re.sub(r'\bmyself\b', 'the patient', text)

# Second person: you, your -> the clinician
text = re.sub(r'\bYour\b', 'the clinician', text)
return text


Loading