Skip to content

Commit 3c06f70

Browse files
committed
Fix .jar analysis via Syft & Grype
1 parent 10b0aec commit 3c06f70

File tree

4 files changed

+504
-226
lines changed

4 files changed

+504
-226
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ pytz
99
XlsxWriter
1010
PyYAML
1111
fosslight_util>=2.1.13
12-
dependency-check

setup.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,40 @@
55
from codecs import open
66
import os
77
import shutil
8+
import subprocess
9+
import sys
810
from setuptools import setup, find_packages
11+
from setuptools.command.install import install
12+
13+
14+
class PostInstallCommand(install):
15+
"""Post-installation for installation mode."""
16+
def run(self):
17+
install.run(self)
18+
19+
# Skip auto-install if explicitly disabled
20+
if os.environ.get('FOSSLIGHT_SKIP_AUTO_INSTALL', '').lower() in ('1', 'true', 'yes'):
21+
print("Auto-install disabled by environment variable")
22+
return
23+
24+
# Install syft and grype using standalone installer
25+
try:
26+
print("Installing syft and grype...")
27+
# Use standalone installer script - no package dependencies!
28+
script_path = os.path.join(os.path.dirname(__file__), 'install_tools.py')
29+
if os.path.exists(script_path):
30+
result = subprocess.run([sys.executable, script_path],
31+
capture_output=True, text=True)
32+
if result.returncode == 0:
33+
print("Syft and grype installation completed.")
34+
else:
35+
print(f"Warning: Tool installation failed: {result.stderr}")
36+
else:
37+
print("Warning: install_tools.py not found, skipping auto-install")
38+
except Exception as e:
39+
print(f"Warning: Failed to auto-install syft/grype: {e}")
40+
print("You can install them manually or they will be installed on first use.")
41+
942

1043
with open('README.md', 'r', 'utf-8') as f:
1144
readme = f.read()
@@ -63,11 +96,19 @@
6396
},
6497
package_data={_PACKAEG_NAME: [os.path.join(_LICENSE_DIR, '*')]},
6598
include_package_data=True,
99+
# Include install_tools.py in the package
100+
data_files=[
101+
('', ['install_tools.py']),
102+
],
103+
cmdclass={
104+
'install': PostInstallCommand,
105+
},
66106
entry_points={
67107
"console_scripts": [
68108
"binary_analysis = fosslight_binary.cli:main",
69109
"fosslight_bin = fosslight_binary.cli:main",
70110
"fosslight_binary = fosslight_binary.cli:main",
111+
"fosslight_install_tools = fosslight_binary.install_cli:main",
71112
]
72113
}
73114
)

0 commit comments

Comments
 (0)