moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

aws-events: Cannot grant `putEvents` to Service Principals #21

Open moelasmar opened 2 months ago

moelasmar commented 2 months ago

Original issue by @arcrank on 2022-09-16T15:44:27Z

Describe the bug

When trying to grantPutEventsTo an AWS SP, there is a no-op, and no warnings or errors. I would expect if we added a grant to a iam.ServicePrincipal that the underlying grant/policy would be created. We can add an SP to the event bus in the console. Tracing back code I myself didn't necessary find a place where this would have failed, or I would have expected if this was not possible to give a failure message.

Expected Behavior

I would expect the template to have grant policies attached. If for some reason you weren't allowed to add SPs, I would expect a failure message and error.

Current Behavior

Nothing is logged to the terminal when synthing the template snippet is

 "Resources": {
  "bus707364D1": {
   "Type": "AWS::Events::EventBus",
   "Properties": {
    "Name": "MyCustomEventBus"
   },
   "Metadata": {
    "aws:cdk:path": "xxx/bus/Resource"
   }
  },
  "busMyArchiveF1010141": {
   "Type": "AWS::Events::Archive",
   "Properties": {
    "SourceArn": {
     "Fn::GetAtt": [
      "bus707364D1",
      "Arn"
     ]
    },
    "ArchiveName": "MyCustomEventBusArchive",
    "Description": "MyCustomerEventBus Archive",
    "EventPattern": {
     "account": [
      "264988854622"
     ]
    },
    "RetentionDays": 365
   },

Reproduction Steps

    const bus = new events.EventBus(this, 'bus', {
      eventBusName: 'MyCustomEventBus'
    });

    bus.archive('MyArchive', {
      archiveName: 'MyCustomEventBusArchive',
      description: 'MyCustomerEventBus Archive',
      eventPattern: {
        account: [cdk.Stack.of(this).account],
      },
      retention: cdk.Duration.days(365),
    });

    bus.grantPutEventsTo(new iam.ServicePrincipal('lambda.amazonaws.com'));

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.23.0

Framework Version

No response

Node.js Version

14

OS

MacOs/Linux

Language

Typescript

Language Version

No response

Other information

No response

moelasmar commented 2 months ago

This issue has been queued for processing by our automated system.

moelasmar commented 2 months ago
    ## Issue Processing Complete

    This issue has been processed successfully.

    You can view the processing results here: [Results](https://cdkgithubbugreproducersta-githubissueresultsbucket-anxrgpotfplp.s3.amazonaws.com/moelasmar/CodeQlDemoEcsIssue%2321/moelasmar/CodeQlDemoEcsIssue%2321_results.zip?AWSAccessKeyId=ASIAQUFLP7FH2JD36SP4&Signature=h6tNw4R2ng68m0ymI5MlwdU6Ojg%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIGohvP5v%2Fez8vYj0Ipg9MRWrfDv1z0PIsI%2Fe3O5SVt0lAiEAoYIDEJru%2BfNCRj3G8%2BueaxwD6jXWA74kUO2a7taQuIkq5AQI9%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDJwgfv9p3P8A8vISYiq4BC%2Bp0DIrYfoYTYhZEKQr2Zu%2FattfdBFX5HDKYtVL5Yv8OlWtQYgJg%2F7h4sB3l9ahvMUJhIAxHqY91vOlQYK2Ze3bT5d7mOmXPIZBmL8PtiKQDpOgdZ8E9iZRxTr%2F%2BFIsfBrGXcVEDWlcB6GHb1LakV5CXRuPvmWnq8F2nS7Jl3obSjkj8iAdrf8PikCNKscenh5gPOISemQgsDxpwZp0gFcmiUq0ggehWjMW%2Fc7ze4CgPOjgBPyg2tou4XKWjIPIbE0s2IhFR1zrZBgKabKNy9KDYl7mT2ljxtAl99rX%2B8pnXx7T%2BFMntTdDptH8KRYszWJhI0nJSLtLU2bA8zyORoItD4I0A%2FlDllqoD8ZSrBQd65egeTxdVIgnco5V%2BBFa1mmOTcs%2BNYoiStbnJYgWvlNPgp3G7Wg%2Fc7tI2An%2BQxS87MQRAqiPNWiPe3EeOhvg9hPROr9eMY6LF%2FuzkHQJw1ojU0Js83NeDv%2BbtcL75ex27a0lqRAvDcsgQ3AEDF1MiUFNpX5ZKbBsoVqxmNRjovcUohrjW9ZKdWUZj89xfH9WzKjJTGnfhtv2s7mjbR7Pwn5kyOpv6jqVUbSX83WTqjz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