4
4
5
5
from c42eventextractor import FileEventHandlers
6
6
from c42eventextractor .extractors import FileEventExtractor
7
- from py42 import debug_level
8
- from py42 import settings
9
- from py42 .sdk import SDK
10
7
from py42 .sdk .file_event_query .cloud_query import Actor
11
8
from py42 .sdk .file_event_query .device_query import DeviceUsername
12
9
from py42 .sdk .file_event_query .event_query import Source
22
19
from code42cli .securitydata .logger_factory import get_error_logger
23
20
from code42cli .securitydata .options import ExposureType as ExposureTypeOptions
24
21
from code42cli .util import print_error , print_bold , is_interactive
22
+ from code42cli .sdk_client import create_sdk
25
23
26
24
_EXCEPTIONS_OCCURRED = False
27
25
@@ -41,7 +39,7 @@ def extract(output_logger, args):
41
39
store = _create_cursor_store (args , profile )
42
40
filters = _get_filters (args , store )
43
41
handlers = _create_event_handlers (output_logger , store )
44
- sdk = _get_sdk (profile , args .is_debug_mode )
42
+ sdk = create_sdk (profile , args .is_debug_mode )
45
43
extractor = FileEventExtractor (sdk , handlers )
46
44
_call_extract (extractor , filters , args )
47
45
_handle_result ()
@@ -85,12 +83,12 @@ def _verify_begin_date_requirements(args, cursor_store):
85
83
def _begin_date_is_required (args , cursor_store ):
86
84
if not args .is_incremental :
87
85
return True
88
- required = cursor_store is not None and cursor_store .get_stored_insertion_timestamp () is None
86
+ is_required = cursor_store and cursor_store .get_stored_insertion_timestamp () is None
89
87
90
88
# Ignore begin date when is incremental mode, it is not required, and it was passed an argument.
91
- if not required and args .begin_date :
89
+ if not is_required and args .begin_date :
92
90
args .begin_date = None
93
- return required
91
+ return is_required
94
92
95
93
96
94
def _verify_exposure_types (exposure_types ):
@@ -122,7 +120,9 @@ def _create_filters(args):
122
120
123
121
def _get_event_timestamp_filter (args ):
124
122
try :
125
- return date_helper .create_event_timestamp_filter (args .begin_date , args .end_date )
123
+ begin_date = args .begin_date .strip ().split (" " ) if args .begin_date else None
124
+ end_date = args .end_date .strip ().split (" " ) if args .end_date else None
125
+ return date_helper .create_event_timestamp_filter (begin_date , end_date )
126
126
except ValueError as ex :
127
127
print_error (str (ex ))
128
128
exit (1 )
@@ -153,20 +153,6 @@ def handle_response(response):
153
153
return handlers
154
154
155
155
156
- def _get_sdk (profile , is_debug_mode ):
157
- if is_debug_mode :
158
- settings .debug_level = debug_level .DEBUG
159
- try :
160
- password = profile .get_password ()
161
- return SDK .create_using_local_account (profile .authority_url , profile .username , password )
162
- except Exception :
163
- print_error (
164
- u"Invalid credentials or host address. "
165
- u"Verify your profile is set up correctly and that you are supplying the correct password."
166
- )
167
- exit (1 )
168
-
169
-
170
156
def _call_extract (extractor , filters , args ):
171
157
if args .advanced_query :
172
158
extractor .extract_advanced (args .advanced_query )
0 commit comments