MCPcopy
hub / github.com/GitGuardian/ggshield / _install_from_url

Function _install_from_url

ggshield/cmd/plugin/install.py:297–337  ·  view source on GitHub ↗

Install a plugin from a URL.

(
    ctx: click.Context,
    url: str,
    sha256: Optional[str],
    signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
)

Source from the content-addressed store, hash-verified

295
296
297def _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
340def _install_from_github_release(

Callers 1

install_cmdFunction · 0.85

Calls 7

download_from_urlMethod · 0.95
PluginDownloaderClass · 0.90
enable_installed_pluginFunction · 0.90
display_infoMethod · 0.80
display_errorMethod · 0.80
loadMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected