applyMetricsViewSpecSecurity rewrites a metrics view spec based on the field access conditions of a security policy.
(spec *runtimev1.MetricsViewSpec, security *ResolvedSecurity)
| 251 | |
| 252 | // applyMetricsViewSpecSecurity rewrites a metrics view spec based on the field access conditions of a security policy. |
| 253 | func (r *Runtime) applyMetricsViewSpecSecurity(spec *runtimev1.MetricsViewSpec, security *ResolvedSecurity) ([]*runtimev1.MetricsViewSpec_Dimension, []*runtimev1.MetricsViewSpec_Measure, bool) { |
| 254 | if spec == nil { |
| 255 | return nil, nil, false |
| 256 | } |
| 257 | |
| 258 | var dims []*runtimev1.MetricsViewSpec_Dimension |
| 259 | for _, dim := range spec.Dimensions { |
| 260 | if security.CanAccessField(dim.Name) { |
| 261 | dims = append(dims, dim) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | var ms []*runtimev1.MetricsViewSpec_Measure |
| 266 | for _, m := range spec.Measures { |
| 267 | if security.CanAccessField(m.Name) { |
| 268 | ms = append(ms, m) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | if len(dims) == len(spec.Dimensions) && len(ms) == len(spec.Measures) { |
| 273 | return nil, nil, false |
| 274 | } |
| 275 | |
| 276 | return dims, ms, true |
| 277 | } |
| 278 | |
| 279 | // applyExploreSecurity rewrites an explore based on the field access conditions of a security policy. |
| 280 | func (r *Runtime) applyExploreSecurity(res *runtimev1.Resource, security *ResolvedSecurity) *runtimev1.Resource { |
no test coverage detected