@@ -168,7 +168,12 @@ impl ComplianceScanner {
168168 }
169169
170170 /// Scan for PCI-DSS compliance
171- pub fn scan_pci_dss ( & self , target : & str , open_ports : & [ u16 ] , services : & HashMap < u16 , String > ) -> ComplianceResult {
171+ pub fn scan_pci_dss (
172+ & self ,
173+ target : & str ,
174+ open_ports : & [ u16 ] ,
175+ services : & HashMap < u16 , String > ,
176+ ) -> ComplianceResult {
172177 let mut result = ComplianceResult :: new ( target, ComplianceFramework :: PCIDSS ) ;
173178
174179 // PCI-DSS 1.3.1 - Restrict inbound traffic
@@ -193,7 +198,12 @@ impl ComplianceScanner {
193198 }
194199
195200 /// Scan for CIS Benchmark compliance
196- pub fn scan_cis_benchmark ( & self , target : & str , open_ports : & [ u16 ] , services : & HashMap < u16 , String > ) -> ComplianceResult {
201+ pub fn scan_cis_benchmark (
202+ & self ,
203+ target : & str ,
204+ open_ports : & [ u16 ] ,
205+ services : & HashMap < u16 , String > ,
206+ ) -> ComplianceResult {
197207 let mut result = ComplianceResult :: new ( target, ComplianceFramework :: CISBenchmark ) ;
198208
199209 // CIS Control 4.1 - Secure configuration
@@ -238,12 +248,19 @@ impl ComplianceScanner {
238248 description : "No insecure or unnecessary ports should be accessible" . to_string ( ) ,
239249 status,
240250 evidence,
241- remediation : Some ( "Close or firewall prohibited ports: Telnet (23), FTP (21), TFTP (69)" . to_string ( ) ) ,
251+ remediation : Some (
252+ "Close or firewall prohibited ports: Telnet (23), FTP (21), TFTP (69)" . to_string ( ) ,
253+ ) ,
242254 } ) ;
243255 }
244256
245257 /// Check encryption requirements (PCI-DSS 2.2.7)
246- fn check_encryption_required ( & self , result : & mut ComplianceResult , open_ports : & [ u16 ] , services : & HashMap < u16 , String > ) {
258+ fn check_encryption_required (
259+ & self ,
260+ result : & mut ComplianceResult ,
261+ open_ports : & [ u16 ] ,
262+ _services : & HashMap < u16 , String > ,
263+ ) {
247264 let unencrypted: Vec < u16 > = open_ports
248265 . iter ( )
249266 . filter ( |p| self . port_config . encryption_required_ports . contains ( p) )
@@ -265,16 +282,24 @@ impl ComplianceScanner {
265282 result. add_check ( ComplianceCheck {
266283 id : "PCI-DSS-2.2.7" . to_string ( ) ,
267284 framework : ComplianceFramework :: PCIDSS ,
268- requirement : "Use strong cryptography for non-console administrative access" . to_string ( ) ,
285+ requirement : "Use strong cryptography for non-console administrative access"
286+ . to_string ( ) ,
269287 description : "All administrative access must be encrypted" . to_string ( ) ,
270288 status,
271289 evidence,
272- remediation : Some ( "Replace HTTP with HTTPS, use IMAPS/POP3S instead of IMAP/POP3" . to_string ( ) ) ,
290+ remediation : Some (
291+ "Replace HTTP with HTTPS, use IMAPS/POP3S instead of IMAP/POP3" . to_string ( ) ,
292+ ) ,
273293 } ) ;
274294 }
275295
276296 /// Check secure administrative access (PCI-DSS 2.3)
277- fn check_secure_admin ( & self , result : & mut ComplianceResult , open_ports : & [ u16 ] , _services : & HashMap < u16 , String > ) {
297+ fn check_secure_admin (
298+ & self ,
299+ result : & mut ComplianceResult ,
300+ open_ports : & [ u16 ] ,
301+ _services : & HashMap < u16 , String > ,
302+ ) {
278303 // Check for SSH (secure) vs Telnet (insecure)
279304 let has_telnet = open_ports. contains ( & 23 ) ;
280305 let has_ssh = open_ports. contains ( & 22 ) ;
@@ -300,7 +325,9 @@ impl ComplianceScanner {
300325 description : "Use SSH instead of Telnet for remote administration" . to_string ( ) ,
301326 status,
302327 evidence,
303- remediation : Some ( "Disable Telnet and use SSH with key-based authentication" . to_string ( ) ) ,
328+ remediation : Some (
329+ "Disable Telnet and use SSH with key-based authentication" . to_string ( ) ,
330+ ) ,
304331 } ) ;
305332 }
306333
@@ -328,7 +355,8 @@ impl ComplianceScanner {
328355 result. add_check ( ComplianceCheck {
329356 id : "PCI-DSS-4.1" . to_string ( ) ,
330357 framework : ComplianceFramework :: PCIDSS ,
331- requirement : "Use strong cryptography to protect cardholder data during transmission" . to_string ( ) ,
358+ requirement : "Use strong cryptography to protect cardholder data during transmission"
359+ . to_string ( ) ,
332360 description : "All data transmission must be encrypted with TLS 1.2+" . to_string ( ) ,
333361 status,
334362 evidence,
@@ -337,7 +365,11 @@ impl ComplianceScanner {
337365 }
338366
339367 /// Check for insecure protocols (PCI-DSS 6.5.4)
340- fn check_insecure_protocols ( & self , result : & mut ComplianceResult , services : & HashMap < u16 , String > ) {
368+ fn check_insecure_protocols (
369+ & self ,
370+ result : & mut ComplianceResult ,
371+ services : & HashMap < u16 , String > ,
372+ ) {
341373 let insecure_services: Vec < String > = services
342374 . values ( )
343375 . filter ( |s| {
@@ -410,12 +442,19 @@ impl ComplianceScanner {
410442 description : "Minimize attack surface by closing unnecessary ports" . to_string ( ) ,
411443 status,
412444 evidence : format ! ( "High-risk ports open: {:?}" , high_risk_ports) ,
413- remediation : Some ( "Close or restrict high-risk ports, use encrypted alternatives" . to_string ( ) ) ,
445+ remediation : Some (
446+ "Close or restrict high-risk ports, use encrypted alternatives" . to_string ( ) ,
447+ ) ,
414448 } ) ;
415449 }
416450
417451 /// Check for unnecessary services (CIS Control 4.8)
418- fn check_unnecessary_services ( & self , result : & mut ComplianceResult , open_ports : & [ u16 ] , _services : & HashMap < u16 , String > ) {
452+ fn check_unnecessary_services (
453+ & self ,
454+ result : & mut ComplianceResult ,
455+ open_ports : & [ u16 ] ,
456+ _services : & HashMap < u16 , String > ,
457+ ) {
419458 let common_unnecessary: Vec < u16 > = open_ports
420459 . iter ( )
421460 . filter ( |p| [ 7 , 9 , 13 , 17 , 19 , 37 , 79 ] . contains ( p) )
@@ -435,7 +474,9 @@ impl ComplianceScanner {
435474 description : "Legacy and unnecessary services should be disabled" . to_string ( ) ,
436475 status,
437476 evidence : format ! ( "Unnecessary service ports: {:?}" , common_unnecessary) ,
438- remediation : Some ( "Disable echo, discard, daytime, chargen, finger services" . to_string ( ) ) ,
477+ remediation : Some (
478+ "Disable echo, discard, daytime, chargen, finger services" . to_string ( ) ,
479+ ) ,
439480 } ) ;
440481 }
441482
@@ -458,7 +499,9 @@ impl ComplianceScanner {
458499 description : "Limit network exposure to minimum necessary ports" . to_string ( ) ,
459500 status,
460501 evidence : format ! ( "{} ports open: {:?}" , port_count, open_ports) ,
461- remediation : Some ( "Review and close unnecessary ports, implement firewall rules" . to_string ( ) ) ,
502+ remediation : Some (
503+ "Review and close unnecessary ports, implement firewall rules" . to_string ( ) ,
504+ ) ,
462505 } ) ;
463506 }
464507}
0 commit comments