Skip to content

Commit

Permalink
[access_graph] add usage events for Crown Jewel's create and AccessPa…
Browse files Browse the repository at this point in the history
…thChanged events (#46642)

* 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>

* [access_graph] add usage events for Crown Jewel's create and AccessPathChanged events

This PR adds the necessary usage event to track crown jewels diffs.

Part of gravitational/access-graph#1193

Requires #46641

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

* add webui event

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
  • Loading branch information
tigrato authored Sep 20, 2024
1 parent 9cba268 commit 0e72c00
Show file tree
Hide file tree
Showing 11 changed files with 2,397 additions and 1,359 deletions.
966 changes: 645 additions & 321 deletions api/gen/proto/go/usageevents/v1/usageevents.pb.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions api/proto/teleport/usageevents/v1/usageevents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ message AccessGraphAWSScanEvent {
uint64 total_accounts = 11;
}

// UIAccessGraphCrownJewelDiffViewEvent is emitted when a user reviews the output of a Crown Jewel access path dff.
message UIAccessGraphCrownJewelDiffViewEvent {
// affected_resource_source is the source of the affected resource.
string affected_resource_source = 1;
// affected_resource_type is the type of the affected resource.
string affected_resource_type = 2;
}

// SecurityReportGetResultEvent is emitted when the user requests a security report.
message SecurityReportGetResultEvent {
// name is the name of the security report.
Expand Down Expand Up @@ -775,6 +783,7 @@ message UsageEventOneOf {
UIDiscoverKubeEKSEnrollEvent ui_discover_kube_eks_enroll_event = 56;
UIDiscoverCreateAppServerEvent ui_discover_create_app_server_event = 57;
AccessGraphAWSScanEvent access_graph_aws_scan_event = 58;
UIAccessGraphCrownJewelDiffViewEvent ui_access_graph_crown_jewel_diff_view = 59;
}
reserved 2; //UIOnboardGetStartedClickEvent
reserved "ui_onboard_get_started_click";
Expand Down
2,363 changes: 1,326 additions & 1,037 deletions gen/proto/go/prehog/v1alpha/teleport.pb.go

Large diffs are not rendered by default.

232 changes: 231 additions & 1 deletion gen/proto/ts/prehog/v1alpha/teleport_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/usagereporter/teleport/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ func ConvertAuditEvent(event apievents.AuditEvent) Anonymizable {
out.NumTablesPermissions += entry.Counts[databaseobjectimportrule.ObjectKindTable]
}
return out
case *apievents.AccessPathChanged:
return &AccessGraphAccessPathChangedEvent{
AffectedResourceType: e.AffectedResourceType,
AffectedResourceSource: e.AffectedResourceSource,
}
case *apievents.CrownJewelCreate:
return &AccessGraphCrownJewelCreateEvent{}
}

return nil
Expand Down
30 changes: 30 additions & 0 deletions lib/usagereporter/teleport/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,36 @@ func TestConvertAuditEvent(t *testing.T) {
},
},
},
{
desc: "AccessPathChanged",
event: &apievents.AccessPathChanged{
AffectedResourceName: "some-resource",
AffectedResourceType: "ssh",
AffectedResourceSource: "TELEPORT",
},
expected: &AccessGraphAccessPathChangedEvent{
AffectedResourceType: "ssh",
AffectedResourceSource: "TELEPORT",
},
expectedAnonymized: &prehogv1a.SubmitEventRequest{
Event: &prehogv1a.SubmitEventRequest_AccessGraphAccessPathChanged{
AccessGraphAccessPathChanged: &prehogv1a.AccessGraphAccessPathChangedEvent{
AffectedResourceType: "ssh",
AffectedResourceSource: "teleport",
},
},
},
},
{
desc: "CrownJewelCreateEvent",
event: &apievents.CrownJewelCreate{},
expected: &AccessGraphCrownJewelCreateEvent{},
expectedAnonymized: &prehogv1a.SubmitEventRequest{
Event: &prehogv1a.SubmitEventRequest_AccessGraphCrownJewelCreate{
AccessGraphCrownJewelCreate: &prehogv1a.AccessGraphCrownJewelCreateEvent{},
},
},
},
}

for _, tt := range cases {
Expand Down
Loading

0 comments on commit 0e72c00

Please sign in to comment.