MCPcopy
hub / github.com/larksuite/cli / ExampleNewPlugin_restrict

Function ExampleNewPlugin_restrict

extension/platform/example_test.go:52–63  ·  view source on GitHub ↗

ExampleNewPlugin_restrict registers a policy plugin that allows only docs/* read commands. Note that Restrict() implicitly sets FailClosed — a policy plugin must abort the binary if it fails to install, not silently disappear.

()

Source from the content-addressed store, hash-verified

50// FailClosed — a policy plugin must abort the binary if it fails to
51// install, not silently disappear.
52func ExampleNewPlugin_restrict() {
53 p, _ := platform.NewPlugin("readonly-docs", "0.1.0").
54 Restrict(&platform.Rule{
55 Name: "docs-only",
56 Allow: []string{"docs/**"},
57 MaxRisk: platform.RiskRead,
58 }).
59 Build()
60 caps := p.Capabilities()
61 fmt.Println(caps.Restricts, caps.FailurePolicy == platform.FailClosed)
62 // Output: true true
63}

Callers

nothing calls this directly

Calls 4

NewPluginFunction · 0.92
BuildMethod · 0.65
RestrictMethod · 0.65
CapabilitiesMethod · 0.65

Tested by

no test coverage detected