mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
cb54e9c14f
❗ We now parse rego metadata annotations by default. Rule annotations now support a `labels` field. During policy eval, labels from all successfully evaluated rules are collected and included in each decision log entry as a top-level `rule_labels` array. Each element preserves the label map from one evaluated rule. Exact duplicates are omitted. ```rego # METADATA # labels: # severity: low # team: platform allow if input.role == "admin" ``` The resulting decision log entry will contain: ```json {"rule_labels": [{"severity": "low", "team": "platform"}]} ``` --------- Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
// Copyright 2017 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package server
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/open-policy-agent/opa/v1/ast"
|
|
"github.com/open-policy-agent/opa/v1/logging"
|
|
"github.com/open-policy-agent/opa/v1/metrics"
|
|
"github.com/open-policy-agent/opa/v1/storage"
|
|
"github.com/open-policy-agent/opa/v1/topdown"
|
|
)
|
|
|
|
// Info contains information describing a policy decision.
|
|
type Info struct {
|
|
Txn storage.Transaction
|
|
Revision string // Deprecated: Use `Bundles` instead
|
|
Bundles map[string]BundleInfo
|
|
DecisionID string
|
|
BatchDecisionID string
|
|
TraceID string
|
|
SpanID string
|
|
RemoteAddr string
|
|
HTTPRequestContext logging.HTTPRequestContext
|
|
Query string
|
|
Path string
|
|
Timestamp time.Time
|
|
Input *any
|
|
InputAST ast.Value
|
|
Results *any
|
|
IntermediateResults map[string]any
|
|
MappedResults *any
|
|
NDBuiltinCache *any
|
|
Error error
|
|
Metrics metrics.Metrics
|
|
Trace []*topdown.Event
|
|
RequestID uint64
|
|
EvaluatedRuleLabels []map[string]any
|
|
Custom map[string]any
|
|
}
|
|
|
|
// BundleInfo contains information describing a bundle.
|
|
type BundleInfo struct {
|
|
Revision string
|
|
}
|