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

Function _install_from_github_release

ggshield/cmd/plugin/install.py:340–380  ·  view source on GitHub ↗

Install a plugin from a GitHub release asset.

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

Source from the content-addressed store, hash-verified

338
339
340def _install_from_github_release(
341 ctx: click.Context,
342 url: str,
343 sha256: Optional[str],
344 signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
345) -> None:
346 """Install a plugin from a GitHub release asset."""
347 downloader = PluginDownloader()
348 enterprise_config = EnterpriseConfig.load()
349
350 ui.display_info("Installing from GitHub release...")
351
352 try:
353 plugin_name, version, installed_wheel = downloader.download_from_github_release(
354 url, sha256, signature_mode=signature_mode
355 )
356
357 plugin_name = enable_installed_plugin(
358 enterprise_config, plugin_name, version, installed_wheel
359 )
360 enterprise_config.save()
361
362 ui.display_info(f"Installed {plugin_name} v{version}")
363
364 except SignatureVerificationError as e:
365 ui.display_error(f"Signature verification failed: {e}")
366 ui.display_info(
367 "This plugin is not signed by GitGuardian. "
368 "If you trust its origin and still want to install it, "
369 "pass --allow-unsigned."
370 )
371 ctx.exit(ExitCode.UNEXPECTED_ERROR)
372 except InsecureSourceError as e:
373 ui.display_error(str(e))
374 ctx.exit(ExitCode.USAGE_ERROR)
375 except ChecksumMismatchError as e:
376 ui.display_error(f"Checksum verification failed: {e}")
377 ctx.exit(ExitCode.UNEXPECTED_ERROR)
378 except Exception as e:
379 ui.display_error(f"Failed to install from GitHub release: {e}")
380 ctx.exit(ExitCode.UNEXPECTED_ERROR)
381
382
383def _install_from_github_artifact(

Callers 1

install_cmdFunction · 0.85

Calls 7

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