@@ -43,6 +43,7 @@ def scan_repository(context: click.Context, path, branch, monitor):
4343 """ Scan git repository including its history """
4444 try :
4545 logger .debug ('Starting repository scan process, %s' , {'path' : path , 'branch' : branch })
46+ context .obj ["monitor" ] = monitor
4647 scan_type = context .obj ["scan_type" ]
4748 if monitor and scan_type != SCA_SCAN_TYPE :
4849 raise click .ClickException (f"Monitor flag is currently supported for SCA scan type only" )
@@ -53,6 +54,7 @@ def scan_repository(context: click.Context, path, branch, monitor):
5354 for obj
5455 in get_git_repository_tree_file_entries (path , branch )]
5556 documents_to_scan = exclude_irrelevant_documents_to_scan (context , documents_to_scan )
57+ perform_pre_scan_documents_actions (context , scan_type , documents_to_scan , False )
5658 logger .debug ('Found all relevant files for scanning %s' , {'path' : path , 'branch' : branch })
5759 return scan_documents (context , documents_to_scan , is_git_diff = False ,
5860 scan_parameters = get_scan_parameters (path , monitor ))
@@ -136,13 +138,15 @@ def pre_commit_scan(context: click.Context, ignored_args: List[str]):
136138
137139
138140def scan_disk_files (context : click .Context , paths : List [str ]):
141+ scan_type = context .obj ['scan_type' ]
139142 is_git_diff = False
140143 documents : List [Document ] = []
141144 for path in paths :
142145 with open (path , "r" , encoding = "utf-8" ) as f :
143146 content = f .read ()
144147 documents .append (Document (path , content , is_git_diff ))
145148
149+ perform_pre_scan_documents_actions (context , scan_type , documents , is_git_diff )
146150 return scan_documents (context , documents , is_git_diff = is_git_diff )
147151
148152
@@ -159,7 +163,6 @@ def scan_documents(context: click.Context, documents_to_scan: List[Document],
159163 zipped_documents = InMemoryZip ()
160164
161165 try :
162- perform_pre_scan_documents_actions (scan_type , documents_to_scan , is_git_diff )
163166 zipped_documents = zip_documents_to_scan (scan_type , zipped_documents , documents_to_scan )
164167 scan_result = perform_scan (cycode_client , zipped_documents , scan_type , scan_id , is_git_diff , is_commit_range ,
165168 scan_parameters )
@@ -188,9 +191,10 @@ def scan_documents(context: click.Context, documents_to_scan: List[Document],
188191 all_detections_count , len (documents_to_scan ), zip_file_size , scan_command_type , error_message )
189192
190193
191- def perform_pre_scan_documents_actions (scan_type : str , documents_to_scan : List [Document ], is_git_diff : bool = False ):
192- if scan_type == 'sca' :
193- sca_code_scanner .run_pre_scan_actions (documents_to_scan , is_git_diff )
194+ def perform_pre_scan_documents_actions (context : click .Context , scan_type : str , documents_to_scan : List [Document ],
195+ is_git_diff : bool = False ):
196+ if scan_type == SCA_SCAN_TYPE :
197+ sca_code_scanner .run_pre_scan_actions (context , documents_to_scan , is_git_diff )
194198
195199
196200def zip_documents_to_scan (scan_type : str , zip : InMemoryZip , documents : List [Document ]):
0 commit comments