moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

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%2323/moelasmar/CodeQlDemoEcsIssue%2323_results.zip?AWSAccessKeyId=ASIAQUFLP7FHTO2O5WXN&Signature=%2B3NBX7R%2FQyo57IdeETbXbhEja3A%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJGMEQCID3glAgJH%2BllAFi0w8rhCAvj%2FyJa5cLkdFHAvTONymEHAiAT9RVuSfJvr3hOcZskURPjghfxJX5k5voPZD50K14lPyrkBAj3%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAAaDDA0MzMwOTMzMjgxNSIM1wsYiXqwOxFu%2F2IrKrgEcKp7YLyqfdWA5pVLyIu%2BL8vUplBKjojDmFYIW%2Bf0pNAMr%2BBM7rRz6lMLLDTGvxdRPv2v3niO8ohhc4psvdNPccIjt1zOb3paxHO5w8vP6CbOeIEjg0ukOK7MaYAuxsXIYgcz%2FmOnPWIA%2FhDn0VpczugBW576nMjMIvaaSddyNi9BacU61WRKfDeLFa1sZCmqBStlIuwrmw6ztjQetJNX45xglGoWJunzXLdAr7qg0EDGQHWb3ltU9Ah%2FT5f28Nt1UAIUTxv%2BpGMDoJSmqZEY9Dsnqf97ddDM%2FFMqUlRRxpABWioz9pKXmTaKn74iZFJcMSf4PqnkCLPdCxfc4ZYNy2VzjjblgOy9P%2B2AQ2RErpBnk74glyf9w52AHOWAxMh1l1krXtzieRsyrjdOWMR18uGrEEp1roogImI2FQIme%2FPCYllZYHqqoMDcfSjGQGAvIkMh2hF3%2B0IqTzUHVDUsK89kbvilHDYgBokdba3MG%2BCtbFaXKTMFDUNHwuKJJF%2BTUbEUrqC9tHR1nksIqgtGGPnoCO%2FJl5debp9GgTgTFpsVrxI6kJCt9x8X7H9ggrnB65r9joUQb1UASAQmgbUPWp%2BEYO4aVMURLENvw7jZN11%2FEi1brZTsctnPK0FaVejLzHktVJuSOf0mmOQDP%2BEzaa5t2rkpO7s8YLXjBYBYzlokb3KCl%2Fb09Qz83oOtKxO4L2bCf%2F4wXKIe4ftMTzidG0dfpdyPn2WmI79cKHN0TfxQHIXHMz0%2F8jDM0dK%2BBjqoAa%2FX61KLk6Qym28rGBdkt8piRiFIUMsQCrfosvBv5LX2tv8JHitpoRD3ndJ9xU0zOWByRi0DTf2KNdj5seWbFKfy%2FpngOPkkPgVNJMyxN4J9cFBiXUheZvD%2BoQkaohENouJKKK%2B03pb73y5JB1AIKe6ikP%2BbeYSbOWe3tS5L374p64EFLXcf7xn10sueUQ0vHjtzI6jHi65CSgLoyQpfS1RD9WVH07WwjA%3D%3D&Expires=1742595116)

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