fosslight-dependency 4.1.31__py3-none-any.whl → 4.1.32__py3-none-any.whl

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.
@@ -6,68 +6,89 @@ from fosslight_util.help import PrintHelpMsg, print_package_version
6
6
  from fosslight_util.output_format import SUPPORT_FORMAT
7
7
 
8
8
  _HELP_MESSAGE_DEPENDENCY = f"""
9
- Usage: fosslight_dependency [option1] <arg1> [option2] <arg2>...
10
-
11
- FOSSLight Dependency Scanner is the tool that supports the analysis of dependencies for multiple package managers.
12
- It detects the manifest file of package managers automatically and analyzes the dependencies with using open source tools.
13
- Then, it generates the report file that contains OSS information of dependencies.
14
-
15
- Currently, it supports the following package managers:
16
- Gradle (Java)
17
- Maven (Java)
18
- NPM (Node.js)
19
- PNPM (Node.js)
20
- Yarn (Node.js)
21
- PIP (Python)
22
- Pub (Dart with flutter)
23
- Cocoapods (Swift/Obj-C)
24
- Swift (Swift)
25
- Carthage (Swift/Obj-C)
26
- Go (Go)
27
- Nuget (.NET)
28
- Helm (Kubernetes)
29
- Unity (Unity)
30
- Cargo (Rust)
31
-
32
- Options:
33
- Optional
34
- -h\t\t\t\t Print help message.
35
- -v\t\t\t\t Print the version of the script.
36
- -m <package_manager>\t Enter the package manager.
37
- \t(npm, maven, gradle, pypi, pub, cocoapods, android, swift, carthage,
38
- \t go, nuget, helm, unity, cargo, pnpm, yarn)
39
- -p <input_path>\t\t Enter the path where the script will be run.
40
- -e <exclude_path>\t\t Enter the path where the analysis will not be performed (files and directories).
41
- \t\t\t\t * IMPORTANT: Always wrap patterns in double quotes ("") to avoid shell expansion.
42
- \t\t\t\t Example) fosslight_dependency -e "test/abc.py" "*.jar"
43
- -o <output_path>\t\t Output path
44
- \t\t\t\t\t(If you want to generate the specific file name, add the output path with file name.)
45
- -f <format> [<format> ...]\t Output formats
46
- \t\t\t\t \t({', '.join(SUPPORT_FORMAT)})
47
- \t\t\t\t Multiple formats can be specified separated by space.
48
- --graph-path <save_path> \t Enter the path where the graph image will be saved
49
- \t\t\t\t\t(ex. /your/directory/path/filename.[pdf, jpg, png]) (recommend pdf extension)
50
- --graph-size <width> <height> Enter the size of the graph image (The size unit is pixels)
51
- \t\t\t\t\t--graph-path option is required
52
- --direct\t\t\t Print the direct/transitive dependency type in comment.
53
- \t\tChoice 'True' or 'False'. (default:True)
54
- -r\t\t\t\t Recursive mode. Scan all subdirectories for manifest files.
55
- --notice\t\t\t Print the open source license notice text.
56
-
57
- Required only for swift, carthage
58
- -t <token>\t\t\t Enter the github personal access token.
59
-
60
- Optional only for pypi
61
- -a <activate_cmd>\t\t Virtual environment activate command(ex, 'conda activate (venv name)')
62
- -d <deactivate_cmd>\t\t Virtual environment deactivate command(ex, 'conda deactivate')
63
-
64
- Optional only for gradle, maven
65
- -c <dir_name>\t\t Enter the customized build output directory name
66
- \t\t-Default name : 'build' for gradle, 'target' for maven
67
-
68
- Optional only for android
69
- -n <app_name>\t\t Enter the application directory name where the plugin output file is located(default: app)
70
- """
9
+ 📖 Usage
10
+ ────────────────────────────────────────────────────────────────────
11
+ fosslight_dependency [options] <arguments>
12
+
13
+ 📝 Description
14
+ ────────────────────────────────────────────────────────────────────
15
+ FOSSLight Dependency Scanner analyzes dependencies for multiple package
16
+ managers. It detects manifest files automatically and generates reports
17
+ containing OSS information of dependencies.
18
+
19
+ 📚 Guide: https://fosslight.org/fosslight-guide/scanner/3_dependency.html
20
+
21
+ 📦 Supported Package Managers
22
+ ────────────────────────────────────────────────────────────────────
23
+ Gradle, Maven (Java) │ NPM, PNPM, Yarn (Node.js)
24
+ PIP (Python) │ Pub (Dart/Flutter)
25
+ Cocoapods, Swift, Carthage Go (Go)
26
+ Nuget (.NET) │ Helm (Kubernetes)
27
+ Unity (Unity) │ Cargo (Rust)
28
+
29
+ ⚙️ General Options
30
+ ────────────────────────────────────────────────────────────────────
31
+ -p <path> Path to analyze (default: current directory)
32
+ -o <path> Output file path or directory
33
+ -f <format> Output formats: {', '.join(SUPPORT_FORMAT)}
34
+ -e <pattern> Exclude paths from analysis (files and directories)
35
+ ⚠️ IMPORTANT: Always wrap in quotes to avoid shell expansion
36
+ Example: fosslight_dependency -e "test/" "node_modules/"
37
+ -h Show this help message
38
+ -v Show version information
39
+
40
+ 🔍 Scanner-Specific Options
41
+ ────────────────────────────────────────────────────────────────────
42
+ -m <manager> Specify package manager (npm, maven, gradle, pypi, pub,
43
+ cocoapods, android, swift, carthage, go, nuget, helm,
44
+ unity, cargo, pnpm, yarn)
45
+ -r Recursive mode: scan all subdirectories for manifest files
46
+ --graph-path <path> Save dependency graph image (pdf, jpg, png) (recommend pdf extension)
47
+ Example: fosslight_dependency --graph-path /your/path/filename.[pdf, jpg, png]
48
+ --graph-format <format> Set graph image format (default: pdf)
49
+ --graph-size <w> <h> Set graph image size in pixels (requires --graph-path)
50
+ --direct <True|False> Print direct/transitive dependency type
51
+ Choose True or False (default: True)
52
+ --notice Print the open source license notice text
53
+
54
+ 🔧 Package Manager Specific Options
55
+ ────────────────────────────────────────────────────────────────────
56
+ Swift, Carthage:
57
+ -t <token> GitHub personal access token
58
+
59
+ Pypi:
60
+ -a <cmd> Virtual environment activate command
61
+ (ex: 'conda activate myenv')
62
+ -d <cmd> Virtual environment deactivate command
63
+ (ex: 'conda deactivate')
64
+
65
+ Gradle, Maven:
66
+ -c <dir> Customized build output directory
67
+ (default: 'build' for gradle, 'target' for maven)
68
+
69
+ Android:
70
+ -n <name> Application directory name (default: app)
71
+
72
+ 💡 Examples
73
+ ────────────────────────────────────────────────────────────────────
74
+ # Scan current directory
75
+ fosslight_dependency
76
+
77
+ # Scan specific path with exclusions
78
+ fosslight_dependency -p /path/to/project -e "test/" "vendor/"
79
+
80
+ # Generate output in specific format
81
+ fosslight_dependency -f excel -o results/
82
+
83
+ # Specify package manager
84
+ fosslight_dependency -m npm -p /path/to/nodejs/project
85
+
86
+ # Recursive scan with all subdirectories
87
+ fosslight_dependency -r
88
+
89
+ # Generate dependency graph
90
+ fosslight_dependency --graph-path dependency_tree.pdf
91
+ """
71
92
 
72
93
 
73
94
  def print_version(pkg_name: str) -> None:
@@ -195,8 +195,7 @@ class Npm(PackageManager):
195
195
  else:
196
196
  npm_url_exists = False
197
197
  if self._network_available is True:
198
- npm_url_exists = self._npm_url_exists(oss_init_name)
199
-
198
+ npm_url_exists = self._npm_url_exists(oss_init_name, oss_item.version)
200
199
  if self._network_available and not npm_url_exists:
201
200
  oss_item.homepage = repo_url or ""
202
201
  oss_item.download_location = oss_item.homepage
@@ -242,8 +241,11 @@ class Npm(PackageManager):
242
241
  self._network_available = False
243
242
  return self._network_available
244
243
 
245
- def _npm_url_exists(self, package_name: str) -> bool:
246
- url = f"https://registry.npmjs.org/{package_name}"
244
+ def _npm_url_exists(self, package_name: str, oss_version="") -> bool:
245
+ if oss_version:
246
+ url = f"https://registry.npmjs.org/{package_name}/{oss_version}"
247
+ else:
248
+ url = f"https://registry.npmjs.org/{package_name}"
247
249
  try:
248
250
  resp = requests.head(url, timeout=3, allow_redirects=True)
249
251
  if resp.status_code == 405:
@@ -10,6 +10,7 @@ import json
10
10
  import shutil
11
11
  import copy
12
12
  import re
13
+ import sys
13
14
  import fosslight_util.constant as constant
14
15
  import fosslight_dependency.constant as const
15
16
  from fosslight_dependency._package_manager import PackageManager
@@ -51,6 +52,89 @@ class Pypi(PackageManager):
51
52
  def set_pip_deactivate_cmd(self, pip_deactivate_cmd):
52
53
  self.pip_deactivate_cmd = pip_deactivate_cmd
53
54
 
55
+ def get_virtualenv_site_packages(self):
56
+ site_packages = ''
57
+ try:
58
+ venv_path = os.path.join(self.input_dir, self.venv_tmp_dir)
59
+ if os.path.exists(venv_path):
60
+ site_packages = os.path.join(
61
+ venv_path, 'lib',
62
+ f"python{sys.version_info.major}.{sys.version_info.minor}",
63
+ 'site-packages'
64
+ )
65
+ if os.path.exists(site_packages):
66
+ return site_packages
67
+
68
+ if self.pip_activate_cmd:
69
+ activate_cmd = self.pip_activate_cmd
70
+ if activate_cmd.startswith('. '):
71
+ activate_cmd = activate_cmd[2:]
72
+ elif activate_cmd.startswith('source '):
73
+ activate_cmd = activate_cmd[7:]
74
+
75
+ if 'bin/activate' in activate_cmd or 'Scripts/activate' in activate_cmd:
76
+ venv_path = activate_cmd.replace('/bin/activate', '')
77
+ venv_path = venv_path.replace('\\Scripts\\activate.bat', '')
78
+ venv_path = venv_path.replace('\\Scripts\\activate', '')
79
+
80
+ if not os.path.isabs(venv_path):
81
+ venv_path = os.path.join(self.input_dir, venv_path)
82
+
83
+ if os.path.exists(venv_path):
84
+ for lib_dir in ['lib', 'Lib']:
85
+ site_packages = os.path.join(
86
+ venv_path, lib_dir,
87
+ f"python{sys.version_info.major}.{sys.version_info.minor}",
88
+ 'site-packages'
89
+ )
90
+ if os.path.exists(site_packages):
91
+ return site_packages
92
+ site_packages = os.path.join(venv_path, 'Lib', 'site-packages')
93
+ if os.path.exists(site_packages):
94
+ return site_packages
95
+
96
+ if 'conda' in activate_cmd:
97
+ site_packages = ''
98
+ except Exception as e:
99
+ logger.debug(f"Failed to get virtualenv site-packages: {e}")
100
+ site_packages = ''
101
+ return site_packages
102
+
103
+ def get_license_from_file(self, package_name, version, license_files_metadata=None):
104
+ license_names = []
105
+ try:
106
+ if not license_files_metadata:
107
+ return []
108
+ normalized_name = re.sub(r"[-_.]+", "_", package_name)
109
+ dist_info_name = f"{normalized_name}-{version}.dist-info"
110
+
111
+ site_packages = self.get_virtualenv_site_packages()
112
+ if not site_packages:
113
+ logger.debug("Could not find site-packages directory")
114
+ return []
115
+
116
+ dist_info_path = os.path.join(site_packages, dist_info_name)
117
+ if not os.path.exists(dist_info_path):
118
+ return []
119
+
120
+ for license_file in license_files_metadata:
121
+ license_file_path = os.path.join(dist_info_path, license_file)
122
+ if os.path.isfile(license_file_path):
123
+ license_name = check_license_name(license_file_path, is_filepath=True)
124
+ if license_name and license_name not in license_names:
125
+ license_names.append(license_name)
126
+ else:
127
+ if '/' not in license_file:
128
+ for root, _, files in os.walk(dist_info_path):
129
+ if license_file in files:
130
+ found_path = os.path.join(root, license_file)
131
+ license_name = check_license_name(found_path, is_filepath=True)
132
+ if license_name and license_name not in license_names:
133
+ license_names.append(license_name)
134
+ except Exception as e:
135
+ logger.debug(f"Failed to read license file for {package_name}: {e}")
136
+ return license_names
137
+
54
138
  def run_plugin(self):
55
139
  ret = True
56
140
 
@@ -275,22 +359,34 @@ class Pypi(PackageManager):
275
359
  oss_item.name = f"{self.package_manager_name}:{oss_init_name}"
276
360
  oss_item.version = metadata.get('version', '')
277
361
 
278
- # license_expression > license > classifier
362
+ # license_expression > classifier > license > license_file
279
363
  license_info = check_UNKNOWN(metadata.get('license_expression', ''))
280
- if not license_info:
281
- license_info = metadata.get('license', '')
282
- if '\n' in license_info:
283
- license_info = check_UNKNOWN(check_license_name(license_info))
284
364
  if not license_info:
285
365
  classifiers = metadata.get('classifier', [])
286
366
  license_classifiers = [c for c in classifiers if c.startswith('License ::')]
287
367
  if license_classifiers:
288
368
  license_info_l = []
289
369
  for license_classifier in license_classifiers:
290
- if license_classifier.startswith('License :: OSI Approved ::'):
291
- license_info_l.append(license_classifier.split('::')[-1].strip())
292
- break
370
+ parts = license_classifier.split(' :: ')
371
+ if len(parts) >= 2:
372
+ license_name = parts[-1].strip()
373
+ if license_name and license_name != 'OSI Approved':
374
+ license_info_l.append(license_name)
375
+ break
293
376
  license_info = ','.join(license_info_l)
377
+ if not license_info:
378
+ license_info = metadata.get('license', '')
379
+ if '\n' in license_info:
380
+ license_info = check_UNKNOWN(check_license_name(license_info))
381
+ if not license_info:
382
+ license_files_meta = metadata.get('license_file')
383
+ license_info_list = self.get_license_from_file(
384
+ oss_init_name,
385
+ oss_item.version,
386
+ license_files_meta
387
+ )
388
+ if license_info_list:
389
+ license_info = ','.join(license_info_list)
294
390
  license_name = check_UNKNOWN(license_info)
295
391
  if license_name:
296
392
  license_name = license_name.replace(';', ',')
@@ -139,7 +139,7 @@ class Yarn(Npm):
139
139
  else:
140
140
  npm_url_exists = False
141
141
  if self._network_available is True:
142
- npm_url_exists = self._npm_url_exists(oss_init_name)
142
+ npm_url_exists = self._npm_url_exists(oss_init_name, oss_item.version)
143
143
 
144
144
  if self._network_available and not npm_url_exists:
145
145
  oss_item.homepage = repo_url or ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_dependency
3
- Version: 4.1.31
3
+ Version: 4.1.32
4
4
  Summary: FOSSLight Dependency Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_dependency_scanner
6
6
  Download-URL: https://github.com/fosslight/fosslight_dependency_scanner
@@ -1,7 +1,7 @@
1
1
  fosslight_dependency/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  fosslight_dependency/_analyze_dependency.py,sha256=-iETqo4DNu_d8iJtC7Of0waY6YHjJ8OB8Lf_m-9WZXw,5888
3
3
  fosslight_dependency/_graph_convertor.py,sha256=D8GwmJfuj9Wg3_DeKRPLGGdyHSLcoU2Q0VzKQbkJG4g,2267
4
- fosslight_dependency/_help.py,sha256=1ER9CDiORhMdX1FYedPHcp2TRyvICPFGM1wxOOJ4PNE,3882
4
+ fosslight_dependency/_help.py,sha256=g_ArQJ7OmB9QtD8Eddhg3G6jhrrvPxPM6jWBGVZ-WLU,5266
5
5
  fosslight_dependency/_package_manager.py,sha256=-hEOG44AnBoSKjMM-WQAbZIXhD8kHc-EwkOl1aLu-CA,15824
6
6
  fosslight_dependency/cli.py,sha256=A4SyAr9zfwI5cKPiWHsPvkD64HtUlpS3CRJ9DN3ytqo,4929
7
7
  fosslight_dependency/constant.py,sha256=zaLjZsk4r5Gv6puCbV_Crt9pWrX_FEYzgEh0UQVIE4g,1291
@@ -17,21 +17,21 @@ fosslight_dependency/package_manager/Go.py,sha256=eEWvPoE3Jd0lMJAxWMNdFcoi21fJF0
17
17
  fosslight_dependency/package_manager/Gradle.py,sha256=zTMvospDpfabl2DRk1jW316lW9BJfGtf05TBcna6E8E,4640
18
18
  fosslight_dependency/package_manager/Helm.py,sha256=ucx2Y0tWX37UHIzIGaRyTe7uQ2vlu2nUuO09hOMq9ZU,4223
19
19
  fosslight_dependency/package_manager/Maven.py,sha256=F1KQxR_LjSxl7ZgRS_W1TbuDpRERLoAVGLIUWOpjLmk,11046
20
- fosslight_dependency/package_manager/Npm.py,sha256=6DSsRnk8tj8NUTjG4qFfybi9x-GW1I3FRGYbNn9IJpk,12300
20
+ fosslight_dependency/package_manager/Npm.py,sha256=m0Q_ET3WLD4iLIcr0G0Scl5kPf34fkn6tpW_tlagqTI,12452
21
21
  fosslight_dependency/package_manager/Nuget.py,sha256=Q_pDGxsNOboVcA6KCEt2rAdFvTB46Z5sOvY4pKwNiHo,17290
22
22
  fosslight_dependency/package_manager/Pnpm.py,sha256=LDKooFGQHui_Q5U7XqSJ8KcCPiLVndXf5oGKTJExh5w,7056
23
23
  fosslight_dependency/package_manager/Pub.py,sha256=g4jqA19vf3jBdlmPLVZiIYMAQHNn3Y2I-_oq3vtpfv0,10372
24
- fosslight_dependency/package_manager/Pypi.py,sha256=Ae-mFl9jSgc1XrUdzAuKGuZA4nduSsWaC-u6VVjFNtg,17187
24
+ fosslight_dependency/package_manager/Pypi.py,sha256=m_uG-OMI3SdgzSJUXEcIJ3X1XY6BwMt-RcqmsUaIE5M,21768
25
25
  fosslight_dependency/package_manager/Swift.py,sha256=8fdbdAXTNlp2NDoSqQXm48JGAg9UhxA91M1-NhHkT40,6752
26
26
  fosslight_dependency/package_manager/Unity.py,sha256=n1006GZ6Qrk8wAdO6wla1Q-JD7Evin7REVj-HDeTARc,5142
27
- fosslight_dependency/package_manager/Yarn.py,sha256=CdfvyegpBgHTI4Snj-KjkntYMwQ718c0Yz2zchXMoBE,10051
27
+ fosslight_dependency/package_manager/Yarn.py,sha256=ZSi7_O5tMmS80Z58YOZxvai84_KyDpP8plo0x80YtVc,10069
28
28
  fosslight_dependency/package_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- fosslight_dependency-4.1.31.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- fosslight_dependency-4.1.31.dist-info/licenses/LICENSES/Apache-2.0.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
31
- fosslight_dependency-4.1.31.dist-info/licenses/LICENSES/LicenseRef-3rd_party_licenses.txt,sha256=EcsFt7aE1rp3OXAdJgmXayfOZdpRdBMcmRnyoqWMCsw,95687
32
- fosslight_dependency-4.1.31.dist-info/licenses/LICENSES/MIT.txt,sha256=9cx4CbArgByWvkoEZNqpzbpJgA9TUe2D62rMocQpgfs,1082
33
- fosslight_dependency-4.1.31.dist-info/METADATA,sha256=mWoJrnTm0xW6nK9BxiV2xawEdlTh-97ZuRBCTgspxEQ,5555
34
- fosslight_dependency-4.1.31.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
35
- fosslight_dependency-4.1.31.dist-info/entry_points.txt,sha256=bJlbAsDzlnvBYHImO0uVqbVXdaDcBzMu4i_X5M8Pd1w,71
36
- fosslight_dependency-4.1.31.dist-info/top_level.txt,sha256=Jc0V7VcVCH0TEM8ksb8dwroTYz4AmRaQnlr3FB71Hcs,21
37
- fosslight_dependency-4.1.31.dist-info/RECORD,,
29
+ fosslight_dependency-4.1.32.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ fosslight_dependency-4.1.32.dist-info/licenses/LICENSES/Apache-2.0.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
31
+ fosslight_dependency-4.1.32.dist-info/licenses/LICENSES/LicenseRef-3rd_party_licenses.txt,sha256=EcsFt7aE1rp3OXAdJgmXayfOZdpRdBMcmRnyoqWMCsw,95687
32
+ fosslight_dependency-4.1.32.dist-info/licenses/LICENSES/MIT.txt,sha256=9cx4CbArgByWvkoEZNqpzbpJgA9TUe2D62rMocQpgfs,1082
33
+ fosslight_dependency-4.1.32.dist-info/METADATA,sha256=S3G17LR7Bk7-QCTJCRBGdpoF_uQBaaQXPz_1DV7FdGc,5555
34
+ fosslight_dependency-4.1.32.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
35
+ fosslight_dependency-4.1.32.dist-info/entry_points.txt,sha256=bJlbAsDzlnvBYHImO0uVqbVXdaDcBzMu4i_X5M8Pd1w,71
36
+ fosslight_dependency-4.1.32.dist-info/top_level.txt,sha256=Jc0V7VcVCH0TEM8ksb8dwroTYz4AmRaQnlr3FB71Hcs,21
37
+ fosslight_dependency-4.1.32.dist-info/RECORD,,