@@ -59,25 +59,25 @@ test("Should create subsequent scans for open HTTPS ports (NMAP findings)", asyn
5959
6060 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 1 , {
6161 name : "sslyze-foobar.com" ,
62- parameters : [ "--regular" , "foobar.com" ] ,
62+ parameters : [ "--regular" , "foobar.com:443 " ] ,
6363 parentScan : { metadata : { labels : { foo : "bar" } } } ,
6464 scanType : "sslyze" ,
6565 } ) ;
6666 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 2 , {
67- name : "zap-foobar.com" ,
67+ name : "zap-https- foobar.com" ,
6868 parameters : [ "-t" , "https://foobar.com:443" ] ,
6969 parentScan : { metadata : { labels : { foo : "bar" } } } ,
7070 scanType : "zap-baseline" ,
7171 } ) ;
72- // even if the HTTP port is not running at port 80 a corresponding Nikto scan should be created if a HTTP service is found by nmap
72+ // even if the HTTPS port is not running at port 443 a corresponding Sslyze scan should be created if a HTTP service is found by nmap
7373 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 3 , {
7474 name : "sslyze-example.com" ,
75- parameters : [ "--regular" , "example.com" ] ,
75+ parameters : [ "--regular" , "example.com:8443 " ] ,
7676 parentScan : { metadata : { labels : { foo : "bar" } } } ,
7777 scanType : "sslyze" ,
7878 } ) ;
7979 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 4 , {
80- name : "zap-example.com" ,
80+ name : "zap-https- example.com" ,
8181 parameters : [ "-t" , "https://example.com:8443" ] ,
8282 parentScan : { metadata : { labels : { foo : "bar" } } } ,
8383 scanType : "zap-baseline" ,
@@ -139,15 +139,15 @@ test("Should create subsequent scans for open HTTP ports (NMAP findings)", async
139139 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenCalledTimes ( 6 ) ;
140140
141141 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 5 , {
142- name : "nikto-foobar.com" ,
143- parameters : [ "-h" , "https ://foobar.com" , "-Tuning" , "1,2,3,5,7,b" ] ,
142+ name : "nikto-http- foobar.com" ,
143+ parameters : [ "-h" , "http ://foobar.com" , "-p" , "80 ", "-Tuning" , "1,2,3,5,7,b" ] ,
144144 parentScan : { metadata : { labels : { foo : "bar" } } } ,
145145 scanType : "nikto" ,
146146 } ) ;
147147 // even if the HTTP port is not running at port 80 a corresponding Nikto scan should be created if a HTTP service is found by nmap
148148 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 6 , {
149- name : "nikto-example.com" ,
150- parameters : [ "-h" , "https ://example.com" , "-Tuning" , "1,2,3,5,7,b" ] ,
149+ name : "nikto-http- example.com" ,
150+ parameters : [ "-h" , "http ://example.com" , "-p" , "3000 ", "-Tuning" , "1,2,3,5,7,b" ] ,
151151 parentScan : { metadata : { labels : { foo : "bar" } } } ,
152152 scanType : "nikto" ,
153153 } ) ;
@@ -209,14 +209,14 @@ test("Should create subsequent scans for open SSH ports (NMAP findings)", async
209209
210210 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 7 , {
211211 name : "ssh-foobar.com" ,
212- parameters : [ "-t" , "foobar.com" ] ,
212+ parameters : [ "-t" , "foobar.com" , "-p" , "22" ] ,
213213 parentScan : { metadata : { labels : { foo : "bar" } } } ,
214214 scanType : "ssh-scan" ,
215215 } ) ;
216216 // even if the HTTP port is not running at port 80 a corresponding Nikto scan should be created if a HTTP service is found by nmap
217217 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 8 , {
218218 name : "ssh-example.com" ,
219- parameters : [ "-t" , "example.com" ] ,
219+ parameters : [ "-t" , "example.com" , "-p" , "23454" ] ,
220220 parentScan : { metadata : { labels : { foo : "bar" } } } ,
221221 scanType : "ssh-scan" ,
222222 } ) ;
@@ -581,4 +581,110 @@ test("Should not create subsequent scans if no subsequent scan is activated", as
581581 } ) ;
582582
583583 expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenCalledTimes ( 12 ) ;
584+ } ) ;
585+
586+ test ( "Should create subsequent scans for Service which are running in custom ports" , async ( ) => {
587+ const findings = [
588+ {
589+ name : "Port 22000 is open" ,
590+ category : "Open Port" ,
591+ attributes : {
592+ state : "open" ,
593+ hostname : "ssh.example.com" ,
594+ port : 22000 ,
595+ service : "ssh" ,
596+ } ,
597+ } ,
598+ {
599+ name : "Port 8000 is open" ,
600+ category : "Open Port" ,
601+ attributes : {
602+ state : "open" ,
603+ hostname : "http.example.com" ,
604+ port : 8000 ,
605+ service : "http" ,
606+ } ,
607+ } ,
608+ {
609+ name : "Port 3000 is open" ,
610+ category : "Open Port" ,
611+ attributes : {
612+ state : "open" ,
613+ hostname : "https.example.com" ,
614+ port : 3000 ,
615+ service : "https" ,
616+ } ,
617+ } ,
618+ {
619+ name : "Port 8443 is open" ,
620+ category : "Open Port" ,
621+ attributes : {
622+ state : "open" ,
623+ hostname : "ssl.example.com" ,
624+ port : 8443 ,
625+ service : "ssl" ,
626+ } ,
627+ }
628+ ] ;
629+
630+ const scan = {
631+ metadata : {
632+ labels : {
633+ foo : "bar" ,
634+ } ,
635+ } ,
636+ } ;
637+
638+ const cascadeAmassNmap = true ;
639+ const cascadeNmapSsl = true ;
640+ const cascadeNmapSsh = true ;
641+ const cascadeNmapNikto = true ;
642+ const cascadeNmapSmb = true ;
643+ const cascadeNmapZapBaseline = true ;
644+
645+ const getFindings = async ( ) => findings ;
646+
647+ await handle ( {
648+ getFindings,
649+ scan,
650+ cascadeAmassNmap,
651+ cascadeNmapSsl,
652+ cascadeNmapSsh,
653+ cascadeNmapNikto,
654+ cascadeNmapSmb,
655+ cascadeNmapZapBaseline
656+ } ) ;
657+
658+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenCalledTimes ( 18 ) ;
659+
660+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 13 , {
661+ name : "ssh-ssh.example.com" ,
662+ parameters : [ "-t" , "ssh.example.com" , "-p" , "22000" ] ,
663+ parentScan : { metadata : { labels : { foo : "bar" } } } ,
664+ scanType : "ssh-scan" ,
665+ } ) ;
666+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 14 , {
667+ name : "nikto-http-http.example.com" ,
668+ parameters : [ "-h" , "http://http.example.com" , "-p" , "8000" , "-Tuning" , "1,2,3,5,7,b" ] ,
669+ parentScan : { metadata : { labels : { foo : "bar" } } } ,
670+ scanType : "nikto" ,
671+ } ) ;
672+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 15 , {
673+ name : "sslyze-https.example.com" ,
674+ parameters : [ "--regular" , "https.example.com:3000" ] ,
675+ parentScan : { metadata : { labels : { foo : "bar" } } } ,
676+ scanType : "sslyze" ,
677+ } ) ;
678+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 16 , {
679+ name : "zap-https-https.example.com" ,
680+ parameters : [ "-t" , "https://https.example.com:3000" ] ,
681+ parentScan : { metadata : { labels : { foo : "bar" } } } ,
682+ scanType : "zap-baseline" ,
683+ } ) ;
684+ expect ( startSubsequentSecureCodeBoxScan ) . toHaveBeenNthCalledWith ( 17 , {
685+ name : "sslyze-ssl.example.com" ,
686+ parameters : [ "--regular" , "ssl.example.com:8443" ] ,
687+ parentScan : { metadata : { labels : { foo : "bar" } } } ,
688+ scanType : "sslyze" ,
689+ } ) ;
584690} ) ;
0 commit comments