fosslight-binary 4.1.31__tar.gz → 4.1.33__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.31 → fosslight_binary-4.1.33}/PKG-INFO +1 -1
  2. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/requirements.txt +1 -1
  3. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/setup.py +1 -1
  4. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/_help.py +2 -1
  5. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/binary_analysis.py +35 -28
  6. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/cli.py +3 -3
  7. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary.egg-info/PKG-INFO +1 -1
  8. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary.egg-info/requires.txt +1 -1
  9. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/LICENSE +0 -0
  10. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/LICENSES/Apache-2.0.txt +0 -0
  11. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
  12. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/MANIFEST.in +0 -0
  13. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/README.md +0 -0
  14. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/setup.cfg +0 -0
  15. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/__init__.py +0 -0
  16. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/_binary.py +0 -0
  17. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/_binary_dao.py +0 -0
  18. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary/_jar_analysis.py +0 -0
  19. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary.egg-info/SOURCES.txt +0 -0
  20. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary.egg-info/dependency_links.txt +0 -0
  21. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/src/fosslight_binary.egg-info/entry_points.txt +0 -0
  22. {fosslight_binary-4.1.31 → fosslight_binary-4.1.33}/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.31
3
+ Version: 4.1.33
4
4
  Summary: FOSSLight Binary Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_binary_scanner
6
6
  Author: LG Electronics
@@ -8,5 +8,5 @@ py-tlsh
8
8
  pytz
9
9
  XlsxWriter
10
10
  PyYAML
11
- fosslight_util>=1.4.43
11
+ fosslight_util~=1.4.47
12
12
  dependency-check
@@ -33,7 +33,7 @@ if __name__ == "__main__":
33
33
 
34
34
  setup(
35
35
  name=_PACKAEG_NAME,
36
- version='4.1.31',
36
+ version='4.1.33',
37
37
  package_dir={"": "src"},
38
38
  packages=find_packages(where='src'),
39
39
  description='FOSSLight Binary Scanner',
@@ -18,7 +18,8 @@ _HELP_MESSAGE_BINARY = """
18
18
  -e <path>\t\t\t Path to exclude from analysis (files and directories)
19
19
  -o <output_path>\t\t Output path
20
20
  \t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
21
- -f <format>\t\t\t Output file format (excel, csv, opossum, yaml)
21
+ -f <format> [<format> ...]\t Output file formats (excel, csv, opossum, yaml)
22
+ \t\t\t\t Multiple formats can be specified separated by space.
22
23
  -d <db_url>\t\t\t DB Connection(format :'postgresql://username:password@host:port/database_name')
23
24
  --notice\t\t\t Print the open source license notice text.
24
25
  --no_correction\t\t\t Enter if you don't want to correct OSS information with sbom-info.yaml
@@ -13,7 +13,7 @@ import yaml
13
13
  import stat
14
14
  from fosslight_util.set_log import init_log
15
15
  import fosslight_util.constant as constant
16
- from fosslight_util.output_format import check_output_format, write_output_file
16
+ from fosslight_util.output_format import check_output_formats, write_output_file
17
17
  from ._binary_dao import get_oss_info_from_db
18
18
  from ._binary import BinaryItem
19
19
  from ._jar_analysis import analyze_jar_file, merge_binary_list
@@ -28,8 +28,9 @@ _REMOVE_FILE_EXTENSION = ['qm', 'xlsx', 'pdf', 'pptx', 'jfif', 'docx', 'doc', 'w
28
28
  _REMOVE_FILE_COMMAND_RESULT = [
29
29
  'data', 'timezone data', 'apple binary property list']
30
30
  INCLUDE_FILE_COMMAND_RESULT = ['current ar archive']
31
+ _EXCLUDE_FILE_EXTENSION = ['class']
31
32
  _EXCLUDE_FILE = ['fosslight_bin', 'fosslight_bin.exe']
32
- _EXCLUDE_DIR = ["test", "tests", "doc", "docs"]
33
+ _EXCLUDE_DIR = ["test", "tests", "doc", "docs", "intermediates"]
33
34
  _EXCLUDE_DIR = [os.path.sep + dir_name + os.path.sep for dir_name in _EXCLUDE_DIR]
34
35
  _EXCLUDE_DIR.append("/.")
35
36
  _REMOVE_DIR = ['.git']
@@ -46,7 +47,7 @@ BIN_EXT_HEADER = {'BIN_FL_Binary': ['ID', 'Binary Path', 'OSS Name',
46
47
  'Comment', 'Vulnerability Link', 'TLSH', 'SHA1']}
47
48
 
48
49
 
49
- def init(path_to_find_bin, output_file_name, format, path_to_exclude=[]):
50
+ def init(path_to_find_bin, output_file_name, formats, path_to_exclude=[]):
50
51
  global _root_path, logger, _start_time
51
52
 
52
53
  _json_ext = ".json"
@@ -59,22 +60,24 @@ def init(path_to_find_bin, output_file_name, format, path_to_exclude=[]):
59
60
  if not path_to_find_bin.endswith(os.path.sep):
60
61
  _root_path += os.path.sep
61
62
 
62
- success, msg, output_path, output_file, output_extension = check_output_format(output_file_name, format)
63
+ success, msg, output_path, output_files, output_extensions = check_output_formats(output_file_name, formats)
64
+
63
65
  if success:
64
66
  if output_path == "":
65
67
  output_path = os.getcwd()
66
68
  else:
67
69
  output_path = os.path.abspath(output_path)
68
70
 
69
- if output_file != "":
70
- result_report = output_file
71
- else:
72
- if output_extension == _json_ext:
73
- result_report = f"fosslight_opossum_bin_{_start_time}"
74
- else:
75
- result_report = f"fosslight_report_bin_{_start_time}"
71
+ while len(output_files) < len(output_extensions):
72
+ output_files.append(None)
73
+ for i, output_extension in enumerate(output_extensions):
74
+ if output_files[i] is None or output_files[i] == "":
75
+ if output_extension == _json_ext:
76
+ output_files[i] = f"fosslight_opossum_bin_{_start_time}"
77
+ else:
78
+ output_files[i] = f"fosslight_report_bin_{_start_time}"
76
79
 
77
- result_report = os.path.join(output_path, result_report)
80
+ combined_paths_and_files = [os.path.join(output_path, file) for file in output_files]
78
81
  else:
79
82
  logger.error(f"Format error - {msg}")
80
83
  sys.exit(1)
@@ -86,7 +89,7 @@ def init(path_to_find_bin, output_file_name, format, path_to_exclude=[]):
86
89
  error_occured(error_msg=msg,
87
90
  result_log=_result_log,
88
91
  exit=True)
89
- return _result_log, result_report, output_extension
92
+ return _result_log, combined_paths_and_files, output_extensions
90
93
 
91
94
 
92
95
  def get_file_list(path_to_find, abs_path_to_exclude):
@@ -104,7 +107,7 @@ def get_file_list(path_to_find, abs_path_to_exclude):
104
107
  for exclude_path in abs_path_to_exclude):
105
108
  continue
106
109
  file_lower_case = file.lower()
107
- extension = file_lower_case.split(".")[-1]
110
+ extension = os.path.splitext(file_lower_case)[1][1:].strip()
108
111
 
109
112
  if extension == 'jar':
110
113
  found_jar = True
@@ -125,16 +128,18 @@ def get_file_list(path_to_find, abs_path_to_exclude):
125
128
  bin_item.set_exclude(True)
126
129
  elif file.lower() in _EXCLUDE_FILE:
127
130
  bin_item.set_exclude(True)
131
+ elif extension in _EXCLUDE_FILE_EXTENSION:
132
+ bin_item.set_exclude(True)
128
133
  bin_list.append(bin_item)
129
134
  file_cnt += 1
130
135
  return file_cnt, bin_list, found_jar
131
136
 
132
137
 
133
- def find_binaries(path_to_find_bin, output_dir, format, dburl="", simple_mode=False,
138
+ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=False,
134
139
  correct_mode=True, correct_filepath="", path_to_exclude=[]):
135
140
 
136
- _result_log, result_report, output_extension = init(
137
- path_to_find_bin, output_dir, format, path_to_exclude)
141
+ _result_log, result_reports, output_extensions = init(
142
+ path_to_find_bin, output_dir, formats, path_to_exclude)
138
143
 
139
144
  total_bin_cnt = 0
140
145
  total_file_cnt = 0
@@ -143,7 +148,7 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl="", simple_mode=Fa
143
148
  writing_msg = ""
144
149
  hide_header = {'TLSH', "SHA1"}
145
150
  content_list = []
146
- result_file = ""
151
+ results = []
147
152
  bin_list = []
148
153
  base_dir_name = os.path.basename(path_to_find_bin)
149
154
  abs_path_to_exclude = [os.path.abspath(os.path.join(base_dir_name, path)) for path in path_to_exclude if path.strip() != ""]
@@ -197,20 +202,22 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl="", simple_mode=Fa
197
202
  if total_bin_cnt == 0:
198
203
  cover.comment += "(No binary detected.) "
199
204
  cover.comment += f"/ Total number of files: {total_file_cnt}"
200
- success_to_write, writing_msg, result_file = write_output_file(result_report, output_extension, sheet_list,
201
- BIN_EXT_HEADER, hide_header, cover)
205
+ for combined_path_and_file, output_extension in zip(result_reports, output_extensions):
206
+ results.append(write_output_file(combined_path_and_file, output_extension, sheet_list, BIN_EXT_HEADER, hide_header, cover))
207
+
202
208
  except Exception as ex:
203
209
  error_occured(error_msg=str(ex), exit=False)
204
210
 
205
- if success_to_write:
206
- if result_file:
207
- logger.info(f"Output file :{result_file}")
211
+ for success_to_write, writing_msg, result_file in results:
212
+ if success_to_write:
213
+ if result_file:
214
+ logger.info(f"Output file :{result_file}")
215
+ else:
216
+ logger.warning(f"{writing_msg}")
217
+ if cover.comment:
218
+ logger.info(cover.comment)
208
219
  else:
209
- logger.warning(f"{writing_msg}")
210
- if cover.comment:
211
- logger.info(cover.comment)
212
- else:
213
- logger.error(f"Fail to generate result file.:{writing_msg}")
220
+ logger.error(f"Fail to generate result file.:{writing_msg}")
214
221
 
215
222
  try:
216
223
  print_result_log(success=True, result_log=_result_log,
@@ -30,7 +30,7 @@ def main():
30
30
  parser.add_argument('-p', '--path', type=str, required=False)
31
31
  parser.add_argument('-o', '--output', type=str, required=False)
32
32
  parser.add_argument('-d', '--dburl', type=str, default='', required=False)
33
- parser.add_argument('-f', '--format', type=str, required=False)
33
+ parser.add_argument('-f', '--formats', type=str, required=False, nargs="*")
34
34
  parser.add_argument('-e', '--exclude', nargs="*", required=False, default=[])
35
35
  parser.add_argument('--notice', action='store_true', required=False)
36
36
  parser.add_argument('--no_correction', action='store_true', required=False)
@@ -66,8 +66,8 @@ def main():
66
66
  if args.dburl: # -d option
67
67
  db_url = args.dburl
68
68
 
69
- if args.format: # -f option
70
- format = args.format
69
+ if args.formats: # -f option
70
+ format = list(args.formats)
71
71
 
72
72
  if args.no_correction:
73
73
  correct_mode = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-binary
3
- Version: 4.1.31
3
+ Version: 4.1.33
4
4
  Summary: FOSSLight Binary Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_binary_scanner
6
6
  Author: LG Electronics
@@ -8,7 +8,7 @@ py-tlsh
8
8
  pytz
9
9
  XlsxWriter
10
10
  PyYAML
11
- fosslight_util>=1.4.43
11
+ fosslight_util~=1.4.47
12
12
  dependency-check
13
13
 
14
14
  [:"darwin" in sys_platform]