moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

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%2326/moelasmar/CodeQlDemoEcsIssue%2326_results.zip?AWSAccessKeyId=ASIAQUFLP7FHS5PTFASZ&Signature=ATEJJ9behZUR%2F5VQGju2A700ehY%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIEuM8NZBYko59cx3%2B35nyTId8YQdLZAibY2r50JKVb6bAiEA4fHaU%2F8CCH3w61USn1olwKeaZgz%2BrAxgtnoRGEFXxSwq5AQI9%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDOQ3%2B6GKMP3NIP393Sq4BLss71ZvDmMaRQus1t2%2Bwa6v7X5vEop4cHuQoNXswFzqrwXwxj%2FEIYRswZ2rcy6KiLXcR%2BRMWrR%2FgAw17xVt3Ohk%2FuLbE32SZkqdNaoH4O1a7YM8F9HkW0aENAOLmIpFfbuHRvt2%2B9vN1zRtV5pNvFR3FkX16MM2mQ%2FNbwc%2F2kjYAU37lyPiQmEg72z0qpqfe707Bx6loKBLsG08nTHzfjx36tMlg2gqQUL0p4n5Wm8YktEtf76PrQD6AG0Aqm%2BYmiRTEq%2FB6GZ5qLBkESP9w8GPWGyOdbmg5b5ef0Q5TeCj2ZaYFxYYkOLC0tZBg2rzijzujCUMVuAJrbUs%2FzpbC3rmdLtrzpdqKMuJEDlJm7nFP8405n1txHGv5OpXnr4bpYcYHtz1enDuJENiJo3qTrGLQlxTKf399cx3NEOfE5Dn73sQb4oplP0K9r9Kr6fNunzCWWd13BT815VWUiypEaNFEK8g9cy5%2BEOAllj7PRczu2HlqrCzxeY9ow%2BgVIuicyKoAouJ1eg%2Fbuz3hXU3bcCeHt4Hypv%2BTqlDccGKGveG1EHqp%2FP%2F%2B66AlHO2b3GgXSIhWHvvq3ogpYZemtMXr82FTdW9Y8aPnQpa8Jj%2BFjMNeNyL8Ey1j3jASeGcFH5VW%2FL6m3qg7kECjgsX0SHmylsCp1Jfk9DtQ9zFJTmlILB082VdSfDzDXbuSMupKfY46kcV5NKaTPKCtJG7lGZKcAFcGuxYmSa6pLbas0azolAekJg8OxdfNY4wwNXSvgY6pwFNmpXoFyOQwlP9u%2B150jg3gtbFKewIaN6PAOiHqWBz9n%2BpzkaAzyZQxeKNUlDJckG3KpH48s68NpUZjDPSvDqi357mh6Kkxhq08FrNZbif0vkXCu%2FOwILNspozmLQqqPNvzElRSH5KLaivuuBkxRDdZykGG2Fw2MYnziA93wD1X3%2FTdtuXcr4sxOZQQWOgKhLGD0O7pwXT5eoPuMtSmCEeroNz5cYBHw%3D%3D&Expires=1742595544)

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