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

Function _install_from_github_artifact

ggshield/cmd/plugin/install.py:383–421  ·  view source on GitHub ↗

Install a plugin from a GitHub Actions artifact.

(
    ctx: click.Context,
    url: str,
    signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
)

Source from the content-addressed store, hash-verified

381
382
383def _install_from_github_artifact(
384 ctx: click.Context,
385 url: str,
386 signature_mode: SignatureVerificationMode = SignatureVerificationMode.STRICT,
387) -> None:
388 """Install a plugin from a GitHub Actions artifact."""
389 ui.display_warning("GitHub artifacts are ephemeral and cannot be auto-updated.")
390
391 downloader = PluginDownloader()
392 enterprise_config = EnterpriseConfig.load()
393
394 ui.display_info("Installing from GitHub artifact...")
395
396 try:
397 plugin_name, version, installed_wheel = (
398 downloader.download_from_github_artifact(url, signature_mode=signature_mode)
399 )
400
401 plugin_name = enable_installed_plugin(
402 enterprise_config, plugin_name, version, installed_wheel
403 )
404 enterprise_config.save()
405
406 ui.display_info(f"Installed {plugin_name} v{version}")
407
408 except SignatureVerificationError as e:
409 ui.display_error(f"Signature verification failed: {e}")
410 ui.display_info(
411 "This plugin is not signed by GitGuardian. "
412 "If you trust its origin and still want to install it, "
413 "pass --allow-unsigned."
414 )
415 ctx.exit(ExitCode.UNEXPECTED_ERROR)
416 except GitHubArtifactError as e:
417 ui.display_error(str(e))
418 ctx.exit(ExitCode.UNEXPECTED_ERROR)
419 except Exception as e:
420 ui.display_error(f"Failed to install from GitHub artifact: {e}")
421 ctx.exit(ExitCode.UNEXPECTED_ERROR)

Callers 1

install_cmdFunction · 0.85

Calls 8

PluginDownloaderClass · 0.90
enable_installed_pluginFunction · 0.90
display_warningMethod · 0.80
display_infoMethod · 0.80
display_errorMethod · 0.80
loadMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected