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{})
| 101 | // into input.chainloop_metadata. Existing keys (e.g. the intoto descriptor |
| 102 | // populated by Attestation_Material.GetEvaluableContent) are preserved. |
| 103 | func (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 | |
| 126 | func (r *Engine) Verify(ctx context.Context, policy *engine.Policy, input []byte, args map[string]any) (*engine.EvaluationResult, error) { |
| 127 | policyString := string(policy.Source) |
no outgoing calls
no test coverage detected