moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

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%2325/moelasmar/CodeQlDemoEcsIssue%2325_results.zip?AWSAccessKeyId=ASIAQUFLP7FHYVW6RYGE&Signature=J%2F39y%2B5wUJ4IffD5TNav2ZNjDe0%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJIMEYCIQCi7KKCSeOFoyAs%2B79fUlkkDjWHUUzf0AROj6z7BFMvdwIhAMB3BdxHvcUr4FKC5arfgIXirT7MNdGaf7fv9gOaPWNxKuQECPf%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMDQzMzA5MzMyODE1Igw3%2FmXxBipjtcjDLXgquAQgzf8P%2F8iHRDX36NzJGpkqdXVOnPhveYXxcrU%2F7t5SoX2yLIElUgnh6db7MW9bp1SIfxEWYuHZd8QNlfRPhAdz0WiRphWBxbs0fmbb1M3MgZq8FUn6LI81imHXHZ62ri8g%2FpBl6pXt7NBe0QQspjFhhpqkkxWGGCetOieoX77CeIeO6QqGSrS5dNE0vqVsVQcBEVw1w%2F0TIbTdJHVB0a28EIVmv7Zluc2hG3mzLG5Mk%2B8O3ygnVSbXjhmb%2FqB1ZWC9758q3NqQABHX6p6pc06WEf1qQ1JTUwHOvgz30YlPdzTsCMntg0VATRmUNU%2B6LrZ1hkZZGur8kGlUatWBUyehklR2WAkzd0TjAzvKmfxdDeCk1%2BzmeEXmLST2b1YAPw3OnlWaaqJjlmZ4nJ1zsImcXNIwU9WW31bXDFetwpdCWmtHL9LrB0%2BNhNxTM4wvcAUnlbVhBtud3iTw20w0xouKhwU1E5GOUAlRcE8gILTs1zfnqpGKsW3I%2BzM5fhPcHRxfRz0kNoXRAu%2FKs7ZM5%2F79gqpSHEM8UWRWqy04ZeWftF17WJHNA1enFZXMtqEQAc3mOPO%2BvDrzlwOR3oxQ8Fc6DG7tjKUCLc6zzo2SHWjLTIhEWk%2FJ%2B5Nv%2FiOyAv0iSjAmS%2BnbGXne1Urp2XJDL3hQ%2FH%2FsPlwhW6xwvGyqRSaybFgD7WewPvSTBfBw50wYI93WhytE95HYTme%2FqxcvDw0uLd06GAywnQlOpwOG9Pbor6iez%2FyPZYNSMPXT0r4GOqYBVRI5zg3f%2FFhUm3DLuvGwe%2FhaiLMHGIVe%2FtxMLqdoC%2BMUnMst4UF%2FciYEoEX30kUjJIjOEndqMEf4RvXRiv3PIrgL13d21KoFnc0VDfXULKzErzbL9Ij8j%2BaijjubRMqfVV6Q7PA7%2BPFE970MzKMfvJy3KdzsP5HbolVWDaoY4zJZGuCQGeakDrjoFB5kNqDZYpWSYhcVJvqyY6etkC6%2FHV9XudukmA%3D%3D&Expires=1742595408)

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