Skip to content

Commit b9d9e87

Browse files
authored
Merge pull request #29 from fosslight/dev2
Do not print comment if there is no information from OWASP
2 parents 8aaa528 + e9a4f79 commit b9d9e87

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

src/fosslight_binary/_jar_analysis.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ def ananlyze_jar_file(path_to_find_bin):
133133
if oss_ver == "" and (product_info['name'] == 'Implementation-Version' or product_info['name'] == 'Bundle-Version'):
134134
oss_ver = product_info['value']
135135

136-
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
137-
oss.set_comment("OWASP Result. ")
138-
139-
remove_owasp_item = owasp_items.get(file_with_path)
140-
if remove_owasp_item:
141-
remove_owasp_item.append(oss)
142-
else:
143-
owasp_items[file_with_path] = [oss]
136+
if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "":
137+
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
138+
oss.set_comment("OWASP Result. ")
139+
140+
remove_owasp_item = owasp_items.get(file_with_path)
141+
if remove_owasp_item:
142+
remove_owasp_item.append(oss)
143+
else:
144+
owasp_items[file_with_path] = [oss]
144145

145146
except Exception as ex:
146147
logger.warning(f"Error to read json file : {ex}")

src/fosslight_binary/binary_analysis.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_error_logs = []
4040
_root_path = ""
4141
_start_time = ""
42+
windows = False
4243

4344

4445
def init(path_to_find_bin, output_file_name, format):
@@ -129,6 +130,8 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
129130
total_bin_cnt = 0
130131
total_file_cnt = 0
131132
db_loaded_cnt = 0
133+
success_to_write = False
134+
writing_msg = ""
132135

133136
try:
134137
if not os.path.isdir(path_to_find_bin):
@@ -166,14 +169,25 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
166169

167170
success_to_write, writing_msg = write_output_file(result_report, output_extension,
168171
sheet_list)
169-
logger.info("Writing Output file(" + os.path.basename(result_report) + output_extension
170-
+ "):" + str(success_to_write) + " " + writing_msg)
171-
if success_to_write:
172-
_result_log["Output file"] = result_report + output_extension
173-
174172
except Exception as ex:
175173
error_occured(error_msg=str(ex), exit=False)
176174

175+
# Print Result
176+
try:
177+
output_files = []
178+
if output_extension == "":
179+
output_extension = ".xlsx"
180+
if not windows:
181+
output_files.append(f"{result_report}.csv")
182+
output_files.insert(0, f"{result_report}{output_extension}")
183+
184+
logger.info(f"Writing Output file ({output_files[0]}"
185+
f"):{success_to_write} {writing_msg}")
186+
if success_to_write:
187+
_result_log["Output file"] = output_files
188+
except Exception as ex:
189+
error_occured(error_msg=f"Print log:{ex}", exit=False)
190+
177191
print_result_log(success=True, result_log=_result_log,
178192
file_cnt=str(total_file_cnt), bin_file_cnt=str(total_bin_cnt),
179193
auto_bin_cnt=str(db_loaded_cnt))
@@ -241,6 +255,7 @@ def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="",
241255

242256

243257
def main():
258+
global windows
244259
argv = sys.argv[1:]
245260
output_dir = ""
246261
path_to_find_bin = ""
@@ -265,9 +280,9 @@ def main():
265280
except Exception:
266281
print_help_msg()
267282

268-
_windows = platform.system() == "Windows"
283+
windows = platform.system() == "Windows"
269284
if path_to_find_bin == "":
270-
if _windows:
285+
if windows:
271286
path_to_find_bin = os.getcwd()
272287
else:
273288
print_help_msg()

0 commit comments

Comments
 (0)