@@ -66,12 +66,14 @@ type PolicyVerifier struct {
6666 logger * zerolog.Logger
6767 client v13.AttestationServiceClient
6868 allowedHostnames []string
69+ includeRawData bool
6970}
7071
7172var _ Verifier = (* PolicyVerifier )(nil )
7273
7374type PolicyVerifierOptions struct {
7475 AllowedHostnames []string
76+ IncludeRawData bool
7577}
7678
7779type PolicyVerifierOption func (* PolicyVerifierOptions )
@@ -82,13 +84,25 @@ func WithAllowedHostnames(hostnames ...string) PolicyVerifierOption {
8284 }
8385}
8486
87+ func WithIncludeRawData (include bool ) PolicyVerifierOption {
88+ return func (o * PolicyVerifierOptions ) {
89+ o .IncludeRawData = include
90+ }
91+ }
92+
8593func NewPolicyVerifier (schema * v1.CraftingSchema , client v13.AttestationServiceClient , logger * zerolog.Logger , opts ... PolicyVerifierOption ) * PolicyVerifier {
8694 options := & PolicyVerifierOptions {}
8795 for _ , opt := range opts {
8896 opt (options )
8997 }
9098
91- return & PolicyVerifier {schema : schema , client : client , logger : logger , allowedHostnames : options .AllowedHostnames }
99+ return & PolicyVerifier {
100+ schema : schema ,
101+ client : client ,
102+ logger : logger ,
103+ allowedHostnames : options .AllowedHostnames ,
104+ includeRawData : options .IncludeRawData ,
105+ }
92106}
93107
94108// VerifyMaterial applies all required policies to a material
@@ -175,7 +189,9 @@ func (pv *PolicyVerifier) evaluatePolicyAttachment(ctx context.Context, attachme
175189 return nil , NewPolicyError (err )
176190 }
177191
178- rawResults = append (rawResults , r .RawData )
192+ if r .RawData != nil {
193+ rawResults = append (rawResults , r .RawData )
194+ }
179195
180196 // Skip if the script explicitly instructs us to ignore it, effectively preventing it from being added to the evaluation results
181197 if r .Ignore {
@@ -330,6 +346,10 @@ func (pv *PolicyVerifier) executeScript(ctx context.Context, script *engine.Poli
330346 engineOpts = append (engineOpts , rego .WithAllowedNetworkDomains (pv .allowedHostnames ... ))
331347 }
332348
349+ if pv .includeRawData {
350+ engineOpts = append (engineOpts , rego .WithIncludeRawData (true ))
351+ }
352+
333353 // verify the policy
334354 ng := rego .NewEngine (engineOpts ... )
335355 res , err := ng .Verify (ctx , script , material , getInputArguments (args ))
@@ -668,6 +688,9 @@ func LogPolicyEvaluations(evaluations []*v12.PolicyEvaluation, logger *zerolog.L
668688func engineRawResultsToAPIRawResults (rawResults []* engine.RawData ) []* structpb.Struct {
669689 res := make ([]* structpb.Struct , 0 )
670690 for _ , r := range rawResults {
691+ if r == nil {
692+ continue
693+ }
671694 // Convert RawData to map
672695 m := map [string ]interface {}{
673696 "input" : r .Input ,
0 commit comments