fosslight-source 2.2.3__py3-none-any.whl → 2.2.5__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.
fosslight_source/_help.py CHANGED
@@ -6,33 +6,56 @@ from fosslight_util.help import PrintHelpMsg, print_package_version
6
6
  from fosslight_util.output_format import SUPPORT_FORMAT
7
7
 
8
8
  _HELP_MESSAGE_SOURCE_SCANNER = f"""
9
- FOSSLight Source Scanner Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
10
-
11
- FOSSLight Source Scanner uses ScanCode and SCANOSS, the source code scanners, to detect
12
- the copyright and license phrases contained in the file.
13
- Some files (ex- build script), binary files, directory and files in specific
14
- directories (ex-test) are excluded from the result.
15
-
16
- Options:
17
- Optional
18
- -p <source_path>\t Path to analyze source (Default: current directory)
19
- -h\t\t\t Print help message
20
- -v\t\t\t Print FOSSLight Source Scanner version
21
- -m\t\t\t Print additional information for scan result on separate sheets
22
- -e <path>\t\t Path to exclude from analysis (files and directories)
23
- \t\t\t * IMPORTANT: Always wrap patterns in double quotes ("") to avoid shell expansion.
24
- \t\t\t Example) fosslight_source -e "dev/" "tests/"
25
- -o <output_path>\t Output path (Path or file name)
26
- -f <format>\t\t Output file formats
27
- \t\t\t ({', '.join(SUPPORT_FORMAT)})
28
- \t\t\t Multiple formats can be specified separated by space.
29
- Options only for FOSSLight Source Scanner
30
- -s <scanner>\t Select which scanner to be run (scancode, scanoss, kb, all)
31
- -j\t\t\t Generate raw result of scanners in json format
32
- -t <float>\t\t Stop scancode scanning if scanning takes longer than a timeout in seconds.
33
- -c <core>\t\t Select the number of cores to be scanned with ScanCode or threads with SCANOSS.
34
- --no_correction\t Enter if you don't want to correct OSS information with sbom-info.yaml
35
- --correct_fpath <path> Path to the sbom-info.yaml file"""
9
+ 📖 Usage
10
+ ────────────────────────────────────────────────────────────────────
11
+ fosslight_source [options] <arguments>
12
+
13
+ 📝 Description
14
+ ────────────────────────────────────────────────────────────────────
15
+ FOSSLight Source Scanner analyzes source code to detect copyright and
16
+ license information using several modes.
17
+
18
+ Note: Build scripts, binary files, and test directories are automatically
19
+ excluded from analysis.
20
+
21
+ 📚 Guide: https://fosslight.org/fosslight-guide/scanner/2_source.html
22
+
23
+ ⚙️ General Options
24
+ ────────────────────────────────────────────────────────────────────
25
+ -p <path> Source path to analyze (default: current directory)
26
+ -o <path> Output file path or directory
27
+ -f <format> Output formats: {', '.join(SUPPORT_FORMAT)}
28
+ (multiple formats can be specified, separated by space)
29
+ -e <pattern> Exclude paths from analysis (files and directories)
30
+ ⚠️ IMPORTANT: Always wrap in quotes to avoid shell expansion
31
+ Example: fosslight_source -e "dev/" "tests/" "*.jar"
32
+ -m Generate detailed scan results on separate sheets
33
+ -h Show this help message
34
+ -v Show version information
35
+
36
+ 🔍 Scanner-Specific Options
37
+ ────────────────────────────────────────────────────────────────────
38
+ -s <mode> Choose mode: scancode, scanoss, kb, or all(default)
39
+ -c <number> Number of CPU cores/threads to use for scanning
40
+ -t <seconds> Timeout in seconds for ScanCode scanning
41
+ -j Generate raw scanner results in JSON format
42
+ --no_correction Skip OSS information correction with sbom-info.yaml
43
+ --correct_fpath <path> Path to custom sbom-info.yaml file
44
+
45
+ 💡 Examples
46
+ ────────────────────────────────────────────────────────────────────
47
+ # Scan current directory
48
+ fosslight_source
49
+
50
+ # Scan specific path with exclusions
51
+ fosslight_source -p /path/to/source -e "test/" "node_modules/"
52
+
53
+ # Generate output in specific format
54
+ fosslight_source -f excel -o results/
55
+
56
+ # Generate raw scanner results in JSON format
57
+ fosslight_source -p /path/to/source -j
58
+ """
36
59
 
37
60
 
38
61
  def print_version(pkg_name: str) -> None:
fosslight_source/cli.py CHANGED
@@ -370,7 +370,7 @@ def run_scanners(
370
370
  if output_path == "":
371
371
  output_path = os.getcwd()
372
372
  final_output_path = output_path
373
- output_path = os.path.join(os.path.dirname(output_path), '.fosslight_temp')
373
+ output_path = os.path.join(os.path.dirname(output_path), f'.fosslight_temp_{start_time}')
374
374
 
375
375
  logger, result_log = init_log(os.path.join(output_path, f"fosslight_log_src_{start_time}.txt"),
376
376
  True, logging.INFO, logging.DEBUG, PKG_NAME, path_to_scan, path_to_exclude)
@@ -404,8 +404,10 @@ def run_scanners(
404
404
  excluded_files)
405
405
  excluded_files = set(excluded_files) if excluded_files else set()
406
406
  if selected_scanner in ['scanoss', 'all']:
407
- scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_file_name, formats, True,
408
- num_cores, excluded_path_with_default_exclusion, excluded_files)
407
+ scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_path, formats, True, num_cores,
408
+ excluded_path_with_default_exclusion, excluded_files,
409
+ write_json_file)
410
+
409
411
  if selected_scanner in SCANNER_TYPE:
410
412
  run_kb = True if selected_scanner in ['kb', 'all'] else False
411
413
  spdx_downloads, manifest_licenses = metadata_collector(path_to_scan, excluded_files)
@@ -8,11 +8,12 @@ import importlib_metadata
8
8
  import warnings
9
9
  import logging
10
10
  import json
11
+ from typing import Tuple
11
12
  import fosslight_util.constant as constant
12
- from fosslight_util.output_format import check_output_formats_v2 # , write_output_file
13
13
  from ._parsing_scanoss_file import parsing_scan_result # scanoss
14
14
  from ._parsing_scanoss_file import parsing_extra_info # scanoss
15
15
  from scanoss.scanner import Scanner, ScanType
16
+ from scanoss.scanoss_settings import ScanossSettings
16
17
  import io
17
18
  import contextlib
18
19
 
@@ -27,9 +28,10 @@ def get_scanoss_extra_info(scanned_result: dict) -> list:
27
28
  return parsing_extra_info(scanned_result)
28
29
 
29
30
 
30
- def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list = [],
31
+ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [],
31
32
  called_by_cli: bool = False, num_threads: int = -1,
32
- path_to_exclude: list = [], excluded_files: set = None) -> list:
33
+ path_to_exclude: list = [], excluded_files: set = None,
34
+ write_json_file: bool = False) -> Tuple[list, bool]:
33
35
  """
34
36
  Run scanoss.py for the given path.
35
37
 
@@ -40,7 +42,6 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
40
42
  :param write_json_file: if requested, keep the raw files.
41
43
  :return scanoss_file_list: list of ScanItem (scanned result by files).
42
44
  """
43
- success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, format)
44
45
 
45
46
  scanoss_file_list = []
46
47
  api_limit_exceed = False
@@ -49,19 +50,22 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
49
50
  except Exception as error:
50
51
  logger.warning(f"{error}. Skipping scan with scanoss.")
51
52
  logger.warning("Please install scanoss and dataclasses before run fosslight_source with scanoss option.")
52
- return scanoss_file_list
53
+ return scanoss_file_list, api_limit_exceed
53
54
 
54
55
  output_json_file = os.path.join(output_path, SCANOSS_OUTPUT_FILE)
55
- if os.path.exists(output_json_file): # remove scanner_output.wfp file if exist
56
+ output_wfp_file = os.path.join(output_path, SCANOSS_RESULT_FILE)
57
+ if os.path.exists(output_json_file):
56
58
  os.remove(output_json_file)
57
59
 
58
60
  try:
61
+ scanoss_settings = ScanossSettings()
59
62
  scanner = Scanner(
60
63
  ignore_cert_errors=True,
61
64
  skip_folders=list(path_to_exclude) if path_to_exclude else [],
62
65
  scan_output=output_json_file,
63
66
  scan_options=ScanType.SCAN_SNIPPETS.value,
64
- nb_threads=num_threads if num_threads > 0 else 10
67
+ nb_threads=num_threads if num_threads > 0 else 10,
68
+ scanoss_settings=scanoss_settings
65
69
  )
66
70
 
67
71
  output_buffer = io.StringIO()
@@ -81,10 +85,15 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
81
85
  with open(output_json_file, "r") as st_json:
82
86
  st_python = json.load(st_json)
83
87
  scanoss_file_list = parsing_scan_result(st_python, excluded_files)
84
-
85
88
  except Exception as error:
86
89
  logger.debug(f"SCANOSS Parsing {path_to_scan}: {error}")
87
90
 
91
+ if not write_json_file:
92
+ if os.path.isfile(output_json_file):
93
+ os.remove(output_json_file)
94
+ if os.path.isfile(output_wfp_file):
95
+ os.remove(output_wfp_file)
96
+
88
97
  logger.info(f"|---Number of files detected with SCANOSS: {(len(scanoss_file_list))}")
89
98
 
90
99
  return scanoss_file_list, api_limit_exceed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_source
3
- Version: 2.2.3
3
+ Version: 2.2.5
4
4
  Summary: FOSSLight Source Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_source_scanner
6
6
  Download-URL: https://github.com/fosslight/fosslight_source_scanner
@@ -15,7 +15,7 @@ Requires-Python: >=3.10, <3.13
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: pyparsing
18
- Requires-Dist: scanoss>=1.18.0
18
+ Requires-Dist: scanoss>=1.19.0
19
19
  Requires-Dist: XlsxWriter
20
20
  Requires-Dist: fosslight_util>=2.1.37
21
21
  Requires-Dist: PyYAML
@@ -1,17 +1,17 @@
1
1
  fosslight_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fosslight_source/_help.py,sha256=Ge6g9GKWGza11E74PFnBMqsj40UCUz-a_xArDZ1FClU,2316
2
+ fosslight_source/_help.py,sha256=Zgc-66WakwuF2iPnoxQlRHx64kLabdiPemkVxKz9S7Y,3553
3
3
  fosslight_source/_license_matched.py,sha256=-3H881XQjFDafRttBsuboS3VbCPYEvPH1pwWXptknE4,2164
4
4
  fosslight_source/_parsing_scancode_file_item.py,sha256=9TjCwTTPaytqTlZzCKzaX-n20xJLy346xwp0Ee-rWWA,14951
5
5
  fosslight_source/_parsing_scanoss_file.py,sha256=L3iHqmQF2jeSpHYuYSre44doXKy-BoX0u1Lm2IfJSU8,3866
6
6
  fosslight_source/_scan_item.py,sha256=rWoC-jMc6Hf_dpiwVdQjATNhkzRgLVn966q3UA1TAxc,9412
7
- fosslight_source/cli.py,sha256=GDwBlwgSvPtWlKhk6hZWQSUl71MJYaGIE4_Mcp1w_L8,20367
7
+ fosslight_source/cli.py,sha256=1Cc1vLESYHzb101OJb9ySgtfNZa0pQRNHxJ1XT1eUrg,20456
8
8
  fosslight_source/run_manifest_extractor.py,sha256=8itu69eoriEnSskVDF9rnkLZ3d515KTaKy6tkZKWgBk,8940
9
9
  fosslight_source/run_scancode.py,sha256=TFyNLV6P9rSBo9royDoG6az4l7Tkpl8Gr66IFK1DBU8,9021
10
- fosslight_source/run_scanoss.py,sha256=91hQ60BcjgCkfrcWuMYoR4lRSCa1-AdLMxVubTx_Wv4,3763
10
+ fosslight_source/run_scanoss.py,sha256=Whxcpmsai-Lhlh599PDFAM15ElhPsCtYDM51AOb6V3M,4019
11
11
  fosslight_source/run_spdx_extractor.py,sha256=wIdjDIpzglc2tfrh_YodkAQ0QqfgfmJBSuE2bf4w4Tg,862
12
- fosslight_source-2.2.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
- fosslight_source-2.2.3.dist-info/METADATA,sha256=Md1A-4vaFc-sabOYYLntHZFo6NoohWA-Sn_H7K4LWus,3557
14
- fosslight_source-2.2.3.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
15
- fosslight_source-2.2.3.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
16
- fosslight_source-2.2.3.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
17
- fosslight_source-2.2.3.dist-info/RECORD,,
12
+ fosslight_source-2.2.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
+ fosslight_source-2.2.5.dist-info/METADATA,sha256=1D2bUSE2E2ZRIsYtUzQv_6ebhpo3mLCQXRK1Z69peu4,3557
14
+ fosslight_source-2.2.5.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
15
+ fosslight_source-2.2.5.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
16
+ fosslight_source-2.2.5.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
17
+ fosslight_source-2.2.5.dist-info/RECORD,,