fosslight-binary 4.1.20__tar.gz → 4.1.22__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 (22) hide show
  1. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/PKG-INFO +1 -1
  2. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/setup.py +1 -1
  3. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/_binary.py +20 -4
  4. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/_help.py +1 -0
  5. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/binary_analysis.py +45 -39
  6. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/cli.py +6 -1
  7. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/PKG-INFO +1 -1
  8. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/LICENSE +0 -0
  9. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/LICENSES/Apache-2.0.txt +0 -0
  10. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
  11. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/MANIFEST.in +0 -0
  12. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/README.md +0 -0
  13. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/requirements.txt +0 -0
  14. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/setup.cfg +0 -0
  15. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/__init__.py +0 -0
  16. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/_binary_dao.py +0 -0
  17. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary/_jar_analysis.py +0 -0
  18. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/SOURCES.txt +0 -0
  19. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/dependency_links.txt +0 -0
  20. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/entry_points.txt +0 -0
  21. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/requires.txt +0 -0
  22. {fosslight_binary-4.1.20 → fosslight_binary-4.1.22}/src/fosslight_binary.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight_binary
3
- Version: 4.1.20
3
+ Version: 4.1.22
4
4
  Summary: FOSSLight Binary Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_binary_scanner
6
6
  Author: LG Electronics
@@ -33,7 +33,7 @@ if __name__ == "__main__":
33
33
 
34
34
  setup(
35
35
  name=_PACKAEG_NAME,
36
- version='4.1.20',
36
+ version='4.1.22',
37
37
  package_dir={"": "src"},
38
38
  packages=find_packages(where='src'),
39
39
  description='FOSSLight Binary Scanner',
@@ -27,7 +27,10 @@ class OssItem:
27
27
  self.comment = ""
28
28
 
29
29
  def set_comment(self, value):
30
- self.comment += value
30
+ if self.comment:
31
+ self.comment = f"{self.comment} / {value}"
32
+ else:
33
+ self.comment = value
31
34
 
32
35
  def set_exclude(self, value):
33
36
  self.exclude = value
@@ -89,7 +92,10 @@ class BinaryItem:
89
92
  return ", ".join(nvd_url)
90
93
 
91
94
  def set_comment(self, value):
92
- self.comment = value
95
+ if self.comment:
96
+ self.comment = f"{self.comment} / {value}"
97
+ else:
98
+ self.comment = value
93
99
 
94
100
  def set_bin_name(self, value):
95
101
  self.bin_name = value
@@ -110,16 +116,26 @@ class BinaryItem:
110
116
  return (self.binary_strip_root + "\t" + self.checksum + "\t" + self.tlsh)
111
117
 
112
118
  def get_oss_report(self):
119
+ comment = ""
113
120
  if len(self.oss_items) > 0:
114
121
  for oss in self.oss_items:
115
122
  exclude = _EXCLUDE_TRUE_VALUE if (self.exclude or oss.exclude) else ""
116
123
  nvd_url = self.get_vulnerability_items()
124
+
125
+ if self.comment:
126
+ if oss.comment:
127
+ comment = f"{self.comment} / {oss.comment}"
128
+ else:
129
+ comment = self.comment
130
+ else:
131
+ comment = oss.comment
132
+
117
133
  yield from [self.binary_strip_root, oss.name, oss.version,
118
- oss.license, oss.dl_url, '', '', exclude, oss.comment, nvd_url]
134
+ oss.license, oss.dl_url, '', '', exclude, comment, nvd_url]
119
135
  else:
120
136
  exclude = _EXCLUDE_TRUE_VALUE if self.exclude else ""
121
137
  yield from [self.binary_strip_root, '',
122
- '', '', '', '', '', exclude, '']
138
+ '', '', '', '', '', exclude, self.comment]
123
139
 
124
140
  def set_checksum_tlsh(self):
125
141
  self.checksum, self.tlsh, error, msg = get_checksum_and_tlsh(
@@ -14,6 +14,7 @@ _HELP_MESSAGE_BINARY = """
14
14
  -p <binary_path>\t\t Path to analyze binaries (Default: current directory)
15
15
  -h\t\t\t\t Print help message
16
16
  -v\t\t\t\t Print FOSSLight Binary Scanner version
17
+ -s\t\t\t\t Extract only the binary list in simple mode
17
18
  -o <output_path>\t\t Output path
18
19
  \t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
19
20
  -f <format>\t\t\t Output file format (excel, csv, opossum, yaml)
@@ -70,10 +70,10 @@ def init(path_to_find_bin, output_file_name, format):
70
70
  bin_txt_file = f"{output_file}.txt"
71
71
  else:
72
72
  if output_extension == _json_ext:
73
- result_report = f"fosslight_opossum_{_start_time}"
73
+ result_report = f"fosslight_opossum_bin_{_start_time}"
74
74
  else:
75
- result_report = f"fosslight_report_{_start_time}"
76
- bin_txt_file = f"fosslight_binary_{_start_time}.txt"
75
+ result_report = f"fosslight_report_bin_{_start_time}"
76
+ bin_txt_file = f"fosslight_binary_bin_{_start_time}.txt"
77
77
 
78
78
  result_report = os.path.join(output_path, result_report)
79
79
  binary_txt_file = os.path.join(output_path, bin_txt_file)
@@ -81,7 +81,7 @@ def init(path_to_find_bin, output_file_name, format):
81
81
  logger.error(f"Format error - {msg}")
82
82
  sys.exit(1)
83
83
 
84
- log_file = os.path.join(output_path, f"fosslight_log_{_start_time}.txt")
84
+ log_file = os.path.join(output_path, f"fosslight_log_bin_{_start_time}.txt")
85
85
  logger, _result_log = init_log(log_file, True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_find_bin)
86
86
 
87
87
  if not success:
@@ -125,7 +125,7 @@ def get_file_list(path_to_find):
125
125
  return file_cnt, bin_list, found_jar
126
126
 
127
127
 
128
- def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
128
+ def find_binaries(path_to_find_bin, output_dir, format, dburl="", simple_mode=False):
129
129
 
130
130
  _result_log, result_report, binary_txt_file, output_extension = init(
131
131
  path_to_find_bin, output_dir, format)
@@ -138,6 +138,7 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
138
138
  extended_header = {}
139
139
  content_list = []
140
140
  result_file = ""
141
+ bin_list = []
141
142
 
142
143
  if not os.path.isdir(path_to_find_bin):
143
144
  error_occured(error_msg=f"Can't find the directory : {path_to_find_bin}",
@@ -151,39 +152,41 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
151
152
  result_log=_result_log,
152
153
  exit=True)
153
154
  total_bin_cnt = len(return_list)
154
- try:
155
- # Run OWASP Dependency-check
156
- if found_jar:
157
- logger.info("Run OWASP Dependency-check to analyze .jar file")
158
- owasp_items, vulnerability_items, success = analyze_jar_file(path_to_find_bin)
159
- if success:
160
- return_list = merge_binary_list(owasp_items, vulnerability_items, return_list)
161
- extended_header = JAR_VUL_HEADER
162
- else:
163
- logger.warning("Could not find OSS information for some jar files.")
164
-
165
- return_list, db_loaded_cnt = get_oss_info_from_db(return_list, dburl)
166
- return_list = sorted(return_list, key=lambda row: (row.bin_name))
167
-
168
- if return_list:
169
- str_files = (x.get_print_binary_only() for x in return_list)
170
- success, error = write_txt_file(binary_txt_file,
171
- "Binary\tsha1sum\ttlsh\n" + '\n'.join(str_files))
172
-
173
- if success:
174
- _result_log["FOSSLight binary.txt"] = binary_txt_file
175
- else:
176
- error_occured(error_msg=error, exit=False)
177
-
178
- sheet_list = {}
179
- content_list = [list(item.get_oss_report()) for item in return_list]
180
- sheet_list["BIN_FL_Binary"] = content_list
181
-
182
- success_to_write, writing_msg, result_file = write_output_file(result_report, output_extension, sheet_list, extended_header)
183
- except Exception as ex:
184
- error_occured(error_msg=str(ex), exit=False)
155
+ if simple_mode:
156
+ bin_list = [bin.bin_name for bin in return_list]
157
+ else:
158
+ try:
159
+ # Run OWASP Dependency-check
160
+ if found_jar:
161
+ logger.info("Run OWASP Dependency-check to analyze .jar file")
162
+ owasp_items, vulnerability_items, success = analyze_jar_file(path_to_find_bin)
163
+ if success:
164
+ return_list = merge_binary_list(owasp_items, vulnerability_items, return_list)
165
+ extended_header = JAR_VUL_HEADER
166
+ else:
167
+ logger.warning("Could not find OSS information for some jar files.")
168
+
169
+ return_list, db_loaded_cnt = get_oss_info_from_db(return_list, dburl)
170
+ return_list = sorted(return_list, key=lambda row: (row.bin_name))
171
+
172
+ if return_list:
173
+ str_files = (x.get_print_binary_only() for x in return_list)
174
+ success, error = write_txt_file(binary_txt_file,
175
+ "Binary\tsha1sum\ttlsh\n" + '\n'.join(str_files))
176
+
177
+ if success:
178
+ _result_log["FOSSLight binary.txt"] = binary_txt_file
179
+ else:
180
+ error_occured(error_msg=error, exit=False)
181
+
182
+ sheet_list = {}
183
+ content_list = [list(item.get_oss_report()) for item in return_list]
184
+ sheet_list["BIN_FL_Binary"] = content_list
185
+
186
+ success_to_write, writing_msg, result_file = write_output_file(result_report, output_extension, sheet_list, extended_header)
187
+ except Exception as ex:
188
+ error_occured(error_msg=str(ex), exit=False)
185
189
 
186
- try:
187
190
  if success_to_write:
188
191
  if result_file:
189
192
  logger.info(f"Output file :{result_file}")
@@ -192,10 +195,11 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
192
195
  else:
193
196
  logger.error(f"Fail to generate result file.:{writing_msg}")
194
197
 
198
+ try:
195
199
  print_result_log(success=True, result_log=_result_log,
196
200
  file_cnt=str(total_file_cnt),
197
201
  bin_file_cnt=str(total_bin_cnt),
198
- auto_bin_cnt=str(db_loaded_cnt))
202
+ auto_bin_cnt=str(db_loaded_cnt), bin_list=bin_list)
199
203
  except Exception as ex:
200
204
  error_occured(error_msg=f"Print log : {ex}", exit=False)
201
205
 
@@ -255,7 +259,7 @@ def error_occured(error_msg, exit=False, result_log={}):
255
259
  sys.exit()
256
260
 
257
261
 
258
- def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="", auto_bin_cnt=""):
262
+ def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="", auto_bin_cnt="", bin_list=[]):
259
263
 
260
264
  if "Running time" in result_log:
261
265
  start_time = result_log["Running time"]
@@ -270,6 +274,8 @@ def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="",
270
274
  result_log["Error Log"] = _error_logs
271
275
  if success:
272
276
  result_log["Execution result"] += " but it has minor errors"
277
+ if bin_list:
278
+ result_log["Binary list"] = bin_list
273
279
  try:
274
280
  _str_final_result_log = yaml.safe_dump(result_log, allow_unicode=True, sort_keys=True)
275
281
  logger.info(_str_final_result_log)
@@ -19,10 +19,12 @@ def main():
19
19
  output_dir = ""
20
20
  format = ""
21
21
  db_url = ""
22
+ simple_mode = False
22
23
 
23
24
  parser = argparse.ArgumentParser(add_help=False)
24
25
  parser.add_argument('-h', '--help', action='store_true', required=False)
25
26
  parser.add_argument('-v', '--version', action='store_true', required=False)
27
+ parser.add_argument('-s', '--simple', action='store_true', required=False)
26
28
  parser.add_argument('-p', '--path', type=str, required=False)
27
29
  parser.add_argument('-o', '--output', type=str, required=False)
28
30
  parser.add_argument('-d', '--dburl', type=str, default='', required=False)
@@ -42,6 +44,9 @@ def main():
42
44
  print_package_version(_PKG_NAME, "FOSSLight Binary Scanner Version:")
43
45
  sys.exit(0)
44
46
 
47
+ if args.simple:
48
+ simple_mode = True
49
+
45
50
  if args.path: # -p option
46
51
  path_to_find_bin = args.path
47
52
  else:
@@ -73,7 +78,7 @@ def main():
73
78
  timer.setDaemon(True)
74
79
  timer.start()
75
80
 
76
- find_binaries(path_to_find_bin, output_dir, format, db_url)
81
+ find_binaries(path_to_find_bin, output_dir, format, db_url, simple_mode)
77
82
 
78
83
 
79
84
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-binary
3
- Version: 4.1.20
3
+ Version: 4.1.22
4
4
  Summary: FOSSLight Binary Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_binary_scanner
6
6
  Author: LG Electronics