Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report AWS operations with service identity #258

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 59 additions & 3 deletions src/mapper/pkg/graph/generated/generated.go

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

12 changes: 9 additions & 3 deletions src/mapper/pkg/graph/model/models_gen.go

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

39 changes: 24 additions & 15 deletions src/mapper/pkg/resolvers/schema.helpers.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,33 +248,42 @@ func (r *Resolver) handleDNSCaptureResultsAsExternalTraffic(_ context.Context, d
// ReportAWSOperation is the resolver for the reportAWSOperation field.
func (r *Resolver) handleAWSOperationReport(ctx context.Context, operation model.AWSOperationResults) error {
for _, op := range operation {
logrus.Debugf("Received AWS operation: %+v", op)
srcPod, err := r.kubeFinder.ResolveIPToPod(ctx, op.SrcIP)
var serviceIdentity model.OtterizeServiceIdentity

if err != nil {
logrus.Errorf("could not resolve %s to pod: %s", op.SrcIP, err.Error())
continue
}
if op.Client != nil {
serviceIdentity.Name = op.Client.Name
serviceIdentity.Namespace = op.Client.Namespace
} else if op.SrcIP != nil {
srcPod, err := r.kubeFinder.ResolveIPToPod(ctx, *op.SrcIP)

serviceId, err := r.serviceIdResolver.ResolvePodToServiceIdentity(ctx, srcPod)
if err != nil {
logrus.Errorf("could not resolve IP %s to pod: %s", *op.SrcIP, err.Error())
continue
}

if err != nil {
logrus.Errorf("could not resolve pod %s to identity: %s", srcPod.Name, err.Error())
serviceId, err := r.serviceIdResolver.ResolvePodToServiceIdentity(ctx, srcPod)

if err != nil {
logrus.Errorf("could not resolve pod %s to identity: %s", srcPod.Name, err.Error())
continue
}

serviceIdentity.Name = serviceId.Name
serviceIdentity.Namespace = srcPod.Namespace
} else {
logrus.Error("Invalid AWS operation report: both srcIP and client are nil")
continue
}

r.awsIntentsHolder.AddIntent(awsintentsholder.AWSIntent{
Client: model.OtterizeServiceIdentity{
Name: serviceId.Name,
Namespace: srcPod.Namespace,
},
Client: serviceIdentity,
Actions: op.Actions,
ARN: op.Resource,
})

logrus.
WithField("client", serviceId.Name).
WithField("namespace", srcPod.Namespace).
WithField("clientName", serviceIdentity.Name).
WithField("clientNamespace", serviceIdentity.Namespace).
WithField("actions", op.Actions).
WithField("arn", op.Resource).
Debug("Discovered AWS intent")
Expand Down
23 changes: 19 additions & 4 deletions src/mapperclient/generated.go

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

8 changes: 7 additions & 1 deletion src/mappergraphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,16 @@ input IstioConnectionResults {
results: [IstioConnection!]!
}

input NamespacedName {
name: String!
namespace: String!
}

input AWSOperation {
resource: String!
actions: [String!]!
srcIp: String!
srcIp: String
client: NamespacedName
}

input ServerFilter {
Expand Down
Loading