fosslight-util 2.1.11__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.
fosslight_util/correct.py CHANGED
@@ -61,17 +61,15 @@ def correct_with_yaml(correct_filepath, path_to_scan, scan_item):
61
61
 
62
62
  yaml_path_exists = True
63
63
  exclude_fileitems.append(idx)
64
-
65
- if not yaml_path_exists:
64
+ if scanner_name == FOSSLIGHT_SOURCE and not yaml_path_exists:
66
65
  correct_item = copy.deepcopy(yaml_file_item)
67
66
  if os.path.exists(os.path.normpath(yaml_file_item.source_name_or_path)):
68
67
  correct_item.comment = 'Loaded from sbom-info.yaml'
69
68
  correct_fileitems.append(correct_item)
70
69
  else:
71
- if scanner_name == FOSSLIGHT_SOURCE:
72
- correct_item.exclude = True
73
- correct_item.comment = 'Added by sbom-info.yaml'
74
- correct_fileitems.append(correct_item)
70
+ correct_item.exclude = True
71
+ correct_item.comment = 'Added by sbom-info.yaml'
72
+ correct_fileitems.append(correct_item)
75
73
  if correct_fileitems:
76
74
  scan_item.append_file_items(correct_fileitems, scanner_name)
77
75
  find_match = True
@@ -73,7 +73,7 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
73
73
  comp_type = ComponentType.LIBRARY
74
74
 
75
75
  for oss_item in file_item.oss_items:
76
- if oss_item.name == '':
76
+ if oss_item.name == '' or oss_item.name == '-':
77
77
  if scanner_name == FOSSLIGHT_DEPENDENCY:
78
78
  continue
79
79
  else:
@@ -93,7 +93,8 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
93
93
  if scanner_name == FOSSLIGHT_DEPENDENCY and file_item.purl:
94
94
  comp.purl = PackageURL.from_string(file_item.purl)
95
95
  if scanner_name != FOSSLIGHT_DEPENDENCY:
96
- comp.hashes = [HashType(alg=HashAlgorithm.SHA_1, content=file_item.checksum)]
96
+ if file_item.checksum != '0':
97
+ comp.hashes = [HashType(alg=HashAlgorithm.SHA_1, content=file_item.checksum)]
97
98
 
98
99
  if oss_item.download_location != '':
99
100
  comp.external_references = [ExternalReference(url=XsUri(oss_item.download_location),
@@ -34,6 +34,7 @@ IDX_FILE = 0
34
34
  IDX_EXCLUDE = 7
35
35
  logger = logging.getLogger(LOGGER_NAME)
36
36
  COVER_SHEET_NAME = 'Scanner Info'
37
+ MAX_EXCEL_URL_LENGTH = 255
37
38
 
38
39
 
39
40
  def get_header_row(sheet_name, extended_header={}):
@@ -181,7 +182,10 @@ def write_result_to_sheet(worksheet, sheet_contents):
181
182
  for row_item in sheet_contents:
182
183
  worksheet.write(row, 0, row)
183
184
  for col_num, value in enumerate(row_item):
184
- worksheet.write(row, col_num + 1, str(value))
185
+ if len(value) > MAX_EXCEL_URL_LENGTH and (value.startswith("http://") or value.startswith("https://")):
186
+ worksheet.write_string(row, col_num + 1, str(value))
187
+ else:
188
+ worksheet.write(row, col_num + 1, str(value))
185
189
  row += 1
186
190
 
187
191
 
@@ -6,7 +6,7 @@
6
6
  import logging
7
7
  import os
8
8
  import json
9
- from fosslight_util.constant import LOGGER_NAME
9
+ from fosslight_util.constant import LOGGER_NAME, FOSSLIGHT_DEPENDENCY
10
10
  from fosslight_util.oss_item import ScannerItem
11
11
  from typing import List
12
12
 
@@ -20,22 +20,27 @@ def write_scancodejson(output_dir: str, output_filename: str, oss_list: List[Sca
20
20
  json_output['summary'] = {}
21
21
  json_output['license_detections'] = []
22
22
  json_output['files'] = []
23
+ json_output['dependencies'] = []
23
24
 
24
- for file_items in oss_list.file_items.values():
25
+ for scanner, file_items in oss_list.file_items.items():
25
26
  for fi in file_items:
26
- if fi.exclude:
27
- continue
28
- if fi.oss_items and (all(oss_item.exclude for oss_item in fi.oss_items)):
29
- continue
30
- if not fi.source_name_or_path:
31
- fi.source_name_or_path = EMPTY_FILE_PATH
32
- json_output['files'] = add_item_in_files(fi, json_output['files'])
27
+ if scanner == FOSSLIGHT_DEPENDENCY:
28
+ json_output['dependencies'] = add_item_in_deps(fi, json_output['dependencies'])
29
+ else:
30
+ if fi.exclude:
31
+ continue
32
+ if fi.oss_items and (all(oss_item.exclude for oss_item in fi.oss_items)):
33
+ continue
34
+ if not fi.source_name_or_path:
35
+ fi.source_name_or_path = EMPTY_FILE_PATH
36
+ json_output['files'] = add_item_in_files(fi, json_output['files'])
33
37
 
34
38
  with open(os.path.join(output_dir, output_filename), 'w') as f:
35
39
  json.dump(json_output, f, sort_keys=False, indent=4)
36
40
 
37
41
 
38
- def append_oss_item_in_filesitem(oss_items, files_item):
42
+ def get_oss_item_list(oss_items):
43
+ scan_oss_items = []
39
44
  for oi in oss_items:
40
45
  if oi.exclude:
41
46
  continue
@@ -46,9 +51,9 @@ def append_oss_item_in_filesitem(oss_items, files_item):
46
51
  oss_item['copyright'] = oi.copyright
47
52
  oss_item['download_location'] = oi.download_location
48
53
  oss_item['comment'] = oi.comment
49
- files_item['oss'].append(oss_item)
54
+ scan_oss_items.append(oss_item)
50
55
 
51
- return files_item
56
+ return scan_oss_items
52
57
 
53
58
 
54
59
  def add_item_in_files(file_item, files_list):
@@ -57,8 +62,20 @@ def add_item_in_files(file_item, files_list):
57
62
  files_item['name'] = os.path.basename(file_item.source_name_or_path)
58
63
  files_item['is_binary'] = file_item.is_binary
59
64
  files_item['base_name'], files_item['extension'] = os.path.splitext(os.path.basename(file_item.source_name_or_path))
60
- files_item['oss'] = []
61
- files_item = append_oss_item_in_filesitem(file_item.oss_items, files_item)
65
+ files_item['oss'] = get_oss_item_list(file_item.oss_items)
66
+
62
67
  files_list.append(files_item)
63
68
 
64
69
  return files_list
70
+
71
+
72
+ def add_item_in_deps(file_item, deps_list):
73
+ deps_item = {}
74
+ deps_item['purl'] = file_item.purl
75
+ deps_item['scope'] = 'dependencies'
76
+ deps_item['depends_on'] = file_item.depends_on
77
+ deps_item['oss'] = get_oss_item_list(file_item.oss_items)
78
+
79
+ deps_list.append(deps_item)
80
+
81
+ return deps_list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.11
3
+ Version: 2.1.13
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -2,7 +2,7 @@ fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  fosslight_util/_get_downloadable_url.py,sha256=V-wjCHBNFOthOt1tMb6ZCJY7UnlrB_6JI0CFx03AARk,9310
3
3
  fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
4
4
  fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
5
- fosslight_util/correct.py,sha256=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
5
+ fosslight_util/correct.py,sha256=1WEAL-9_KhjFPLucPhv0PNN3K7avm0z8mU6sTuSyeHM,3864
6
6
  fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
7
7
  fosslight_util/download.py,sha256=5nLe0oE1pUHEawM4kLlryusPBlk6ptEvy4HtqwFmCMs,16292
8
8
  fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
@@ -14,19 +14,19 @@ fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,
14
14
  fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
15
15
  fosslight_util/spdx_licenses.py,sha256=GvMNe_D4v2meapTVwPu2BJXInnTo3_gIzg669eJhUu0,3691
16
16
  fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g0,433
17
- fosslight_util/write_cyclonedx.py,sha256=pJnUpBz_cWH4jCSyulaiZI8h--rIUTby5ijYm7rWf8w,9576
18
- fosslight_util/write_excel.py,sha256=G0fIslbWoOtWZCJxbBGLCpUKbhmwrrqhI5PHwRw8_44,9931
17
+ fosslight_util/write_cyclonedx.py,sha256=hq817j-0OM89B8jtZKgHgvVa0YEaYHlz_8R5vNpe21I,9662
18
+ fosslight_util/write_excel.py,sha256=QUIMCnmEKJoSpri5RctBcKLvhDShLdZUP_dhHv-sVy8,10165
19
19
  fosslight_util/write_opossum.py,sha256=ltmo6SkugKWdAYupeCqwE4-3lua0GwLpix1XqFC-tT8,11678
20
- fosslight_util/write_scancodejson.py,sha256=81n7cWNYoyIKE_V4Kx5YtL2CgjMPIjoKdnSU3inkpJY,2163
20
+ fosslight_util/write_scancodejson.py,sha256=dMCjTtUnNR5BCL6gBCleDT8bTSAN5Gg2RAfimmkGXUE,2692
21
21
  fosslight_util/write_spdx.py,sha256=Ov9jBlfVrkWIymcfAxbupUxDZKfCOZZGOPZ4v-x230M,12108
22
22
  fosslight_util/write_txt.py,sha256=BEFjYBppqk1CITx-fUN4vfvKv0XCs1GXWtc2Iu-etU4,629
23
23
  fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,3238
24
24
  fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
25
25
  fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
26
26
  fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
27
- fosslight_util-2.1.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- fosslight_util-2.1.11.dist-info/METADATA,sha256=IPVWkUABqpyTDjH4H8w_bNSfdkEBLQqr_be_yCvOJaU,6500
29
- fosslight_util-2.1.11.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
- fosslight_util-2.1.11.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
- fosslight_util-2.1.11.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
- fosslight_util-2.1.11.dist-info/RECORD,,
27
+ fosslight_util-2.1.13.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.13.dist-info/METADATA,sha256=Zi4GMXN-56dLXE7o18eW86t_Ok0PJx89StzSRzLKGHM,6500
29
+ fosslight_util-2.1.13.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ fosslight_util-2.1.13.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
+ fosslight_util-2.1.13.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.13.dist-info/RECORD,,