larxius commited on
Commit
eb44e60
·
verified ·
1 Parent(s): ebc42ea

Update frontend/src/pages/NewScan.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/NewScan.jsx +263 -1
frontend/src/pages/NewScan.jsx CHANGED
@@ -23,6 +23,14 @@ export const NewScan = () => {
23
  const [scheduleFrequency, setScheduleFrequency] = useState('daily');
24
  const [scheduleTime, setScheduleTime] = useState('02:00');
25
 
 
 
 
 
 
 
 
 
26
  const { token, user } = useAuth();
27
  const navigate = useNavigate();
28
 
@@ -76,7 +84,7 @@ export const NewScan = () => {
76
  return (q.allocated_count - q.used_count) > 0;
77
  };
78
 
79
- const handleLaunch = async (e) => {
80
  e.preventDefault();
81
  setError('');
82
 
@@ -106,6 +114,12 @@ export const NewScan = () => {
106
  return;
107
  }
108
 
 
 
 
 
 
 
109
  setLoading(true);
110
 
111
  try {
@@ -590,6 +604,254 @@ export const NewScan = () => {
590
  </div>
591
  )}
592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
  </div>
594
  );
595
  };
 
23
  const [scheduleFrequency, setScheduleFrequency] = useState('daily');
24
  const [scheduleTime, setScheduleTime] = useState('02:00');
25
 
26
+ // Legal & Confirmation Modal States
27
+ const [showConfirmModal, setShowConfirmModal] = useState(false);
28
+ const [showPolicyModal, setShowPolicyModal] = useState(false);
29
+ const [hasReadPolicy, setHasReadPolicy] = useState(false);
30
+ const [policyCheck1, setPolicyCheck1] = useState(false);
31
+ const [policyCheck2, setPolicyCheck2] = useState(false);
32
+ const [isConfirmedChecked, setIsConfirmedChecked] = useState(false);
33
+
34
  const { token, user } = useAuth();
35
  const navigate = useNavigate();
36
 
 
84
  return (q.allocated_count - q.used_count) > 0;
85
  };
86
 
87
+ const handleLaunch = (e) => {
88
  e.preventDefault();
89
  setError('');
90
 
 
114
  return;
115
  }
116
 
117
+ // Open confirmation modal before actual launch
118
+ setShowConfirmModal(true);
119
+ };
120
+
121
+ const executeScan = async () => {
122
+ setShowConfirmModal(false);
123
  setLoading(true);
124
 
125
  try {
 
604
  </div>
605
  )}
606
 
607
+ {/* Confirm Scan Execution Modal Popup */}
608
+ {showConfirmModal && (
609
+ <div className="fixed inset-0 z-[9999] flex items-center justify-center p-4">
610
+ {/* Backdrop */}
611
+ <div
612
+ className="fixed inset-0 bg-slate-900/60 backdrop-blur-sm transition-opacity animate-fade-in"
613
+ onClick={() => setShowConfirmModal(false)}
614
+ ></div>
615
+
616
+ {/* Modal Content */}
617
+ <div className="relative bg-white dark:bg-slate-900 rounded-3xl border border-slate-200 dark:border-slate-800 shadow-2xl max-w-lg w-full p-6 overflow-hidden z-10 animate-slide-up text-left">
618
+
619
+ {/* Header */}
620
+ <div className="flex items-start justify-between pb-4 border-b border-slate-100 dark:border-slate-800">
621
+ <div className="flex items-center gap-3">
622
+ <div className="w-10 h-10 rounded-full bg-blue-600/10 border border-blue-600/20 flex items-center justify-center text-blue-600">
623
+ <span className="material-symbols-outlined text-[24px]">alternate_email</span>
624
+ </div>
625
+ <div>
626
+ <h3 className="text-xl font-bold text-slate-900 dark:text-white tracking-tight">
627
+ Confirm Scan Execution
628
+ </h3>
629
+ <p className="text-xs text-slate-500 dark:text-slate-400 mt-0.5">
630
+ Review target parameters before starting the scan pipeline
631
+ </p>
632
+ </div>
633
+ </div>
634
+ <button
635
+ type="button"
636
+ onClick={() => setShowConfirmModal(false)}
637
+ className="text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 transition-colors bg-transparent border-0 cursor-pointer p-1"
638
+ >
639
+ <span className="material-symbols-outlined text-[20px]">close</span>
640
+ </button>
641
+ </div>
642
+
643
+ {/* Target Parameters Card */}
644
+ <div className="my-5 p-4 rounded-xl bg-slate-50 dark:bg-slate-800/60 border border-slate-200/60 dark:border-slate-700/60 flex flex-col gap-3 font-mono text-xs">
645
+ <div className="flex items-center justify-between">
646
+ <span className="text-slate-500 font-bold uppercase tracking-wider">TARGET URL</span>
647
+ <span className="text-blue-600 dark:text-blue-400 font-bold break-all max-w-[280px] text-right">{targetUrl}</span>
648
+ </div>
649
+ <div className="flex items-center justify-between">
650
+ <span className="text-slate-500 font-bold uppercase tracking-wider">SCAN INTENSITY</span>
651
+ <span className="px-2.5 py-0.5 rounded-full bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 font-sans font-semibold text-[11px]">{scanType} Scan</span>
652
+ </div>
653
+ <div className="flex items-center justify-between">
654
+ <span className="text-slate-500 font-bold uppercase tracking-wider">EXECUTION TYPE</span>
655
+ <span className="text-slate-800 dark:text-slate-200 font-sans font-medium">{isScheduled ? 'Scheduled Execution' : 'Immediate Execution'}</span>
656
+ </div>
657
+ </div>
658
+
659
+ {/* Confirmation Checkbox & Policy Link */}
660
+ <div className="flex flex-col gap-2 mb-5">
661
+ <label className={`flex items-start gap-3 text-xs font-medium text-slate-700 dark:text-slate-300 cursor-pointer ${!hasReadPolicy ? 'opacity-60 cursor-not-allowed' : ''}`}>
662
+ <input
663
+ type="checkbox"
664
+ disabled={!hasReadPolicy}
665
+ checked={isConfirmedChecked}
666
+ onChange={(e) => setIsConfirmedChecked(e.target.checked)}
667
+ className="mt-0.5 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500 cursor-pointer disabled:cursor-not-allowed"
668
+ />
669
+ <span>
670
+ I confirm that I have <strong>explicit written authorization</strong> to execute active penetration testing against <span className="text-blue-600 dark:text-blue-400">{targetUrl}</span>.
671
+ </span>
672
+ </label>
673
+
674
+ <div className="pl-7">
675
+ {hasReadPolicy ? (
676
+ <span className="inline-flex items-center gap-1 text-xs font-semibold text-emerald-600 dark:text-emerald-400">
677
+ <span className="material-symbols-outlined text-[16px]">check_circle</span>
678
+ Security Policy Read & Accepted
679
+ </span>
680
+ ) : (
681
+ <button
682
+ type="button"
683
+ onClick={() => setShowPolicyModal(true)}
684
+ className="text-xs font-semibold text-blue-600 dark:text-blue-400 hover:underline bg-transparent border-0 p-0 cursor-pointer text-left"
685
+ >
686
+ Read Security Policy & Authorization Terms
687
+ </button>
688
+ )}
689
+ </div>
690
+ </div>
691
+
692
+ {/* Warning Box */}
693
+ <div className="p-4 rounded-xl bg-amber-50 dark:bg-amber-950/30 border border-amber-200/80 dark:border-amber-800/50 text-amber-800 dark:text-amber-300 text-xs leading-relaxed flex items-start gap-3 mb-6">
694
+ <span className="material-symbols-outlined text-amber-600 dark:text-amber-400 text-[20px] shrink-0 mt-0.5">help_outline</span>
695
+ <div>
696
+ Are you sure you want to run this scan on <strong className="text-amber-900 dark:text-amber-200">{targetUrl}</strong>? If you are sure, read the security policy to enable the confirmation box, check it, and click <strong>Yes, Start Scan</strong>.
697
+ </div>
698
+ </div>
699
+
700
+ {/* Action Buttons */}
701
+ <div className="flex items-center justify-end gap-3 pt-3 border-t border-slate-100 dark:border-slate-800">
702
+ <button
703
+ type="button"
704
+ onClick={() => setShowConfirmModal(false)}
705
+ className="px-5 py-2.5 rounded-xl text-xs font-bold text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 cursor-pointer"
706
+ >
707
+ No, Cancel
708
+ </button>
709
+ <button
710
+ type="button"
711
+ disabled={!hasReadPolicy || !isConfirmedChecked || loading}
712
+ onClick={executeScan}
713
+ className="px-5 py-2.5 rounded-xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-md shadow-blue-600/20 flex items-center gap-1.5 cursor-pointer border-0"
714
+ >
715
+ <span className="material-symbols-outlined text-[16px]">play_circle</span>
716
+ <span>{loading ? "Initiating..." : "Yes, Start Scan"}</span>
717
+ </button>
718
+ </div>
719
+ </div>
720
+ </div>
721
+ )}
722
+
723
+ {/* Security Policy & Legal Disclaimer Modal */}
724
+ {showPolicyModal && (
725
+ <div className="fixed inset-0 z-[10000] flex items-center justify-center p-4">
726
+ {/* Backdrop */}
727
+ <div
728
+ className="fixed inset-0 bg-slate-900/70 backdrop-blur-md transition-opacity animate-fade-in"
729
+ onClick={() => setShowPolicyModal(false)}
730
+ ></div>
731
+
732
+ {/* Modal Content */}
733
+ <div className="relative bg-white dark:bg-slate-900 rounded-3xl border border-slate-200 dark:border-slate-800 shadow-2xl max-w-2xl w-full p-6 overflow-hidden z-10 animate-slide-up text-left flex flex-col max-h-[85vh]">
734
+
735
+ {/* Modal Header */}
736
+ <div className="flex items-center justify-between pb-4 border-b border-slate-100 dark:border-slate-800 shrink-0">
737
+ <div className="flex items-center gap-2.5">
738
+ <span className="material-symbols-outlined text-blue-600 dark:text-blue-400 text-[24px]">gavel</span>
739
+ <h3 className="text-lg font-bold text-slate-900 dark:text-white tracking-tight">
740
+ Security Policy & Legal Disclaimer
741
+ </h3>
742
+ </div>
743
+ <button
744
+ type="button"
745
+ onClick={() => setShowPolicyModal(false)}
746
+ className="text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 transition-colors bg-transparent border-0 cursor-pointer p-1"
747
+ >
748
+ <span className="material-symbols-outlined text-[20px]">close</span>
749
+ </button>
750
+ </div>
751
+
752
+ {/* Modal Body - Policy Content (Scrollable) */}
753
+ <div className="my-4 overflow-y-auto pr-2 flex-1 text-xs text-slate-600 dark:text-slate-300 leading-relaxed space-y-4 font-sans">
754
+ <div className="p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200/60 dark:border-slate-700/60 font-mono text-[11px] text-slate-500">
755
+ <div><strong>Effective Date:</strong> August 15, 2026</div>
756
+ <div><strong>Applies to:</strong> All users of the Larshield vulnerability scanning platform ("the Service")</div>
757
+ </div>
758
+
759
+ <div>
760
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">1. Explicit Authorization and Legal Compliance</h4>
761
+ <p>By initiating any scan, probe, or assessment through Larshield, you explicitly certify, represent, and warrant that you possess full, documented, and legally verifiable authorization from the owner of the target system to conduct active security assessments, penetration testing, or vulnerability scanning against it.</p>
762
+ <p className="mt-2">You acknowledge that scanning any computer, network, or application without proper authorization is illegal under applicable law — including, without limitation, the Computer Fraud and Abuse Act (US), the Computer Misuse Act (UK), the Information Technology Act (India), and equivalent statutes in other jurisdictions. Larshield is intended strictly for authorized security testing, such as systems you own, systems within a scope you have been contractually engaged to test, or environments explicitly designated for security research (e.g., CTF ranges, bug bounty programs with defined scope).</p>
763
+ </div>
764
+
765
+ <div>
766
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">2. Assumption of Risk & Potential Impact</h4>
767
+ <p>You acknowledge that vulnerability scanning and penetration testing are inherently intrusive activities. Depending on configuration, they may involve port scanning, service fingerprinting, exploitation simulation, or payload delivery, any of which could cause service degradation, data loss, or downtime on the target system.</p>
768
+ <p className="mt-2">By using Larshield, you accept full responsibility for any operational impact resulting from your use of the tool, and you agree to take reasonable precautions (e.g., scheduling scans during maintenance windows, using rate-limited or passive modes where appropriate) when testing production systems.</p>
769
+ </div>
770
+
771
+ <div>
772
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">3. Indemnification and Hold Harmless</h4>
773
+ <p>You agree to indemnify, defend, and hold harmless the Larshield project, its developer(s), contributors, and affiliates from any claims, damages, liabilities, costs, or losses (including reasonable legal fees) arising from your use of the Service — including any unauthorized or improper use.</p>
774
+ <p className="mt-2">Larshield is provided on an "AS IS" and "AS AVAILABLE" basis, without warranties of any kind, express or implied, including but not limited to fitness for a particular purpose or non-infringement. Larshield and its creators shall not be liable for any direct, indirect, incidental, or consequential damages resulting from use or misuse of the Service.</p>
775
+ </div>
776
+
777
+ <div>
778
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">4. Audit Logging and Cooperation with Authorities</h4>
779
+ <p>Larshield logs scan activity, including origin IP address, timestamp, scan configuration, and target parameters, for security, abuse-prevention, and accountability purposes.</p>
780
+ <p className="mt-2">In the event of an investigation into unauthorized access, abuse, or a legal inquiry, Larshield reserves the right to share relevant audit logs with law enforcement, hosting providers, or the affected system owner, as required or permitted by law.</p>
781
+ </div>
782
+
783
+ <div>
784
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">5. Acceptable Use</h4>
785
+ <p>You agree not to use Larshield to:</p>
786
+ <ul className="list-disc pl-5 mt-1 space-y-1">
787
+ <li>Scan or test any system without documented authorization from its owner</li>
788
+ <li>Deliver malicious payloads intended to cause damage beyond what is necessary for a legitimate, authorized assessment</li>
789
+ <li>Circumvent rate limits or access controls of third-party systems outside an agreed testing scope</li>
790
+ </ul>
791
+ </div>
792
+
793
+ <div>
794
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">6. Data Handling</h4>
795
+ <p>Scan results are stored per-user and are not shared with third parties except as required under Section 4.</p>
796
+ </div>
797
+
798
+ <div>
799
+ <h4 className="font-bold text-slate-900 dark:text-white text-xs mb-1">7. Changes to This Policy</h4>
800
+ <p>Larshield may update this policy from time to time. Continued use of the Service after changes are posted constitutes acceptance of the revised policy.</p>
801
+ </div>
802
+
803
+ <p className="pt-2 font-semibold text-slate-900 dark:text-white">
804
+ By clicking "I Accept" below, you confirm that you have read, understood, and agree to be bound by this Security Policy & EULA.
805
+ </p>
806
+
807
+ {/* Checkbox Section inside Modal */}
808
+ <div className="p-4 bg-slate-100 dark:bg-slate-800 rounded-xl border border-slate-200 dark:border-slate-700 flex flex-col gap-2.5 mt-4">
809
+ <label className="flex items-center gap-2.5 text-xs font-semibold text-slate-800 dark:text-slate-200 cursor-pointer">
810
+ <input
811
+ type="checkbox"
812
+ checked={policyCheck1}
813
+ onChange={(e) => setPolicyCheck1(e.target.checked)}
814
+ className="h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500 cursor-pointer"
815
+ />
816
+ <span>I have read and agree to the terms above</span>
817
+ </label>
818
+ <label className="flex items-center gap-2.5 text-xs font-semibold text-slate-800 dark:text-slate-200 cursor-pointer">
819
+ <input
820
+ type="checkbox"
821
+ checked={policyCheck2}
822
+ onChange={(e) => setPolicyCheck2(e.target.checked)}
823
+ className="h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500 cursor-pointer"
824
+ />
825
+ <span>I certify that I have authorization to scan any target(s) I submit to this Service</span>
826
+ </label>
827
+ </div>
828
+ </div>
829
+
830
+ {/* Modal Footer */}
831
+ <div className="flex items-center justify-end gap-3 pt-4 border-t border-slate-100 dark:border-slate-800 shrink-0">
832
+ <button
833
+ type="button"
834
+ onClick={() => setShowPolicyModal(false)}
835
+ className="px-5 py-2.5 rounded-xl text-xs font-bold text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 cursor-pointer"
836
+ >
837
+ Cancel
838
+ </button>
839
+ <button
840
+ type="button"
841
+ disabled={!policyCheck1 || !policyCheck2}
842
+ onClick={() => {
843
+ setHasReadPolicy(true);
844
+ setShowPolicyModal(false);
845
+ }}
846
+ className="px-6 py-2.5 rounded-xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-md shadow-blue-600/20 cursor-pointer border-0"
847
+ >
848
+ I Accept
849
+ </button>
850
+ </div>
851
+ </div>
852
+ </div>
853
+ )}
854
+
855
  </div>
856
  );
857
  };