Skip to content

Commit 2352258

Browse files
committed
Fix to run correct mode only xlsx
Signed-off-by: Jiyeong Seok <[email protected]>
1 parent 15c6b17 commit 2352258

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
fosslight_source
21
future
32
pandas
43
xlrd
54
openpyxl
65
progress
76
pyyaml
87
beautifulsoup4
9-
fosslight_util>=1.4.16
8+
fosslight_util>=1.4.25
9+
fosslight_source>=1.6.28
1010
fosslight_dependency>=3.7.4
11-
fosslight_binary>=4.0.7
11+
fosslight_binary>=4.1.24
1212
fosslight_prechecker>=3.0.1

src/fosslight_scanner/_help.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
-t\t\t\t Hide the progress bar
3535
-v\t\t\t Print FOSSLight Scanner version
3636
--no_correction\t Enter if you don't want to correct OSS information with sbom-info.yaml
37+
* Correction mode only supported xlsx format.
3738
--correct_fpath <path> Path to the sbom-info.yaml file
3839
3940
Options for only 'all' or 'bin' mode

src/fosslight_scanner/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ def check_exclude_dir(oss_list):
302302
_exclude_dirs = ["venv", "node_modules", "Pods", "Carthage"]
303303

304304
for oss_item in oss_list:
305+
if not oss_item.source_name_or_path:
306+
continue
305307
for exclude_dir in _exclude_dirs:
306308
if exclude_dir in oss_item.source_name_or_path[0].split(os.path.sep):
307309
oss_item.exclude = True

src/fosslight_scanner/fosslight_scanner.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,36 +191,39 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
191191
try:
192192
output_file_without_ext = os.path.join(final_excel_dir, output_file)
193193
final_report = f"{output_file_without_ext}{output_extension}"
194-
tmp_dir = f"tmp_{datetime.now().strftime('%y%m%d_%H%M')}"
195-
exist_src = False
196-
exist_bin = False
197-
if correct_mode:
198-
os.makedirs(os.path.join(_output_dir, tmp_dir), exist_ok=True)
199-
if os.path.exists(os.path.join(_output_dir, output_files['SRC'])):
200-
exist_src = True
201-
shutil.copy2(os.path.join(_output_dir, output_files['SRC']), os.path.join(_output_dir, tmp_dir))
202-
if os.path.exists(os.path.join(_output_dir, output_files['BIN'])):
203-
exist_bin = True
204-
shutil.copy2(os.path.join(_output_dir, output_files['BIN']), os.path.join(_output_dir, tmp_dir))
205-
if exist_src or exist_bin:
206-
correct_scanner_result(_output_dir, output_files, output_extension, exist_src, exist_bin)
194+
207195
if output_extension == ".xlsx":
196+
tmp_dir = f"tmp_{datetime.now().strftime('%y%m%d_%H%M')}"
197+
exist_src = False
198+
exist_bin = False
199+
if correct_mode:
200+
os.makedirs(os.path.join(_output_dir, tmp_dir), exist_ok=True)
201+
if os.path.exists(os.path.join(_output_dir, output_files['SRC'])):
202+
exist_src = True
203+
shutil.copy2(os.path.join(_output_dir, output_files['SRC']), os.path.join(_output_dir, tmp_dir))
204+
if os.path.exists(os.path.join(_output_dir, output_files['BIN'])):
205+
exist_bin = True
206+
shutil.copy2(os.path.join(_output_dir, output_files['BIN']), os.path.join(_output_dir, tmp_dir))
207+
if exist_src or exist_bin:
208+
correct_scanner_result(_output_dir, output_files, output_extension, exist_src, exist_bin)
209+
208210
if remove_src_data:
209211
overwrite_excel(_output_dir, default_oss_name, "OSS Name")
210212
overwrite_excel(_output_dir, url, "Download Location")
211213
success, err_msg = merge_excels(_output_dir, final_report)
214+
215+
if correct_mode:
216+
if exist_src:
217+
shutil.move(os.path.join(_output_dir, tmp_dir, output_files['SRC']),
218+
os.path.join(_output_dir, output_files['SRC']))
219+
if exist_bin:
220+
shutil.move(os.path.join(_output_dir, tmp_dir, output_files['BIN']),
221+
os.path.join(_output_dir, output_files['BIN']))
222+
shutil.rmtree(os.path.join(_output_dir, tmp_dir), ignore_errors=True)
212223
elif output_extension == ".yaml":
213224
merge_yaml_files = [output_files["SRC"], output_files["BIN"], output_files["DEP"]]
214225
success, err_msg = merge_yamls(_output_dir, merge_yaml_files, final_report,
215226
remove_src_data, default_oss_name, url)
216-
if correct_mode:
217-
if exist_src:
218-
shutil.move(os.path.join(_output_dir, tmp_dir, output_files['SRC']),
219-
os.path.join(_output_dir, output_files['SRC']))
220-
if exist_bin:
221-
shutil.move(os.path.join(_output_dir, tmp_dir, output_files['BIN']),
222-
os.path.join(_output_dir, output_files['BIN']))
223-
shutil.rmtree(os.path.join(_output_dir, tmp_dir), ignore_errors=True)
224227
if success:
225228
if os.path.isfile(final_report):
226229
result_log["Output File"] = final_report

0 commit comments

Comments
 (0)