Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified backend/api/__pycache__/functions.cpython-313.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/views.cpython-313.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions backend/api/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def generate_waf_rule(cve_id: str, description: str, severity: str, mode: str, w
description (str): CVE description
severity (str): CVSS/impact level
mode (str): "JSON" or "cURL"
waf (str): Target WAF provider ("AWS", "Azure", "GCP", "Cloudflare")
waf (str): Target WAF provider ("AWS", "Azure", "GCP", "Cloudflare", "Akamai", "Imperva")
Returns:
dict: { "waf_rule": ... }
"""
Expand Down Expand Up @@ -154,5 +154,5 @@ def generate_testing_code(cve_id: str, description: str, severity: str):
sample_cve_id = "CVE-2025-26000"
sample_description = "A vulnerability in the Python library 'requests' allows attackers to execute arbitrary code via a crafted HTTP request."
sample_severity = "High"
result = generate_exploit(sample_cve_id, sample_description, sample_severity)
result = generate_testing_code(sample_cve_id, sample_description, sample_severity)
print(result)
11 changes: 10 additions & 1 deletion backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,17 @@ def post(self, request):
}
}, status=status.HTTP_201_CREATED)
else:
# Format validation errors for better frontend handling
formatted_errors = {}
for field, errors in serializer.errors.items():
if isinstance(errors, list):
formatted_errors[field] = [str(error) for error in errors]
else:
formatted_errors[field] = [str(errors)]

return Response({
"message": f"User Not Created {serializer.errors}"
"message": "User registration failed",
"errors": formatted_errors
}, status=status.HTTP_400_BAD_REQUEST)

def _store_cve_data_for_user(self, user):
Expand Down
Binary file modified backend/db.sqlite3
Binary file not shown.
49 changes: 43 additions & 6 deletions frontend/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import { useState } from "react"
import { useState, useEffect } from "react"
import { useRouter } from "next/navigation"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
Expand All @@ -14,31 +14,66 @@ export default function LoginPage() {
const [password, setPassword] = useState("")
const [error, setError] = useState("")
const [loading, setLoading] = useState(false)
const { login } = useAuth()
const { login, isAuthenticated, loading: authLoading } = useAuth()
const router = useRouter()

// Redirect if already authenticated
useEffect(() => {
if (!authLoading && isAuthenticated) {
router.push("/dashboard")
}
}, [isAuthenticated, authLoading, router])

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError("")

// Prevent multiple login attempts
if (loading) {
return
}

setLoading(true)

try {
const result = await login(username, password)
if (result.success) {
// Add a small delay to ensure authentication state is properly set
setTimeout(() => {
router.push("/dashboard")
try {
router.push("/dashboard")
} catch (navigationError) {
console.error("Navigation error:", navigationError)
// If navigation fails, the useEffect will handle the redirect
}
}, 100)
} else {
setError(result.error || "Login failed")
setError(result.error || "Login failed. Please check your credentials and try again.")
}
} catch (err) {
setError("An unexpected error occurred")
console.error("Login error:", err)
setError("An unexpected error occurred. Please try again later.")
} finally {
setLoading(false)
}
}

// Show loading state while checking authentication
if (authLoading) {
return (
<div className="min-h-screen flex items-center justify-center bg-black">
<Card className="w-full max-w-md">
<CardContent className="flex items-center justify-center py-8">
<div className="flex flex-col items-center gap-2">
<div className="h-8 w-8 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600"></div>
<p className="text-sm text-muted-foreground">Checking authentication...</p>
</div>
</CardContent>
</Card>
</div>
)
}

return (
<div className="min-h-screen flex items-center justify-center bg-black">
<Card className="w-full max-w-md">
Expand Down Expand Up @@ -73,7 +108,9 @@ export default function LoginPage() {
/>
</div>
{error && (
<div className="text-red-600 text-sm text-center">{error}</div>
<div className="bg-red-50 border border-red-200 rounded-lg p-3">
<div className="text-red-800 text-sm text-center">{error}</div>
</div>
)}
<Button
type="submit"
Expand Down
6 changes: 4 additions & 2 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function LandingPage() {
{
icon: Code,
title: "WAF Rule Generation",
description: "Automatically generate WAF rules for AWS, Azure, GCP, and Cloudflare to protect your applications."
description: "Automatically generate WAF rules for AWS, Azure, GCP, Cloudflare, Akamai, and Imperva to protect your applications."
},
{
icon: BarChart3,
Expand All @@ -48,7 +48,9 @@ export default function LandingPage() {
{ name: "AWS WAF", icon: Cloud, color: "bg-amber-800" },
{ name: "Azure Front Door", icon: Cloud, color: "bg-amber-800" },
{ name: "Google Cloud Armor", icon: Cloud, color: "bg-amber-800" },
{ name: "Cloudflare", icon: Cloud, color: "bg-amber-800" }
{ name: "Cloudflare", icon: Cloud, color: "bg-amber-800" },
{ name: "Akamai", icon: Cloud, color: "bg-amber-800" },
{ name: "Imperva", icon: Cloud, color: "bg-amber-800" }
]

const benefits = [
Expand Down
49 changes: 43 additions & 6 deletions frontend/app/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import { useState } from "react"
import { useState, useEffect } from "react"
import { useRouter } from "next/navigation"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
Expand All @@ -15,31 +15,66 @@ export default function RegisterPage() {
const [email, setEmail] = useState("")
const [error, setError] = useState("")
const [loading, setLoading] = useState(false)
const { register } = useAuth()
const { register, isAuthenticated, loading: authLoading } = useAuth()
const router = useRouter()

// Redirect if already authenticated
useEffect(() => {
if (!authLoading && isAuthenticated) {
router.push("/dashboard")
}
}, [isAuthenticated, authLoading, router])

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError("")

// Prevent multiple registration attempts
if (loading) {
return
}

setLoading(true)

try {
const result = await register(username, password, email)
if (result.success) {
// Add a small delay to ensure authentication state is properly set
setTimeout(() => {
router.push("/dashboard")
try {
router.push("/dashboard")
} catch (navigationError) {
console.error("Navigation error:", navigationError)
// If navigation fails, the useEffect will handle the redirect
}
}, 100)
} else {
setError(result.error || "Registration failed")
setError(result.error || "Registration failed. Please try again.")
}
} catch (err) {
setError("An unexpected error occurred")
console.error("Registration error:", err)
setError("An unexpected error occurred. Please try again later.")
} finally {
setLoading(false)
}
}

// Show loading state while checking authentication
if (authLoading) {
return (
<div className="min-h-screen flex items-center justify-center bg-black">
<Card className="w-full max-w-md">
<CardContent className="flex items-center justify-center py-8">
<div className="flex flex-col items-center gap-2">
<div className="h-8 w-8 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600"></div>
<p className="text-sm text-muted-foreground">Checking authentication...</p>
</div>
</CardContent>
</Card>
</div>
)
}

return (
<div className="min-h-screen flex items-center justify-center bg-black">
<Card className="w-full max-w-md">
Expand Down Expand Up @@ -84,7 +119,9 @@ export default function RegisterPage() {
/>
</div>
{error && (
<div className="text-red-600 text-sm text-center">{error}</div>
<div className="bg-red-50 border border-red-200 rounded-lg p-3">
<div className="text-red-800 text-sm text-center">{error}</div>
</div>
)}
<Button
type="submit"
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/cve-data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,8 @@ function TableCellViewer({ item, onUpdateStatus }: { item: CVE; onUpdateStatus:
<SelectItem value="aws">AWS WAF</SelectItem>
<SelectItem value="gcp">GCP Cloud Armor</SelectItem>
<SelectItem value="cloudflare">Cloudflare</SelectItem>
<SelectItem value="akamai">Akamai</SelectItem>
<SelectItem value="imperva">Imperva</SelectItem>
</SelectContent>
</Select>
</div>
Expand Down
Loading