Skip to content

Commit 9816d85

Browse files
Copilotamitdevx
andauthored
Security audit: Fix vulnerabilities and harden application (#3)
* Initial plan * Fix security vulnerabilities and type safety issues Co-authored-by: uffamit <110670491+uffamit@users.noreply.github.com> * Add file size validation and remove database files from git tracking Co-authored-by: uffamit <110670491+uffamit@users.noreply.github.com>
1 parent 32d39ed commit 9816d85

11 files changed

Lines changed: 531 additions & 545 deletions

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ next-env.d.ts
4242

4343
# firebase
4444
firebase-debug.log
45-
firestore-debug.log
45+
firestore-debug.log
46+
47+
# database files
48+
*.sqlite
49+
*.sqlite-shm
50+
*.sqlite-wal

database.sqlite

-4 KB
Binary file not shown.

database.sqlite-shm

-32 KB
Binary file not shown.

database.sqlite-wal

-40.3 KB
Binary file not shown.

package-lock.json

Lines changed: 373 additions & 346 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"genkit:watch": "genkit start -- tsx --watch src/ai/dev.ts",
88
"build": "npx next build",
99
"start": "npx next start",
10-
"lint": "npx next lint --max-warnings=0 --no-error-on-unmatched-pattern",
10+
"lint": "npx next lint",
1111
"typecheck": "tsc --noEmit"
1212
},
1313
"dependencies": {
@@ -43,7 +43,7 @@
4343
"genkit": "^1.8.0",
4444
"html2canvas": "^1.4.1",
4545
"lucide-react": "^0.475.0",
46-
"next": "15.3.3",
46+
"next": "^15.5.6",
4747
"patch-package": "^8.0.0",
4848
"react": "^18.3.1",
4949
"react-day-picker": "^8.10.1",
@@ -66,4 +66,4 @@
6666
"typescript": "^5"
6767
},
6868
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
69-
}
69+
}

src/ai/flows/assess-health-safety.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Your analysis must be objective and based on general nutritional science. Be con
102102
inputSchema: AssessHealthSafetyInputSchema,
103103
outputSchema: AssessHealthSafetyOutputSchema,
104104
},
105-
async (input) => {
105+
async (input: AssessHealthSafetyInput) => {
106106
const {output} = await prompt(input);
107107
if (!output) {
108108
throw new Error('The AI model failed to provide an assessment.');

src/ai/flows/extract-ingredients.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Image to analyze: {{media url=image}}`,
4848
inputSchema: ExtractIngredientsInputSchema,
4949
outputSchema: ExtractIngredientsOutputSchema,
5050
},
51-
async (input) => {
51+
async (input: ExtractIngredientsInput) => {
5252
const {output} = await prompt(input);
5353
if (!output) {
5454
return {

src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function HomePage() {
4343
<div className="container px-4 md:px-6">
4444
<div className="flex flex-col items-center justify-center space-y-4 text-center mb-12">
4545
<div className="inline-block rounded-lg bg-secondary px-3 py-1 text-sm text-secondary-foreground font-semibold">Key Features</div>
46-
<h2 className="text-3xl font-bold tracking-tighter sm:text-5xl font-headline">Why You'll Love EatInformed</h2>
46+
<h2 className="text-3xl font-bold tracking-tighter sm:text-5xl font-headline">Why You&apos;ll Love EatInformed</h2>
4747
<p className="max-w-[900px] text-muted-foreground md:text-xl/relaxed">
4848
We provide the tools you need for food clarity.
4949
</p>
@@ -75,7 +75,7 @@ export default function HomePage() {
7575
<div className="inline-block rounded-lg bg-secondary px-3 py-1 text-sm text-secondary-foreground font-semibold">How It Works</div>
7676
<h2 className="text-3xl font-bold tracking-tighter sm:text-5xl font-headline">Simple Steps to Food Clarity</h2>
7777
<p className="max-w-[900px] text-muted-foreground md:text-xl/relaxed lg:text-base/relaxed xl:text-xl/relaxed">
78-
Discovering what's in your food has never been easier.
78+
Discovering what&apos;s in your food has never been easier.
7979
</p>
8080
</div>
8181
<div className="mx-auto grid max-w-5xl items-start gap-8 sm:grid-cols-2 md:gap-12 lg:grid-cols-3 lg:gap-16 mt-12">

src/components/features/ImageUploadForm.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ export function CheckPageClient() {
109109
});
110110
return;
111111
}
112+
// Security: Limit file size to 10MB to prevent DoS attacks
113+
const maxSizeInBytes = 10 * 1024 * 1024; // 10MB
114+
if (file.size > maxSizeInBytes) {
115+
toast({
116+
variant: 'destructive',
117+
title: 'File Too Large',
118+
description: 'Please upload an image smaller than 10MB.',
119+
});
120+
return;
121+
}
112122
const reader = new FileReader();
113123
reader.onloadend = () => {
114124
const dataUri = reader.result as string;

0 commit comments

Comments
 (0)