fosslight-util 1.4.40__tar.gz → 1.4.42__tar.gz

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.
Files changed (38) hide show
  1. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/PKG-INFO +7 -2
  2. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/README.md +6 -1
  3. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/setup.py +1 -1
  4. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/correct.py +4 -3
  5. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/download.py +25 -4
  6. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/oss_item.py +58 -11
  7. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/parsing_yaml.py +6 -0
  8. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/read_excel.py +4 -1
  9. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_excel.py +4 -0
  10. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_yaml.py +11 -6
  11. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/PKG-INFO +7 -2
  12. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/LICENSE +0 -0
  13. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/MANIFEST.in +0 -0
  14. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/requirements.txt +0 -0
  15. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/setup.cfg +0 -0
  16. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/__init__.py +0 -0
  17. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/_get_downloadable_url.py +0 -0
  18. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/compare_yaml.py +0 -0
  19. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/constant.py +0 -0
  20. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/convert_excel_to_yaml.py +0 -0
  21. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/cover.py +0 -0
  22. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/help.py +0 -0
  23. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/output_format.py +0 -0
  24. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
  25. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
  26. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/resources/licenses.json +0 -0
  27. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/set_log.py +0 -0
  28. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/spdx_licenses.py +0 -0
  29. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/timer_thread.py +0 -0
  30. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_opossum.py +0 -0
  31. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_scancodejson.py +0 -0
  32. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_spdx.py +0 -0
  33. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util/write_txt.py +0 -0
  34. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/SOURCES.txt +0 -0
  35. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
  36. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/entry_points.txt +0 -0
  37. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/requires.txt +0 -0
  38. {fosslight_util-1.4.40 → fosslight_util-1.4.42}/src/fosslight_util.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight_util
3
- Version: 1.4.40
3
+ Version: 1.4.42
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -122,6 +122,7 @@ Description: <!--
122
122
 
123
123
  #### How it works
124
124
  1. Try git clone.
125
+ 1-1. If the link is ssh-url, convert to https-url.
125
126
  2. If git clone fails, download it with wget and extract the compressed file.
126
127
  3. After extracting the compressed file, delete the compressed file.
127
128
 
@@ -135,7 +136,11 @@ Description: <!--
135
136
 
136
137
  #### How to run
137
138
  ```
138
- $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
139
+ $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
140
+ ```
141
+ If you want to try with private repository, set your github token like below.
142
+ ```
143
+ $ fosslight_download -s "https://my_github_token@github.com/Foo/private_repo -t target_dir/"
139
144
  ```
140
145
 
141
146
  ## 👏 How to report issue
@@ -114,6 +114,7 @@ If you give a link, the source is downloaded to the target directory through git
114
114
 
115
115
  #### How it works
116
116
  1. Try git clone.
117
+ 1-1. If the link is ssh-url, convert to https-url.
117
118
  2. If git clone fails, download it with wget and extract the compressed file.
118
119
  3. After extracting the compressed file, delete the compressed file.
119
120
 
@@ -127,7 +128,11 @@ If you give a link, the source is downloaded to the target directory through git
127
128
 
128
129
  #### How to run
129
130
  ```
130
- $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
131
+ $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
132
+ ```
133
+ If you want to try with private repository, set your github token like below.
134
+ ```
135
+ $ fosslight_download -s "https://my_github_token@github.com/Foo/private_repo -t target_dir/"
131
136
  ```
132
137
 
133
138
  ## 👏 How to report issue
@@ -14,7 +14,7 @@ with open('requirements.txt', 'r', 'utf-8') as f:
14
14
  if __name__ == "__main__":
15
15
  setup(
16
16
  name='fosslight_util',
17
- version='1.4.40',
17
+ version='1.4.42',
18
18
  package_dir={"": "src"},
19
19
  packages=find_packages(where='src'),
20
20
  description='FOSSLight Util',
@@ -48,12 +48,13 @@ def correct_with_yaml(correct_filepath, path_to_scan, scanner_oss_list):
48
48
  if sheet_name not in constant.supported_sheet_and_scanner.keys():
49
49
  continue
50
50
  correct_contents = copy.deepcopy(sheet_contents)
51
+ scanner_name = constant.supported_sheet_and_scanner[sheet_name]
51
52
  for idx, oss_raw_item in enumerate(sheet_contents):
52
53
  if len(oss_raw_item) < 9:
53
54
  logger.warning(f"sheet list is too short ({len(oss_raw_item)}): {oss_raw_item}")
54
55
  continue
55
56
  oss_item = OssItem('')
56
- oss_item.set_sheet_item(oss_raw_item)
57
+ oss_item.set_sheet_item(oss_raw_item, scanner_name)
57
58
 
58
59
  matched_yi = []
59
60
  oss_rel_path = os.path.normpath(os.path.join(rel_path, oss_item.source_name_or_path[0]))
@@ -75,13 +76,13 @@ def correct_with_yaml(correct_filepath, path_to_scan, scanner_oss_list):
75
76
  if matched_oss_item.comment:
76
77
  matched_oss_item.comment += '/'
77
78
  matched_oss_item.comment += 'Loaded from sbom-info.yaml'
78
- matched_oss_array = matched_oss_item.get_print_array()[0]
79
+ matched_oss_array = matched_oss_item.get_print_array(scanner_name)[0]
79
80
  correct_contents.append(matched_oss_array)
80
81
  oss_item.exclude = True
81
82
  if oss_item.comment:
82
83
  oss_item.comment += '/'
83
84
  oss_item.comment += 'Excluded by sbom-info.yaml'
84
- correct_contents[idx] = oss_item.get_print_array()[0]
85
+ correct_contents[idx] = oss_item.get_print_array(scanner_name)[0]
85
86
 
86
87
  if sheet_name == 'SRC_FL_Source':
87
88
  for n_idx, ni in enumerate(matched_yaml):
@@ -61,13 +61,21 @@ def change_src_link_to_https(src_link):
61
61
  return src_link
62
62
 
63
63
 
64
+ def change_ssh_link_to_https(src_link):
65
+ src_link = src_link.replace("git@github.com:", "https://github.com/")
66
+ return src_link
67
+
68
+
64
69
  def parse_src_link(src_link):
65
- src_info = {}
70
+ src_info = {"url": src_link}
66
71
  src_link_changed = ""
67
- if src_link.startswith("git://") or src_link.startswith("https://") or src_link.startswith("http://"):
72
+ if src_link.startswith("git://") or src_link.startswith("git@") \
73
+ or src_link.startswith("https://") or src_link.startswith("http://"):
68
74
  src_link_split = src_link.split(';')
69
75
  if src_link.startswith("git://github.com/"):
70
76
  src_link_changed = change_src_link_to_https(src_link_split[0])
77
+ elif src_link.startswith("git@github.com:"):
78
+ src_link_changed = change_ssh_link_to_https(src_link_split[0])
71
79
  else:
72
80
  if "rubygems.org" in src_link:
73
81
  src_info["rubygems"] = True
@@ -79,7 +87,7 @@ def parse_src_link(src_link):
79
87
  src_info["url"] = src_link_changed
80
88
  src_info["branch"] = branch_info
81
89
  src_info["tag"] = tag_info
82
- return src_info
90
+ return src_info
83
91
 
84
92
 
85
93
  def main():
@@ -205,11 +213,24 @@ def get_github_ossname(link):
205
213
  return oss_name
206
214
 
207
215
 
216
+ def get_github_token(git_url):
217
+ github_token = ""
218
+ pattern = r'https://(.*?)@'
219
+ search = re.search(pattern, git_url)
220
+ if search:
221
+ github_token = search.group(1)
222
+ return github_token
223
+
224
+
208
225
  def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch=""):
209
226
  ref_to_checkout = decide_checkout(checkout_to, tag, branch)
210
227
  msg = ""
211
228
  oss_name = get_github_ossname(git_url)
212
229
  oss_version = ""
230
+ github_token = get_github_token(git_url)
231
+ callbacks = None
232
+ if github_token != "":
233
+ callbacks = git.RemoteCallbacks(credentials=git.UserPass("foo", github_token)) # username is not used, so set to dummy
213
234
 
214
235
  if platform.system() != "Windows":
215
236
  signal.signal(signal.SIGALRM, alarm_handler)
@@ -221,7 +242,7 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch=""):
221
242
  Path(target_dir).mkdir(parents=True, exist_ok=True)
222
243
  repo = git.clone_repository(git_url, target_dir,
223
244
  bare=False, repository=None,
224
- remote=None, callbacks=None)
245
+ remote=None, callbacks=callbacks)
225
246
  if platform.system() != "Windows":
226
247
  signal.alarm(0)
227
248
  else:
@@ -5,7 +5,7 @@
5
5
 
6
6
  import logging
7
7
  import os
8
- from fosslight_util.constant import LOGGER_NAME
8
+ from fosslight_util.constant import LOGGER_NAME, FL_DEPENDENCY, FL_BINARY
9
9
 
10
10
  _logger = logging.getLogger(LOGGER_NAME)
11
11
 
@@ -25,6 +25,11 @@ class OssItem:
25
25
  self._yocto_recipe = []
26
26
  self._yocto_package = []
27
27
  self.is_binary = False
28
+ self._depends_on = []
29
+ self.purl = ""
30
+ self.bin_vulnerability = ""
31
+ self.bin_tlsh = ""
32
+ self.bin_sha1 = ""
28
33
 
29
34
  def __del__(self):
30
35
  pass
@@ -123,11 +128,29 @@ class OssItem:
123
128
  self._yocto_package = [item.strip() for item in self._yocto_package]
124
129
  self._yocto_package = list(set(self._yocto_package))
125
130
 
126
- def set_sheet_item(self, item):
131
+ @property
132
+ def depends_on(self):
133
+ return self._depends_on
134
+
135
+ @depends_on.setter
136
+ def depends_on(self, value):
137
+ if not value:
138
+ self._depends_on = []
139
+ else:
140
+ if not isinstance(value, list):
141
+ value = value.split(",")
142
+ self._depends_on.extend(value)
143
+ self._depends_on = [item.strip() for item in self._depends_on]
144
+ self._depends_on = list(set(self._depends_on))
145
+
146
+ def set_sheet_item(self, item, scanner_name=''):
127
147
  if len(item) < 9:
128
148
  _logger.warning(f"sheet list is too short ({len(item)}): {item}")
129
149
  return
130
- self.source_name_or_path = item[0]
150
+ if scanner_name == FL_DEPENDENCY:
151
+ self.purl = item[0]
152
+ else:
153
+ self.source_name_or_path = item[0]
131
154
  self.name = item[1]
132
155
  self.version = item[2]
133
156
  self.license = item[3]
@@ -137,19 +160,39 @@ class OssItem:
137
160
  self.exclude = item[7]
138
161
  self.comment = item[8]
139
162
 
140
- def get_print_array(self):
163
+ if len(item) >= 10 and scanner_name == FL_DEPENDENCY:
164
+ self.depends_on = item[9]
165
+ if len(item) >= 10 and scanner_name == FL_BINARY:
166
+ self.bin_vulnerability = item[9]
167
+ if len(item) >= 12:
168
+ self.bin_tlsh = item[10]
169
+ self.bin_sha1 = item[11]
170
+
171
+ def get_print_array(self, scanner_name=''):
141
172
  items = []
142
- if len(self.source_name_or_path) == 0:
143
- self.source_name_or_path.append("")
173
+ if scanner_name != FL_DEPENDENCY:
174
+ if len(self.source_name_or_path) == 0:
175
+ self.source_name_or_path.append("")
144
176
  if len(self.license) == 0:
145
177
  self.license.append("")
146
178
 
147
179
  exclude = "Exclude" if self.exclude else ""
148
-
149
- for source_name_or_path in self.source_name_or_path:
150
- lic = ",".join(self.license)
151
- items.append([os.path.join(self.relative_path, source_name_or_path), self.name, self.version, lic,
152
- self.download_location, self.homepage, self.copyright, exclude, self.comment])
180
+ lic = ",".join(self.license)
181
+ if scanner_name == FL_DEPENDENCY:
182
+ items = [self.purl, self.name, self.version, lic,
183
+ self.download_location, self.homepage, self.copyright, exclude, self.comment]
184
+ if len(self.depends_on) > 0:
185
+ items.append(",".join(self.depends_on))
186
+ else:
187
+ for source_name_or_path in self.source_name_or_path:
188
+ if scanner_name == FL_BINARY:
189
+ oss_item = [os.path.join(self.relative_path, source_name_or_path), self.name, self.version, lic,
190
+ self.download_location, self.homepage, self.copyright, exclude, self.comment,
191
+ self.bin_vulnerability, self.bin_tlsh, self.bin_sha1]
192
+ else:
193
+ oss_item = [os.path.join(self.relative_path, source_name_or_path), self.name, self.version, lic,
194
+ self.download_location, self.homepage, self.copyright, exclude, self.comment]
195
+ items.append(oss_item)
153
196
  return items
154
197
 
155
198
  def get_print_json(self):
@@ -171,6 +214,10 @@ class OssItem:
171
214
  json_item["exclude"] = self.exclude
172
215
  if self.comment != "":
173
216
  json_item["comment"] = self.comment
217
+ if len(self.depends_on) > 0:
218
+ json_item["depends on"] = self.depends_on
219
+ if self.purl != "":
220
+ json_item["purl"] = self.purl
174
221
 
175
222
  return json_item
176
223
 
@@ -115,6 +115,12 @@ def set_value_switch(oss, key, value, yaml_file=""):
115
115
  oss.yocto_package = value
116
116
  elif key == 'yocto_recipe':
117
117
  oss.yocto_recipe = value
118
+ elif key == 'vulnerability link':
119
+ oss.bin_vulnerability = value
120
+ elif key == 'tlsh':
121
+ oss.bin_tlsh = value
122
+ elif key == 'sha1':
123
+ oss.bin_sha1 = value
118
124
  else:
119
125
  if yaml_file != "":
120
126
  _logger.debug(f"file:{yaml_file} - key:{key} cannot be parsed")
@@ -75,7 +75,10 @@ def read_oss_report(excel_file: str, sheet_names: str = "") -> List[OssItem]:
75
75
  "Exclude": IDX_CANNOT_FOUND,
76
76
  "Copyright Text": IDX_CANNOT_FOUND,
77
77
  "Comment": IDX_CANNOT_FOUND,
78
- "File Name or Path": IDX_CANNOT_FOUND
78
+ "File Name or Path": IDX_CANNOT_FOUND,
79
+ "Vulnerability Link": IDX_CANNOT_FOUND,
80
+ "TLSH": IDX_CANNOT_FOUND,
81
+ "SHA1": IDX_CANNOT_FOUND
79
82
  }
80
83
  num_cols = xl_sheet.ncols
81
84
  num_rows = xl_sheet.nrows
@@ -301,6 +301,10 @@ def merge_excels(find_excel_dir, final_out, merge_files='', cover=''):
301
301
  sheet_name = f"{f_short_name}_{sheet_name}"
302
302
  df_excel.to_excel(writer, sheet_name, index=False)
303
303
  added_sheet_names.append(sheet_name)
304
+
305
+ if sheet_name == 'BIN_FL_Binary':
306
+ bin_sheet = writer.sheets[sheet_name]
307
+ bin_sheet.set_column("L:M", None, None, {"hidden": True}) # 'TLSH', 'SHA1' column hide
304
308
  writer.close()
305
309
  except Exception as ex:
306
310
  msg = str(ex)
@@ -35,11 +35,16 @@ def write_yaml(output_file, sheet_list_origin, separate_yaml=False):
35
35
  for sheet_name, sheet_contents in sheet_list.items():
36
36
  if sheet_name not in constant.supported_sheet_and_scanner.keys():
37
37
  continue
38
+ scanner_name = constant.supported_sheet_and_scanner[sheet_name]
39
+ sheet_contents_with_scanner = []
40
+ for i in sheet_contents:
41
+ i.insert(0, scanner_name)
42
+ sheet_contents_with_scanner.append(i)
38
43
  if not separate_yaml:
39
- merge_sheet.extend(sheet_contents)
44
+ merge_sheet.extend(sheet_contents_with_scanner)
40
45
  else:
41
46
  output_file = f'{separate_output_file}_{sheet_name}.yaml'
42
- convert_sheet_to_yaml(sheet_contents, output_file)
47
+ convert_sheet_to_yaml(sheet_contents_with_scanner, output_file)
43
48
  output_files.append(output_file)
44
49
 
45
50
  if not separate_yaml:
@@ -61,13 +66,13 @@ def write_yaml(output_file, sheet_list_origin, separate_yaml=False):
61
66
  return success, error_msg, output
62
67
 
63
68
 
64
- def convert_sheet_to_yaml(sheet_contents, output_file):
65
- sheet_contents = [list(t) for t in set(tuple(e) for e in sorted(sheet_contents))]
69
+ def convert_sheet_to_yaml(sheet_contents_with_scanner, output_file):
70
+ sheet_contents_with_scanner = [list(t) for t in set(tuple(e) for e in sorted(sheet_contents_with_scanner))]
66
71
 
67
72
  yaml_dict = {}
68
- for sheet_item in sheet_contents:
73
+ for sheet_item in sheet_contents_with_scanner:
69
74
  item = OssItem('')
70
- item.set_sheet_item(sheet_item)
75
+ item.set_sheet_item(sheet_item[1:], sheet_item[0])
71
76
  create_yaml_with_ossitem(item, yaml_dict)
72
77
 
73
78
  with open(output_file, 'w') as f:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 1.4.40
3
+ Version: 1.4.42
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -122,6 +122,7 @@ Description: <!--
122
122
 
123
123
  #### How it works
124
124
  1. Try git clone.
125
+ 1-1. If the link is ssh-url, convert to https-url.
125
126
  2. If git clone fails, download it with wget and extract the compressed file.
126
127
  3. After extracting the compressed file, delete the compressed file.
127
128
 
@@ -135,7 +136,11 @@ Description: <!--
135
136
 
136
137
  #### How to run
137
138
  ```
138
- $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
139
+ $ fosslight_download -s "https://github.com/LGE-OSS/example" -t target_dir/
140
+ ```
141
+ If you want to try with private repository, set your github token like below.
142
+ ```
143
+ $ fosslight_download -s "https://my_github_token@github.com/Foo/private_repo -t target_dir/"
139
144
  ```
140
145
 
141
146
  ## 👏 How to report issue
File without changes