fosslight-scanner 2.1.12__py3-none-any.whl → 2.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,9 @@ _HELP_MESSAGE_SCANNER = f"""
29
29
  -f <formats> [<format> ...]\t FOSSLight Report file format ({', '.join(SUPPORT_FORMAT)})
30
30
  * Compare mode result file: supports excel, json, yaml, html
31
31
  * Multiple formats can be specified separated by space.
32
- -e <path>\t\t Path to exclude from analysis (ex, -e [dir] [file])
32
+ -e <path>\t\t Path to exclude from analysis (files and directories)
33
+ * IMPORTANT: Always wrap patterns in double quotes ("") to avoid shell expansion.
34
+ Example) fosslight -e "test/abc.py" "*.jar"
33
35
  -o <output>\t\t Output directory or file
34
36
  -c <number>\t\t Number of processes to analyze source
35
37
  -r\t\t\t Keep raw data
@@ -28,6 +28,7 @@ from fosslight_util.output_format import check_output_formats_v2
28
28
  from fosslight_util.cover import CoverItem
29
29
  from fosslight_util.oss_item import ScannerItem
30
30
  from fosslight_util.output_format import write_output_file
31
+ from fosslight_util.exclude import get_excluded_paths
31
32
 
32
33
  from .common import (
33
34
  call_analysis_api, update_oss_item,
@@ -46,7 +47,7 @@ COMPARE_OUTPUT_REPORT_PREFIX = "fosslight_compare_"
46
47
  PKG_NAME = "fosslight_scanner"
47
48
  logger = logging.getLogger(constant.LOGGER_NAME)
48
49
  warnings.simplefilter(action='ignore', category=FutureWarning)
49
- _output_dir = "fosslight_raw_data"
50
+ _output_dir = ".fosslight_raw_data"
50
51
  _log_file = "fosslight_log_all_"
51
52
  _start_time = ""
52
53
  _executed_path = ""
@@ -181,6 +182,10 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
181
182
  if not correct_fpath:
182
183
  correct_fpath = src_path
183
184
 
185
+ excluded_path_with_default_exclusion, excluded_path_without_dot, excluded_files, cnt_file_except_skipped = (
186
+ get_excluded_paths(src_path, path_to_exclude))
187
+ logger.debug(f"Skipped paths: {excluded_path_with_default_exclusion}")
188
+
184
189
  try:
185
190
  final_excel_dir = os.path.abspath(final_excel_dir)
186
191
  abs_path = os.path.abspath(src_path)
@@ -203,7 +208,10 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
203
208
  source_write_json_file=source_write_json_file,
204
209
  source_print_matched_text=source_print_matched_text,
205
210
  source_time_out=source_time_out,
206
- formats=formats
211
+ formats=formats,
212
+ all_exclude_mode=(excluded_path_with_default_exclusion,
213
+ excluded_path_without_dot,
214
+ excluded_files, cnt_file_except_skipped)
207
215
  )
208
216
  if success:
209
217
  all_scan_item.file_items.update(result[2].file_items)
@@ -228,7 +236,11 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
228
236
  _output_dir,
229
237
  formats, db_url, binary_simple,
230
238
  correct_mode, correct_fpath,
231
- path_to_exclude=path_to_exclude)
239
+ path_to_exclude=path_to_exclude,
240
+ all_exclude_mode=(excluded_path_with_default_exclusion,
241
+ excluded_path_without_dot,
242
+ excluded_files,
243
+ cnt_file_except_skipped))
232
244
  if success:
233
245
  all_scan_item.file_items.update(result.file_items)
234
246
  all_cover_items.append(result.cover)
@@ -236,7 +248,10 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
236
248
  if run_dep:
237
249
  dep_scanitem = run_dependency(src_path, _output_dir,
238
250
  dep_arguments, path_to_exclude, formats,
239
- recursive_dep)
251
+ recursive_dep,
252
+ all_exclude_mode=(excluded_path_with_default_exclusion,
253
+ excluded_path_without_dot,
254
+ excluded_files, cnt_file_except_skipped))
240
255
  all_scan_item.file_items.update(dep_scanitem.file_items)
241
256
  all_cover_items.append(dep_scanitem.cover)
242
257
  else:
@@ -249,7 +264,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
249
264
  cover = CoverItem(tool_name=PKG_NAME,
250
265
  start_time=_start_time,
251
266
  input_path=abs_path,
252
- exclude_path=path_to_exclude,
267
+ exclude_path=excluded_path_without_dot,
253
268
  simple_mode=False)
254
269
  merge_comment = []
255
270
  for ci in all_cover_items:
@@ -335,6 +350,38 @@ def download_source(link, out_dir):
335
350
  return success, temp_src_dir, oss_name, oss_version
336
351
 
337
352
 
353
+ def rename_and_remove_hidden_folder(output_path, output_dir, keep_raw_data=False):
354
+ try:
355
+ hidden_log_dir = os.path.join(output_path, ".fosslight_log")
356
+ visible_log_dir = os.path.join(output_path, "fosslight_log")
357
+ if os.path.exists(hidden_log_dir):
358
+ try:
359
+ if os.path.exists(visible_log_dir):
360
+ shutil.rmtree(visible_log_dir)
361
+ shutil.move(hidden_log_dir, visible_log_dir)
362
+ except Exception as ex:
363
+ logger.debug(f"Error renaming log folder: {ex}")
364
+
365
+ if keep_raw_data:
366
+ visible_raw_dir = os.path.join(os.path.dirname(output_dir), "fosslight_raw_data")
367
+ if os.path.exists(output_dir):
368
+ if os.path.exists(visible_raw_dir):
369
+ shutil.rmtree(visible_raw_dir)
370
+ shutil.move(output_dir, visible_raw_dir)
371
+ logger.debug(f"Renamed {output_dir} to {visible_raw_dir}")
372
+ else:
373
+ logger.debug(f"Remove temporary files: {output_dir}")
374
+ if os.path.exists(output_dir):
375
+ shutil.rmtree(output_dir)
376
+
377
+ visible_raw_dir = os.path.join(os.path.dirname(output_dir), "fosslight_raw_data")
378
+ if os.path.exists(visible_raw_dir):
379
+ shutil.rmtree(visible_raw_dir)
380
+ logger.debug(f"Removed previous raw data folder: {visible_raw_dir}")
381
+ except Exception as ex:
382
+ logger.debug(f"Error cleaning up output directories: {ex}")
383
+
384
+
338
385
  def init(output_path="", make_outdir=True):
339
386
  global _output_dir, _log_file, _start_time, logger
340
387
 
@@ -352,7 +399,7 @@ def init(output_path="", make_outdir=True):
352
399
  Path(_output_dir).mkdir(parents=True, exist_ok=True)
353
400
  _output_dir = os.path.abspath(_output_dir)
354
401
 
355
- log_dir = os.path.join(output_root_dir, "fosslight_log")
402
+ log_dir = os.path.join(output_root_dir, ".fosslight_log")
356
403
  logger, result_log = init_log(os.path.join(log_dir, f"{_log_file}{_start_time}.txt"),
357
404
  True, logging.INFO, logging.DEBUG, PKG_NAME)
358
405
 
@@ -480,12 +527,9 @@ def run_main(mode_list, path_arg, dep_arguments, output_file_or_dir, file_format
480
527
  shutil.rmtree(extract_folder)
481
528
  else:
482
529
  logger.error("(mode) No mode has been selected for analysis.")
483
- try:
484
- if not keep_raw_data:
485
- logger.debug(f"Remove temporary files: {_output_dir}")
486
- shutil.rmtree(_output_dir)
487
- except Exception as ex:
488
- logger.debug(f"Error to remove temp files:{ex}")
530
+
531
+ rename_and_remove_hidden_folder(output_path, _output_dir, keep_raw_data)
532
+
489
533
  except Exception as ex:
490
534
  logger.warning(str(ex))
491
535
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_scanner
3
- Version: 2.1.12
3
+ Version: 2.1.13
4
4
  Summary: FOSSLight Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_scanner
6
6
  Download-URL: https://github.com/fosslight/fosslight_scanner
@@ -20,10 +20,10 @@ Requires-Dist: openpyxl
20
20
  Requires-Dist: progress
21
21
  Requires-Dist: pyyaml
22
22
  Requires-Dist: beautifulsoup4
23
- Requires-Dist: fosslight_util<3.0.0,>=2.1.35
24
- Requires-Dist: fosslight_source<3.0.0,>=2.2.1
25
- Requires-Dist: fosslight_dependency<5.0.0,>=4.1.28
26
- Requires-Dist: fosslight_binary<6.0.0,>=5.1.16
23
+ Requires-Dist: fosslight_util<3.0.0,>=2.1.37
24
+ Requires-Dist: fosslight_source<3.0.0,>=2.2.3
25
+ Requires-Dist: fosslight_dependency<5.0.0,>=4.1.29
26
+ Requires-Dist: fosslight_binary<6.0.0,>=5.1.17
27
27
  Requires-Dist: fosslight_prechecker<5.0.0,>=4.0.0
28
28
  Dynamic: author
29
29
  Dynamic: classifier
@@ -1,15 +1,15 @@
1
1
  fosslight_scanner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  fosslight_scanner/_get_input.py,sha256=f78M57QU7Lhw1VfZJKvYXbGsUiYMViPz1---UDIbV9I,1396
3
- fosslight_scanner/_help.py,sha256=5G_oL80402ylacXLnPDGn4xmJKsmv_FL_RBgLjdQ_Hw,3162
3
+ fosslight_scanner/_help.py,sha256=sWJ5wapLWLGDv2Acm9Eh4i3dTxdrYiLB2T7BPYC2os0,3366
4
4
  fosslight_scanner/_parse_setting.py,sha256=htxNNvhizZ2ZT18Aw6ihKuBpOMAyptkbMS5Z0_Xh5mQ,2551
5
5
  fosslight_scanner/_run_compare.py,sha256=zmzX-FIvWCSkwPvEA3iHfVpyg6QDGUCpw3tJuGLdPWM,10657
6
6
  fosslight_scanner/cli.py,sha256=vz_oGevbejqo3tHa4z6d-Ft0xu-gP9Pg-VmXb9IhO_s,6910
7
7
  fosslight_scanner/common.py,sha256=FyEoqVsIZ4pRIlHRXZES8PYaYfy3PEmUaOn02YSuuYU,8377
8
- fosslight_scanner/fosslight_scanner.py,sha256=wOSSnJZuUCvom9rvdwOUy7B2f-CUzDdecI2hm52dyFg,21174
8
+ fosslight_scanner/fosslight_scanner.py,sha256=zEdSjbQB87reiAyLxpKzQOYPT8ooJSXf3oSrrXA-bOk,23792
9
9
  fosslight_scanner/resources/bom_compare.html,sha256=VocJ9bDmQQOwfGyvXatPZ4W-QddO-IlsAvKdO0nZ7pA,2240
10
- fosslight_scanner-2.1.12.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
- fosslight_scanner-2.1.12.dist-info/METADATA,sha256=5AuTEQ3qZgFO4g01z1Lc8uDSVlaDQakzmjJtsk-47To,8599
12
- fosslight_scanner-2.1.12.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
13
- fosslight_scanner-2.1.12.dist-info/entry_points.txt,sha256=dl7AA0_Jqnq0NHuCEaxcJFgstLw3sod_-FGtcgZuJbs,104
14
- fosslight_scanner-2.1.12.dist-info/top_level.txt,sha256=43_xLb5KYpy8wOU1H2Wd2fEsWBY7Dg6ZEJJXkfT64Ak,18
15
- fosslight_scanner-2.1.12.dist-info/RECORD,,
10
+ fosslight_scanner-2.1.13.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
+ fosslight_scanner-2.1.13.dist-info/METADATA,sha256=6L8_JOtCLuxJRenV1je0nfHivjIYX4ilusxByyGJ2KE,8599
12
+ fosslight_scanner-2.1.13.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
13
+ fosslight_scanner-2.1.13.dist-info/entry_points.txt,sha256=dl7AA0_Jqnq0NHuCEaxcJFgstLw3sod_-FGtcgZuJbs,104
14
+ fosslight_scanner-2.1.13.dist-info/top_level.txt,sha256=43_xLb5KYpy8wOU1H2Wd2fEsWBY7Dg6ZEJJXkfT64Ak,18
15
+ fosslight_scanner-2.1.13.dist-info/RECORD,,