MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / injectProjectMetadata

Method injectProjectMetadata

pkg/policies/engine/rego/rego.go:103–124  ·  view source on GitHub ↗

injectProjectMetadata merges the engine's project name / version (when set) into input.chainloop_metadata. Existing keys (e.g. the intoto descriptor populated by Attestation_Material.GetEvaluableContent) are preserved.

(inputMap map[string]interface{})

Source from the content-addressed store, hash-verified

101// into input.chainloop_metadata. Existing keys (e.g. the intoto descriptor
102// populated by Attestation_Material.GetEvaluableContent) are preserved.
103func (r *Engine) injectProjectMetadata(inputMap map[string]interface{}) map[string]interface{} {
104 if r.CommonEngineOptions == nil {
105 return inputMap
106 }
107 if r.ProjectName == "" && r.ProjectVersionName == "" {
108 return inputMap
109 }
110
111 cm, _ := inputMap[chainloopMetadataKey].(map[string]interface{})
112 if cm == nil {
113 cm = make(map[string]interface{})
114 }
115 if r.ProjectName != "" {
116 cm[chainloopProjectNameKey] = r.ProjectName
117 }
118 if r.ProjectVersionName != "" {
119 cm[chainloopProjectVersionNameKey] = r.ProjectVersionName
120 }
121 inputMap[chainloopMetadataKey] = cm
122
123 return inputMap
124}
125
126func (r *Engine) Verify(ctx context.Context, policy *engine.Policy, input []byte, args map[string]any) (*engine.EvaluationResult, error) {
127 policyString := string(policy.Source)

Callers 3

VerifyMethod · 0.95
MatchesParametersMethod · 0.95
MatchesEvaluationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected