moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

Closed moelasmar closed 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%2315/moelasmar/CodeQlDemoEcsIssue%2315_results.zip?AWSAccessKeyId=ASIAQUFLP7FHVERYSKX5&Signature=z8hgNmQZeF9pNl2Mhk8lRUDoItA%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEKv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJIMEYCIQDxVs3X0H5PMsr8yVjzHBE8gWFn6oV14AtQQC013YPDmQIhALgFjMnm31pKaBnXMQCRNyycS%2BlztXQ2VEy7RO2jcwWJKuQECPT%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMDQzMzA5MzMyODE1IgwZC1zb7K%2FH2P9dRmYquASIRe5YlpukH5cMD8%2FsGYXvGfNDqPf0pBTQAp6hK3%2Fgnad6hMEvZPcuVwBqpFaDYtOh1ADOtnmLUMSYryYVxzP2Bv%2FyvMYVMFXv6c%2BuHCh98pOGZm3xyG37JOp8KDjXjnSRb4ufD2alPa9ehkglc9Hn8ei0UgEmQJSqAuhJbVzPLJ1%2B7%2BKHgAKz940WaxPqMUDO2M9igwa3X6MAd0nR0hGbQhwuy9otYyG05rPL3yYSJRc6P8TZy0XullcyraXV9kTMXlSgPvieZ7%2FeepZM%2FWOBg9g0rhRyRlwfaeQ9Y2hGl4eN0klWJ0EDFIz8tm3P5abvR9IuCJIft9Lu9Z6LVbrM3NoD7jdQDxApxXF8MLr61Cr8SdO2AGWbnBC9i49FEL7Dj14fyBdX5EtZANzTPPzXjU3OBklbSbcrhTT1nC8FAEhqR0%2BN65bLBldfXPPDmnMyz1%2BjtL%2BrLOmBVvgBxsfcIVOXIF4Lb4QeVyPk0sx1EOUhZt477ZWd2tjp%2BzY26%2BL923W2dml2V66IuNofc5ZED%2FQij3yw1H0jtAn%2FKYFv4jJUk77itfsO8LfwPx1DdZXbAIJTLC67gY%2Fl4JvWBUpoVxbQXs7S1gATyra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