-
Notifications
You must be signed in to change notification settings - Fork 284
[dev] [claudfuen] feat/pentest-subscription-billing #2220
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
Draft
github-actions
wants to merge
10
commits into
main
Choose a base branch
from
feat/pentest-subscription-billing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f852262
refactor(ui): improve nav icons + remove overview drag-and-drop
claudfuen 9d9c947
revert(ui): restore original compliance sidebar icons
claudfuen 3d282ab
fix(billing): look up run by providerRunId not internal id
claudfuen 16b6745
Merge branch 'main' of https://github.com/trycompai/comp into feat/pe…
claudfuen 1b02738
feat(pentest): gate penetration tests page behind subscription
claudfuen ec41dab
feat(pentest): add billing enforcement, usage tracking, and billing page
claudfuen 1b06c7a
fix(pentest): address PR review feedback
claudfuen 11d6e90
Merge branch 'main' into feat/pentest-subscription-billing
claudfuen aad0642
docs: rewrite README with cleaner structure and updated positioning
claudfuen ee6d513
fix: replace react-wrap-balancer with text-balance, fix prisma config…
claudfuen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
165 changes: 165 additions & 0 deletions
165
...src/app/(app)/[orgId]/security/penetration-tests/components/pentest-preview-animation.tsx
This file contains hidden or 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,165 @@ | ||
| 'use client'; | ||
|
|
||
| import { useEffect, useState } from 'react'; | ||
| import { AlertTriangle, CheckCircle2, Loader2, Shield, ShieldAlert } from 'lucide-react'; | ||
|
|
||
| interface Finding { | ||
| severity: 'critical' | 'high' | 'medium' | 'low'; | ||
| title: string; | ||
| location: string; | ||
| } | ||
|
|
||
| const findings: Finding[] = [ | ||
| { severity: 'critical', title: 'SQL Injection in /api/users', location: 'POST /api/users?search=' }, | ||
| { severity: 'high', title: 'Stored XSS in comments', location: 'POST /api/comments' }, | ||
| { severity: 'high', title: 'Broken access control', location: 'GET /api/admin/settings' }, | ||
| { severity: 'medium', title: 'Missing rate limiting', location: 'POST /api/auth/login' }, | ||
| { severity: 'medium', title: 'Insecure CORS policy', location: 'Origin: *' }, | ||
| { severity: 'low', title: 'Missing security headers', location: 'X-Frame-Options' }, | ||
| ]; | ||
|
|
||
| const agents = [ | ||
| 'Reconnaissance', | ||
| 'Authentication testing', | ||
| 'Injection testing', | ||
| 'Access control audit', | ||
| 'Configuration review', | ||
| ]; | ||
|
|
||
| const severityColors = { | ||
| critical: 'bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-400', | ||
| high: 'bg-orange-100 text-orange-700 dark:bg-orange-950/40 dark:text-orange-400', | ||
| medium: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-950/40 dark:text-yellow-400', | ||
| low: 'bg-blue-100 text-blue-700 dark:bg-blue-950/40 dark:text-blue-400', | ||
| }; | ||
|
|
||
| export function PentestPreviewAnimation() { | ||
| const [progress, setProgress] = useState(0); | ||
| const [currentAgent, setCurrentAgent] = useState(0); | ||
| const [visibleFindings, setVisibleFindings] = useState(0); | ||
| const [phase, setPhase] = useState<'scanning' | 'complete'>('scanning'); | ||
|
|
||
| useEffect(() => { | ||
| const totalDuration = 8000; | ||
| const interval = 50; | ||
| let elapsed = 0; | ||
|
|
||
| let pausing = false; | ||
|
|
||
| const timer = setInterval(() => { | ||
| if (pausing) return; | ||
|
|
||
| elapsed += interval; | ||
| const t = elapsed / totalDuration; | ||
|
|
||
| if (t >= 1) { | ||
| setPhase('complete'); | ||
| setProgress(100); | ||
| setVisibleFindings(findings.length); | ||
| setCurrentAgent(agents.length - 1); | ||
|
|
||
| // Pause, then reset once | ||
| pausing = true; | ||
| setTimeout(() => { | ||
| elapsed = 0; | ||
| pausing = false; | ||
| setPhase('scanning'); | ||
| setProgress(0); | ||
| setVisibleFindings(0); | ||
| setCurrentAgent(0); | ||
| }, 3000); | ||
| return; | ||
| } | ||
|
|
||
| // Progress with easing | ||
| const eased = t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2; | ||
| setProgress(Math.round(eased * 100)); | ||
|
|
||
| // Cycle through agents | ||
| setCurrentAgent(Math.min(Math.floor(t * agents.length), agents.length - 1)); | ||
|
|
||
| // Reveal findings progressively | ||
| setVisibleFindings(Math.floor(t * (findings.length + 1))); | ||
| }, interval); | ||
|
|
||
| return () => clearInterval(timer); | ||
| }, []); | ||
|
|
||
| const isComplete = phase === 'complete'; | ||
|
|
||
| return ( | ||
| <div className="px-5 py-4"> | ||
| {/* Header */} | ||
| <div className="flex items-center justify-between mb-4"> | ||
| <div className="flex items-center gap-2"> | ||
| {isComplete ? ( | ||
| <ShieldAlert className="h-4 w-4 text-orange-500" /> | ||
| ) : ( | ||
| <Shield className="h-4 w-4 text-primary animate-pulse" /> | ||
| )} | ||
| <span className="font-semibold text-sm">app.acme.com</span> | ||
| {isComplete ? ( | ||
| <span className="rounded-full bg-green-100 text-green-700 dark:bg-green-950/40 dark:text-green-400 px-2 py-0.5 text-[10px] font-medium"> | ||
| Complete | ||
| </span> | ||
| ) : ( | ||
| <span className="rounded-full bg-primary/10 text-primary px-2 py-0.5 text-[10px] font-medium"> | ||
| Running | ||
| </span> | ||
| )} | ||
| </div> | ||
| <span className="text-xs text-muted-foreground font-mono">{progress}%</span> | ||
| </div> | ||
|
|
||
| {/* Progress bar */} | ||
| <div className="h-1.5 w-full rounded-full bg-muted overflow-hidden mb-4"> | ||
| <div | ||
| className="h-full rounded-full transition-all duration-100 ease-out" | ||
| style={{ | ||
| width: `${progress}%`, | ||
| backgroundColor: isComplete ? 'var(--color-green-500, #22c55e)' : 'var(--color-primary)', | ||
| }} | ||
| /> | ||
| </div> | ||
|
|
||
| {/* Current agent */} | ||
| {!isComplete && ( | ||
| <div className="flex items-center gap-2 mb-4 text-xs text-muted-foreground"> | ||
| <Loader2 className="h-3 w-3 animate-spin text-primary" /> | ||
| <span>{agents[currentAgent]}…</span> | ||
| <span className="ml-auto">{currentAgent + 1}/{agents.length} agents</span> | ||
| </div> | ||
| )} | ||
|
|
||
| {isComplete && ( | ||
| <div className="flex items-center gap-2 mb-4 text-xs text-muted-foreground"> | ||
| <CheckCircle2 className="h-3 w-3 text-green-500" /> | ||
| <span>Scan complete — {findings.length} findings</span> | ||
| <span className="ml-auto">5/5 agents</span> | ||
| </div> | ||
| )} | ||
|
|
||
| {/* Findings */} | ||
| <div className="space-y-0 divide-y"> | ||
| {findings.slice(0, visibleFindings).map((finding, i) => ( | ||
| <div | ||
| key={finding.title} | ||
| className="flex items-center justify-between py-2.5 animate-in fade-in slide-in-from-bottom-1 duration-300" | ||
| style={{ animationDelay: `${i * 50}ms` }} | ||
| > | ||
| <div className="flex items-center gap-2.5 min-w-0"> | ||
| <AlertTriangle className="h-3.5 w-3.5 shrink-0 text-muted-foreground" /> | ||
| <div className="min-w-0"> | ||
| <p className="text-xs font-medium truncate">{finding.title}</p> | ||
| <p className="text-[10px] text-muted-foreground font-mono truncate">{finding.location}</p> | ||
| </div> | ||
| </div> | ||
| <span className={`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase ${severityColors[finding.severity]}`}> | ||
| {finding.severity} | ||
| </span> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.