2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-05-20 11:30:37 -04:00
|
|
|
package resources
|
|
|
|
|
|
|
|
import (
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
2022-05-20 11:30:37 -04:00
|
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
auditv1 "k8s.io/apiserver/pkg/apis/audit/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AuditPolicy defines rulesets for what should be logged in the kube-apiserver audit log.
|
|
|
|
// reference: https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/ .
|
|
|
|
type AuditPolicy struct {
|
|
|
|
Policy auditv1.Policy
|
|
|
|
}
|
|
|
|
|
2022-11-09 09:57:54 -05:00
|
|
|
// NewDefaultAuditPolicy create a new default Constellation audit policty.
|
2022-05-20 11:30:37 -04:00
|
|
|
func NewDefaultAuditPolicy() *AuditPolicy {
|
|
|
|
return &AuditPolicy{
|
|
|
|
Policy: auditv1.Policy{
|
|
|
|
TypeMeta: v1.TypeMeta{
|
|
|
|
APIVersion: "audit.k8s.io/v1",
|
|
|
|
Kind: "Policy",
|
|
|
|
},
|
|
|
|
Rules: []auditv1.PolicyRule{
|
|
|
|
{
|
|
|
|
Level: auditv1.LevelMetadata,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Marshal marshals the audit policy as a YAML document.
|
|
|
|
func (p *AuditPolicy) Marshal() ([]byte, error) {
|
2022-08-29 08:30:20 -04:00
|
|
|
return kubernetes.MarshalK8SResources(p)
|
2022-05-20 11:30:37 -04:00
|
|
|
}
|