moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

Open moelasmar opened 1 month ago

moelasmar commented 1 month 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 1 month ago

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

moelasmar commented 1 month 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%2324/moelasmar/CodeQlDemoEcsIssue%2324_results.zip?AWSAccessKeyId=ASIAQUFLP7FHUY7S4JL4&Signature=vkOopB%2B193zhI%2FO1oZTBoKF%2FyVA%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCICkJKqZQ1ShWseZPJHMLJAPlnwOWvZH8AjwSAU0mSNi7AiEAxdm22M7g%2BQ4f%2FDo8SjRXc0rKMAG11x58xyfwZ25JSvQq5AQI%2BP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDPULXu5tOEfK5hwlkSq4BIGcafE2t%2B3opS8bsxlWxteAca5n1eT9XpiVXBee%2FIp7bKdcYPFlum1x%2ByUNwz7LgFHyNE9WFKsGstvQcM01jMQ4RhOr4MwadbufUcKautbH3ACM%2BFkM6%2BzUcwJVOHyD6TPKJmBAcn36BOGY1X4uEnKCNSC7wyUVJJ2Fb4fTNXY5Qv67gVY47Mbk5BKNA%2FMNeIm%2FvSlXY1jZigquez8XWgMFJfTI7970%2FjvO2oHgk4I0Rsgeefz0pI5NvwMLnSqbVrqU85cVXnqWlQpr%2FyDVNC0a9LhACBzCbuJX05u0ZsptxB4DfNpC68AyF%2FKlDUP07bWq8Z1cL8sEGebQYuO86piqu%2BXQsPSxJy30TSi6TCq9SbFsnu%2FYsMk7%2FbtSxtQlaKg0O3G%2BP8yJyuw9Jd4pvTav47s6hDi9Gk9hgPp2xqSeYsFvKmLp5b9Dm801UdIybqoi7jYpAxMK8sPCnqVqtv8cDB4lYa9yUJ77xD7NRIUvN8ZPY8olVqO6N0AyMwKkJYZ8Rg0jazHDXHTfuU%2B2jv6mD1LAeViiAlpmZSxJZzrVKgbjJTNuK6LLVS1NrW1%2BZeVUuFwTLFx1GIqtWGprKz7Eu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