moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

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%2317/moelasmar/CodeQlDemoEcsIssue%2317_results.zip?AWSAccessKeyId=ASIAQUFLP7FHSLYC3YQW&Signature=GGoyoNgXTMhUX88aq%2Fug6ceuEvg%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK3%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIAg7tLBY%2BO1%2BGI39L0ngqNdEF2IzlcM0qAcbyCOGytQ2AiEA40PloY9LK67JHT6BMTBsWL06DrCFU9nvLsiEYLhBHuYq5AQI9v%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDC3k1iqPIzr%2Bq1A4rCq4BNerCX7B14qg%2Bg3fVPbAhVSjP11UaHlv6dBmcZCdoOlTPMEEERt%2BnlGrIZSkGQ%2Fw61kOTVhm6AnFk8sLIsmggdWrxEyVDhHjHZIRSGfznGciTppBAfpT2uW64uJFDBqCak5gCWswPZrI0bIYW0m8STq1okPFAVhyzlfqa7VnDReU6XhptXYsRJdfX6cgv1dSEBSTIxCVSqFeeUVmPUlt19Q2YIiDSF%2Bo%2FS0%2FgAQ4LP0rPnvf%2BVkVuL2s%2FMasOPgKZcBZ7gUgq1b5lbxAys%2Bh9T0CsVwAxQN5mz4jyZ4FXyg9oTBtpXUzOjvaqm23IRIqfJTDlNMTjag7ILe7qNVhYQQeE%2BvLtNhIQT97PuaJx%2FU7azUsnBQhTh9hvIV00icTc2YtASPak38aYNVsOAT28f9MzKzek2wQ0m%2BPyqtBSb5ANUfuHU6qPNsO2Aski9bREEjV0rbZFzkt%2Fl50xMyOrVEBBVY7f7fZxVcxcZh9LMe0zXhpWSeejjCrnEUdg0lTrzrl71B2cFJtWts5ueL5fJtSUqNGYWWW%2BKu1L2s%2FTEoY%2BSQiPPOcRDxSuoAxZGNF7iPDpzJq0%2BObbo%2Ba3hfdJ6U%2BHow87rayEcTXMxSpDiZiY3KVBegiawt6WA4z9CeLIpOG%2FATVaO0%2BZycxMzphEeMteOHjZPH0Etf1ijxis3Wb0h06TfVlZBJARmUcyXFB9PykVFkhA18lUvFnHXpvsd3CHK6bdhKEPRaeKBwXeMWB3yXhvwVGuwAwgaTSvgY6pwHYMKHKfyd90uwci97SpkBqD34L9UxgEIhug2nEfY0wLnbVv%2BRIyE4mCiGOe7JLUyoSU82WYNl329rvLIB8ch7JSRhb%2BDwVpCdwk86ZUdBdhTIQiZzhrTODprvdZay3UPazJBtZr0zy2mj334NgqzpmglmqLv%2FG%2BF%2FCRLdVMdpm4u8HB1VKNCusd%2BkLI6VRclMDD9nkL8OXlpVfEpJf20LbaXQ87GKs%2BA%3D%3D&Expires=1742589334)

    *This is an automated message from the GitHub Issue Processor.*