Skip to content

Commit

Permalink
Remove old attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet committed Jan 6, 2025
1 parent beb546e commit 6337713
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 101 deletions.
25 changes: 0 additions & 25 deletions lib/tbot/spiffe/workloadattest/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,6 @@ import (
workloadidentityv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/workloadidentity/v1"
)

// Attestation holds the results of the attestation process carried out on a
// PID by the attestor.
//
// The zero value of this type indicates that no attestation was performed or
// was successful.
type Attestation struct {
Unix UnixAttestation
Kubernetes KubernetesAttestation
}

// LogValue implements slog.LogValue to provide a nicely formatted set of
// log keys for a given attestation.
func (a Attestation) LogValue() slog.Value {
return slog.GroupValue(
slog.Attr{
Key: "unix",
Value: a.Unix.LogValue(),
},
slog.Attr{
Key: "kubernetes",
Value: a.Kubernetes.LogValue(),
},
)
}

type attestor[T any] interface {
Attest(ctx context.Context, pid int) (T, error)
}
Expand Down
45 changes: 0 additions & 45 deletions lib/tbot/spiffe/workloadattest/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,9 @@
package workloadattest

import (
"log/slog"

"github.com/gravitational/trace"
)

// KubernetesAttestation holds the Kubernetes pod information retrieved from
// the workload attestation process.
type KubernetesAttestation struct {
// Attested is true if the PID was successfully attested to a Kubernetes
// pod. This indicates the validity of the rest of the fields.
Attested bool
// Namespace is the namespace of the pod.
Namespace string
// ServiceAccount is the service account of the pod.
ServiceAccount string
// PodName is the name of the pod.
PodName string
// PodUID is the UID of the pod.
PodUID string
// Labels is a map of labels on the pod.
Labels map[string]string
}

// LogValue implements slog.LogValue to provide a nicely formatted set of
// log keys for a given attestation.
func (a KubernetesAttestation) LogValue() slog.Value {
values := []slog.Attr{
slog.Bool("attested", a.Attested),
}
if a.Attested {
labels := []slog.Attr{}
for k, v := range a.Labels {
labels = append(labels, slog.String(k, v))
}
values = append(values,
slog.String("namespace", a.Namespace),
slog.String("service_account", a.ServiceAccount),
slog.String("pod_name", a.PodName),
slog.String("pod_uid", a.PodUID),
slog.Attr{
Key: "labels",
Value: slog.GroupValue(labels...),
},
)
}
return slog.GroupValue(values...)
}

// KubernetesAttestorConfig holds the configuration for the KubernetesAttestor.
type KubernetesAttestorConfig struct {
// Enabled is true if the KubernetesAttestor is enabled. If false,
Expand Down
31 changes: 0 additions & 31 deletions lib/tbot/spiffe/workloadattest/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,13 @@ package workloadattest

import (
"context"
"log/slog"

"github.com/gravitational/trace"
"github.com/shirou/gopsutil/v4/process"

workloadidentityv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/workloadidentity/v1"
)

// UnixAttestation holds the Unix process information retrieved from the
// workload attestation process.
type UnixAttestation struct {
// Attested is true if the PID was successfully attested to a Unix
// process. This indicates the validity of the rest of the fields.
Attested bool
// PID is the process ID of the attested process.
PID int
// UID is the primary user ID of the attested process.
UID int
// GID is the primary group ID of the attested process.
GID int
}

// LogValue implements slog.LogValue to provide a nicely formatted set of
// log keys for a given attestation.
func (a UnixAttestation) LogValue() slog.Value {
values := []slog.Attr{
slog.Bool("attested", a.Attested),
}
if a.Attested {
values = append(values,
slog.Int("uid", a.UID),
slog.Int("pid", a.PID),
slog.Int("gid", a.GID),
)
}
return slog.GroupValue(values...)
}

// UnixAttestor attests a process id to a Unix process.
type UnixAttestor struct {
}
Expand Down

0 comments on commit 6337713

Please sign in to comment.