Install a plugin from a URL.
(
ctx: click.Context,
url: str,
sha256: Optional[str],
signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
)
| 295 | |
| 296 | |
| 297 | def _install_from_url( |
| 298 | ctx: click.Context, |
| 299 | url: str, |
| 300 | sha256: Optional[str], |
| 301 | signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT, |
| 302 | ) -> None: |
| 303 | """Install a plugin from a URL.""" |
| 304 | downloader = PluginDownloader() |
| 305 | enterprise_config = EnterpriseConfig.load() |
| 306 | |
| 307 | ui.display_info("Installing from URL...") |
| 308 | |
| 309 | try: |
| 310 | plugin_name, version, installed_wheel = downloader.download_from_url( |
| 311 | url, sha256, signature_mode=signature_mode |
| 312 | ) |
| 313 | |
| 314 | plugin_name = enable_installed_plugin( |
| 315 | enterprise_config, plugin_name, version, installed_wheel |
| 316 | ) |
| 317 | enterprise_config.save() |
| 318 | |
| 319 | ui.display_info(f"Installed {plugin_name} v{version}") |
| 320 | |
| 321 | except SignatureVerificationError as e: |
| 322 | ui.display_error(f"Signature verification failed: {e}") |
| 323 | ui.display_info( |
| 324 | "This plugin is not signed by GitGuardian. " |
| 325 | "If you trust its origin and still want to install it, " |
| 326 | "pass --allow-unsigned." |
| 327 | ) |
| 328 | ctx.exit(ExitCode.UNEXPECTED_ERROR) |
| 329 | except InsecureSourceError as e: |
| 330 | ui.display_error(str(e)) |
| 331 | ctx.exit(ExitCode.USAGE_ERROR) |
| 332 | except ChecksumMismatchError as e: |
| 333 | ui.display_error(f"Checksum verification failed: {e}") |
| 334 | ctx.exit(ExitCode.UNEXPECTED_ERROR) |
| 335 | except Exception as e: |
| 336 | ui.display_error(f"Failed to install from URL: {e}") |
| 337 | ctx.exit(ExitCode.UNEXPECTED_ERROR) |
| 338 | |
| 339 | |
| 340 | def _install_from_github_release( |
no test coverage detected