55from typing import List
66from urllib .parse import urlencode
77
8- from censys .cli .utils import INDEXES , V1_INDEXES , V2_INDEXES , console , write_file
8+ from censys .cli .utils import INDEXES , V1_INDEXES , V2_INDEXES , err_console , write_file
99from censys .common .exceptions import CensysCLIException
1010from censys .search import SearchClient
1111
1212Fields = List [str ]
1313Results = List [dict ]
1414
1515DEFAULT_FIELDS = {
16- "ipv4" : [
17- "updated_at" ,
18- "protocols" ,
19- "metadata.description" ,
20- "autonomous_system.name" ,
21- "23.telnet.banner.banner" ,
22- "80.http.get.title" ,
23- "80.http.get.metadata.description" ,
24- "8080.http.get.metadata.description" ,
25- "8888.http.get.metadata.description" ,
26- "443.https.get.metadata.description" ,
27- "443.https.get.title" ,
28- "443.https.tls.certificate.parsed.subject_dn" ,
29- "443.https.tls.certificate.parsed.names" ,
30- "443.https.tls.certificate.parsed.subject.common_name" ,
31- "443.https.tls.certificate.parsed.extensions.subject_alt_name.dns_names" ,
32- ],
3316 "certs" : [
3417 "metadata.updated_at" ,
3518 "parsed.issuer.common_name" ,
4427 "metadata.seen_in_scan" ,
4528 "tags" ,
4629 ],
47- "websites" : [
48- "443.https.tls.version" ,
49- "alexa_rank" ,
50- "domain" ,
51- "ports" ,
52- "protocols" ,
53- "tags" ,
54- "updated_at" ,
55- ],
5630}
5731
5832
@@ -69,17 +43,12 @@ def cli_search(args: argparse.Namespace):
6943
7044 if args .open :
7145 url_query = {"q" : args .query }
72- if index_type in V1_INDEXES :
73- if index_type == "certs" :
74- index_type = "certificates"
75- # TODO: Remove when v1 is fully deprecated
76- webbrowser .open (
77- f"https://search.censys.io/{ index_type } ?{ urlencode (url_query )} "
78- )
79- sys .exit (0 )
80- webbrowser .open (f"https://censys.io/{ index_type } ?{ urlencode (url_query )} " )
46+ if index_type in {"certs" , "certificates" }:
47+ webbrowser .open (
48+ f"https://search.censys.io/certificates?{ urlencode (url_query )} "
49+ )
8150 sys .exit (0 )
82- elif index_type in V2_INDEXES :
51+ if index_type in V2_INDEXES :
8352 url_query .update ({"resource" : index_type })
8453 webbrowser .open (f"https://search.censys.io/search?{ urlencode (url_query )} " )
8554 sys .exit (0 )
@@ -120,7 +89,7 @@ def cli_search(args: argparse.Namespace):
12089
12190 search_args ["fields" ] = fields
12291
123- with console .status ("Searching" ):
92+ with err_console .status ("Searching" ):
12493 results = list (index .search (args .query , ** search_args ))
12594 elif index_type in V2_INDEXES :
12695 if args .format == "csv" :
@@ -132,7 +101,7 @@ def cli_search(args: argparse.Namespace):
132101 if args .pages :
133102 search_args ["pages" ] = args .pages
134103
135- with console .status ("Searching" ):
104+ with err_console .status ("Searching" ):
136105 query = index .search (args .query , ** search_args )
137106
138107 results = []
@@ -142,7 +111,7 @@ def cli_search(args: argparse.Namespace):
142111 try :
143112 write_file (results , ** write_args )
144113 except ValueError as error : # pragma: no cover
145- console .print (f"Error writing log file. Error: { error } " )
114+ err_console .print (f"Error writing log file. Error: { error } " )
146115
147116
148117def include (parent_parser : argparse ._SubParsersAction , parents : dict ):
0 commit comments