fosslight-util 2.1.37__tar.gz → 2.1.39__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.
- {fosslight_util-2.1.37/src/fosslight_util.egg-info → fosslight_util-2.1.39}/PKG-INFO +2 -2
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/requirements.txt +1 -1
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/setup.py +1 -1
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/cover.py +19 -1
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/download.py +83 -19
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/help.py +29 -17
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_excel.py +7 -2
- {fosslight_util-2.1.37 → fosslight_util-2.1.39/src/fosslight_util.egg-info}/PKG-INFO +2 -2
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/requires.txt +1 -1
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/LICENSE +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/MANIFEST.in +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/README.md +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/setup.cfg +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/__init__.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/_get_downloadable_url.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/compare_yaml.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/constant.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/correct.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/exclude.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/get_pom_license.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/oss_item.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/output_format.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/parsing_yaml.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/read_excel.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/resources/licenses.json +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/set_log.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/spdx_licenses.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/timer_thread.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_cyclonedx.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_opossum.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_scancodejson.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_spdx.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_txt.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util/write_yaml.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/SOURCES.txt +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/entry_points.txt +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/top_level.txt +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_cyclonedx.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_download.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_opossum.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_spdx_licenses.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_text.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_write_output.py +0 -0
- {fosslight_util-2.1.37 → fosslight_util-2.1.39}/tests/test_write_yaml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fosslight_util
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.39
|
|
4
4
|
Summary: FOSSLight Util
|
|
5
5
|
Home-page: https://github.com/fosslight/fosslight_util
|
|
6
6
|
Download-URL: https://github.com/fosslight/fosslight_util
|
|
@@ -22,7 +22,7 @@ Requires-Dist: lastversion
|
|
|
22
22
|
Requires-Dist: coloredlogs
|
|
23
23
|
Requires-Dist: beautifulsoup4
|
|
24
24
|
Requires-Dist: jsonmerge
|
|
25
|
-
Requires-Dist: spdx-tools==0.8
|
|
25
|
+
Requires-Dist: spdx-tools==0.8.2; sys_platform == "linux"
|
|
26
26
|
Requires-Dist: setuptools>=65.5.1
|
|
27
27
|
Requires-Dist: numpy
|
|
28
28
|
Requires-Dist: requests
|
|
@@ -18,8 +18,8 @@ class CoverItem:
|
|
|
18
18
|
|
|
19
19
|
PKG_NAMES = [
|
|
20
20
|
"fosslight_scanner",
|
|
21
|
-
"fosslight_source",
|
|
22
21
|
"fosslight_dependency",
|
|
22
|
+
"fosslight_source",
|
|
23
23
|
"fosslight_binary"
|
|
24
24
|
]
|
|
25
25
|
|
|
@@ -48,6 +48,24 @@ class CoverItem:
|
|
|
48
48
|
def __del__(self):
|
|
49
49
|
pass
|
|
50
50
|
|
|
51
|
+
def get_sort_order(self):
|
|
52
|
+
for idx, pkg_name in enumerate(self.PKG_NAMES[1:], start=0):
|
|
53
|
+
if pkg_name in self.tool_name:
|
|
54
|
+
return idx
|
|
55
|
+
return 999
|
|
56
|
+
|
|
57
|
+
def __lt__(self, other):
|
|
58
|
+
return self.get_sort_order() < other.get_sort_order()
|
|
59
|
+
|
|
60
|
+
def create_merged_comment(self, cover_items):
|
|
61
|
+
if not cover_items:
|
|
62
|
+
return ""
|
|
63
|
+
sorted_items = sorted(cover_items)
|
|
64
|
+
comments = []
|
|
65
|
+
for ci in sorted_items:
|
|
66
|
+
comments.append(f'[{ci.tool_name}] {ci.comment}')
|
|
67
|
+
return '\n'.join(comments)
|
|
68
|
+
|
|
51
69
|
def get_print_json(self):
|
|
52
70
|
json_item = {}
|
|
53
71
|
json_item[self.tool_name_key] = self.tool_name
|
|
@@ -10,7 +10,7 @@ import zipfile
|
|
|
10
10
|
import logging
|
|
11
11
|
import argparse
|
|
12
12
|
import shutil
|
|
13
|
-
from git import
|
|
13
|
+
from git import Git
|
|
14
14
|
import bz2
|
|
15
15
|
import contextlib
|
|
16
16
|
from datetime import datetime
|
|
@@ -217,7 +217,19 @@ def get_remote_refs(git_url: str):
|
|
|
217
217
|
tags = []
|
|
218
218
|
branches = []
|
|
219
219
|
try:
|
|
220
|
-
|
|
220
|
+
env = os.environ.copy()
|
|
221
|
+
env["GIT_TERMINAL_PROMPT"] = "0"
|
|
222
|
+
env["GIT_ASKPASS"] = "echo"
|
|
223
|
+
env["GIT_CREDENTIAL_HELPER"] = ""
|
|
224
|
+
if "GIT_SSH_COMMAND" not in env:
|
|
225
|
+
env["GIT_SSH_COMMAND"] = "ssh -o BatchMode=yes -o StrictHostKeyChecking=no"
|
|
226
|
+
else:
|
|
227
|
+
env["GIT_SSH_COMMAND"] = env["GIT_SSH_COMMAND"] + " -o BatchMode=yes"
|
|
228
|
+
cp = subprocess.run(
|
|
229
|
+
["git", "-c", "credential.helper=", "-c", "credential.helper=!",
|
|
230
|
+
"ls-remote", "--tags", "--heads", git_url],
|
|
231
|
+
env=env, capture_output=True, text=True, timeout=30,
|
|
232
|
+
stdin=subprocess.DEVNULL)
|
|
221
233
|
if cp.returncode == 0:
|
|
222
234
|
for line in cp.stdout.splitlines():
|
|
223
235
|
parts = line.split('\t')
|
|
@@ -291,32 +303,84 @@ def download_git_repository(refs_to_checkout, git_url, target_dir, tag, called_c
|
|
|
291
303
|
|
|
292
304
|
logger.info(f"Download git url :{git_url}")
|
|
293
305
|
env = os.environ.copy()
|
|
294
|
-
|
|
295
|
-
|
|
306
|
+
env["GIT_TERMINAL_PROMPT"] = "0"
|
|
307
|
+
if platform.system() == "Windows":
|
|
308
|
+
env["GIT_ASKPASS"] = "echo"
|
|
309
|
+
else:
|
|
310
|
+
env["GIT_ASKPASS"] = "/bin/echo"
|
|
311
|
+
env["GIT_CREDENTIAL_HELPER"] = ""
|
|
312
|
+
# Disable credential helper via config
|
|
313
|
+
if "GIT_CONFIG_COUNT" not in env:
|
|
314
|
+
env["GIT_CONFIG_COUNT"] = "1"
|
|
315
|
+
env["GIT_CONFIG_KEY_0"] = "credential.helper"
|
|
316
|
+
env["GIT_CONFIG_VALUE_0"] = ""
|
|
317
|
+
if "GIT_SSH_COMMAND" not in env:
|
|
318
|
+
env["GIT_SSH_COMMAND"] = "ssh -o BatchMode=yes -o StrictHostKeyChecking=no"
|
|
319
|
+
else:
|
|
320
|
+
env["GIT_SSH_COMMAND"] = env["GIT_SSH_COMMAND"] + " -o BatchMode=yes"
|
|
321
|
+
|
|
296
322
|
if refs_to_checkout:
|
|
297
323
|
try:
|
|
298
|
-
#
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
324
|
+
# For tags, we need full history. For branches, shallow clone is possible but
|
|
325
|
+
# we use full clone to ensure compatibility with all cases
|
|
326
|
+
# Use subprocess to ensure environment variables are properly passed
|
|
327
|
+
cmd = ["git", "-c", "credential.helper=", "-c", "credential.helper=!", "clone", git_url, target_dir]
|
|
328
|
+
result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=600, stdin=subprocess.DEVNULL)
|
|
329
|
+
if result.returncode == 0:
|
|
330
|
+
# Checkout the specific branch or tag
|
|
331
|
+
checkout_cmd = ["git", "-C", target_dir, "checkout", refs_to_checkout]
|
|
332
|
+
checkout_result = subprocess.run(
|
|
333
|
+
checkout_cmd, env=env, capture_output=True, text=True,
|
|
334
|
+
timeout=60, stdin=subprocess.DEVNULL)
|
|
335
|
+
if checkout_result.returncode == 0:
|
|
336
|
+
if any(Path(target_dir).iterdir()):
|
|
337
|
+
success = True
|
|
338
|
+
oss_version = refs_to_checkout
|
|
339
|
+
logger.info(f"Files found in {target_dir} after clone and checkout.")
|
|
340
|
+
else:
|
|
341
|
+
logger.info(f"No files found in {target_dir} after clone.")
|
|
342
|
+
success = False
|
|
343
|
+
else:
|
|
344
|
+
logger.info(f"Git checkout error: {checkout_result.stderr}")
|
|
345
|
+
# Clone succeeded but checkout failed (e.g. non-existent ref):
|
|
346
|
+
# repo has default branch; treat as success with empty version
|
|
347
|
+
if any(Path(target_dir).iterdir()):
|
|
348
|
+
success = True
|
|
349
|
+
oss_version = ""
|
|
350
|
+
logger.info("Checkout failed; keeping default branch.")
|
|
304
351
|
else:
|
|
305
|
-
logger.info(f"
|
|
352
|
+
logger.info(f"Git clone error: {result.stderr}")
|
|
306
353
|
success = False
|
|
307
|
-
except
|
|
308
|
-
logger.info(
|
|
354
|
+
except subprocess.TimeoutExpired:
|
|
355
|
+
logger.info("Git clone timeout")
|
|
309
356
|
success = False
|
|
310
357
|
except Exception as e:
|
|
311
|
-
logger.info(f"
|
|
358
|
+
logger.info(f"Git clone error:{e}")
|
|
312
359
|
success = False
|
|
313
360
|
|
|
314
361
|
if not success:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
362
|
+
try:
|
|
363
|
+
# Use subprocess to ensure environment variables are properly passed
|
|
364
|
+
# No checkout needed, so shallow clone is sufficient
|
|
365
|
+
cmd = [
|
|
366
|
+
"git", "-c", "credential.helper=", "-c", "credential.helper=!",
|
|
367
|
+
"clone", "--depth", "1", git_url, target_dir
|
|
368
|
+
]
|
|
369
|
+
result = subprocess.run(cmd, env=env, capture_output=True, text=True, timeout=600, stdin=subprocess.DEVNULL)
|
|
370
|
+
if result.returncode == 0:
|
|
371
|
+
if any(Path(target_dir).iterdir()):
|
|
372
|
+
success = True
|
|
373
|
+
else:
|
|
374
|
+
logger.info(f"No files found in {target_dir} after clone.")
|
|
375
|
+
success = False
|
|
376
|
+
else:
|
|
377
|
+
logger.info(f"Git clone error: {result.stderr}")
|
|
378
|
+
success = False
|
|
379
|
+
except subprocess.TimeoutExpired:
|
|
380
|
+
logger.info("Git clone timeout")
|
|
381
|
+
success = False
|
|
382
|
+
except Exception as e:
|
|
383
|
+
logger.info(f"Git clone error:{e}")
|
|
320
384
|
success = False
|
|
321
385
|
return success, oss_version
|
|
322
386
|
|
|
@@ -55,23 +55,35 @@ _HELP_MESSAGE_COMMON = f"""
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
_HELP_MESSAGE_DOWNLOAD = """
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
📖 Usage
|
|
59
|
+
────────────────────────────────────────────────────────────────────
|
|
60
|
+
fosslight_download [options] <arguments>
|
|
61
|
+
|
|
62
|
+
📝 Description
|
|
63
|
+
────────────────────────────────────────────────────────────────────
|
|
64
|
+
FOSSLight Downloader is a tool to download a package or source code from a given URL.
|
|
65
|
+
|
|
66
|
+
⚙️ General Options
|
|
67
|
+
────────────────────────────────────────────────────────────────────
|
|
68
|
+
-s <url> URL of the package or source to download (required)
|
|
69
|
+
-t <path> Output directory to save the downloaded files
|
|
70
|
+
-d <log_dir> Directory to save the log file
|
|
71
|
+
-c <branch/tag> Checkout to branch, tag, or version after download
|
|
72
|
+
-z Unzip only compressed file
|
|
73
|
+
-o Generate summary output file
|
|
74
|
+
-h Show this help message
|
|
75
|
+
|
|
76
|
+
💡 Examples
|
|
77
|
+
────────────────────────────────────────────────────────────────────
|
|
78
|
+
# Download a GitHub repository to output_dir and save log
|
|
79
|
+
fosslight_download -s https://github.com/fosslight/fosslight -t output_dir -d log_dir
|
|
80
|
+
|
|
81
|
+
# Download and checkout to a specific branch
|
|
82
|
+
fosslight_download -s https://github.com/fosslight/fosslight -t output_dir -c develop
|
|
83
|
+
|
|
84
|
+
# Download and unzip a compressed file
|
|
85
|
+
fosslight_download -s https://example.com/archive.zip -z -t output_dir
|
|
86
|
+
"""
|
|
75
87
|
|
|
76
88
|
|
|
77
89
|
class PrintHelpMsg():
|
|
@@ -9,7 +9,7 @@ import logging
|
|
|
9
9
|
import os
|
|
10
10
|
import pandas as pd
|
|
11
11
|
from pathlib import Path
|
|
12
|
-
from fosslight_util.constant import LOGGER_NAME, SHEET_NAME_FOR_SCANNER, FOSSLIGHT_BINARY
|
|
12
|
+
from fosslight_util.constant import LOGGER_NAME, SHEET_NAME_FOR_SCANNER, FOSSLIGHT_BINARY, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SOURCE
|
|
13
13
|
from jsonmerge import merge
|
|
14
14
|
|
|
15
15
|
_HEADER = {'BIN (': ['ID', 'Binary Path', 'Source Code Path',
|
|
@@ -121,7 +121,12 @@ def write_result_to_excel(out_file_name, scan_item, extended_header={}, hide_hea
|
|
|
121
121
|
workbook = xlsxwriter.Workbook(out_file_name)
|
|
122
122
|
write_cover_sheet(workbook, scan_item.cover)
|
|
123
123
|
if scan_item.file_items and len(scan_item.file_items.keys()) > 0:
|
|
124
|
-
|
|
124
|
+
sheet_order = [FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SOURCE, FOSSLIGHT_BINARY]
|
|
125
|
+
all_scanners = list(scan_item.file_items.keys())
|
|
126
|
+
priority = {name.lower(): idx for idx, name in enumerate(sheet_order)}
|
|
127
|
+
sorted_scanner_names = sorted(all_scanners,
|
|
128
|
+
key=lambda x: priority.get(x.lower(), len(priority)))
|
|
129
|
+
for scanner_name in sorted_scanner_names:
|
|
125
130
|
sheet_name = ""
|
|
126
131
|
if scanner_name.lower() in SHEET_NAME_FOR_SCANNER:
|
|
127
132
|
sheet_name = SHEET_NAME_FOR_SCANNER[scanner_name.lower()]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fosslight_util
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.39
|
|
4
4
|
Summary: FOSSLight Util
|
|
5
5
|
Home-page: https://github.com/fosslight/fosslight_util
|
|
6
6
|
Download-URL: https://github.com/fosslight/fosslight_util
|
|
@@ -22,7 +22,7 @@ Requires-Dist: lastversion
|
|
|
22
22
|
Requires-Dist: coloredlogs
|
|
23
23
|
Requires-Dist: beautifulsoup4
|
|
24
24
|
Requires-Dist: jsonmerge
|
|
25
|
-
Requires-Dist: spdx-tools==0.8
|
|
25
|
+
Requires-Dist: spdx-tools==0.8.2; sys_platform == "linux"
|
|
26
26
|
Requires-Dist: setuptools>=65.5.1
|
|
27
27
|
Requires-Dist: numpy
|
|
28
28
|
Requires-Dist: requests
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fosslight_util-2.1.37 → fosslight_util-2.1.39}/src/fosslight_util.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|