Skip to content

Commit

Permalink
Add audit events to Crown Jewel methods (#46641)
Browse files Browse the repository at this point in the history
* Add audit events to Crown Jewel methods

This PR adds the audit events for the crown jewel functionatlity.

Part of gravitational/access-graph#1193

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* fix lint

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
  • Loading branch information
tigrato committed Sep 20, 2024
1 parent 429d594 commit 2232241
Show file tree
Hide file tree
Showing 14 changed files with 5,308 additions and 3,482 deletions.
126 changes: 126 additions & 0 deletions api/proto/teleport/legacy/types/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4598,6 +4598,9 @@ message OneOf {
events.StaticHostUserCreate StaticHostUserCreate = 179;
events.StaticHostUserUpdate StaticHostUserUpdate = 180;
events.StaticHostUserDelete StaticHostUserDelete = 181;
events.CrownJewelCreate CrownJewelCreate = 182;
events.CrownJewelUpdate CrownJewelUpdate = 183;
events.CrownJewelDelete CrownJewelDelete = 184;
}
}

Expand Down Expand Up @@ -7169,3 +7172,126 @@ message StaticHostUserDelete {
(gogoproto.jsontag) = ""
];
}

// CrownJewelCreate is emitted when a Access Graph CrownJewel is created.
message CrownJewelCreate {
// Metadata is a common event metadata
Metadata Metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// Status indicates whether the update was successful.
Status Status = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata
UserMetadata User = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection
ConnectionMetadata Connection = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// CrownJewelQuery is the query used to track the crown jewel.
string CrownJewelQuery = 6 [(gogoproto.jsontag) = "crown_jewel_query"];
}

// CrownJewelUpdate is emitted when a Access Graph CrownJewel is updated.
message CrownJewelUpdate {
// Metadata is a common event metadata
Metadata Metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// Status indicates whether the update was successful.
Status Status = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata
UserMetadata User = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection
ConnectionMetadata Connection = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// CurrentCrownJewelQuery is the current query used to track the crown jewel.
string CurrentCrownJewelQuery = 6 [(gogoproto.jsontag) = "current_crown_jewel_query"];

// UpdatedCrownJewelQuery is the new query used to track the crown jewel.
string UpdatedCrownJewelQuery = 7 [(gogoproto.jsontag) = "updated_crown_jewel_query"];
}

// CrownJewelDelete is emitted when a Access Graph CrownJewel is deleted.
message CrownJewelDelete {
// Metadata is a common event metadata
Metadata Metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// Status indicates whether the update was successful.
Status Status = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata
UserMetadata User = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection
ConnectionMetadata Connection = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];
}
12 changes: 12 additions & 0 deletions api/types/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,15 @@ func computeEventID(evt AuditEvent, payload []byte) string {
hash := sha256.Sum256(payload)
return hex.EncodeToString(hash[:])
}

func (m *CrownJewelCreate) TrimToMaxSize(_ int) AuditEvent {
return m
}

func (m *CrownJewelUpdate) TrimToMaxSize(_ int) AuditEvent {
return m
}

func (m *CrownJewelDelete) TrimToMaxSize(_ int) AuditEvent {
return m
}
Loading

0 comments on commit 2232241

Please sign in to comment.