moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

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%2320/moelasmar/CodeQlDemoEcsIssue%2320_results.zip?AWSAccessKeyId=ASIAQUFLP7FHWZGH5MXQ&Signature=yivDkq3nPbCMGA%2B7xSj87jqgwGs%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQDEW90eigz%2BwqTF8z6O%2FfPpHMHgmtcQ0q5H43NysqAWSQIgI0fWy%2Fcjh7IUPFsBj6ZMiYm4HX5VXm35g%2FPSm1qaQWkq5AQI9%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDCuGugkzGM8DKx6KtSq4BBRV1BkDJxlEKqUtaZAeP8HTYfzUw3joZGWtNO0mkTzPWGdqbkHmzthGu96yLjSVoliuscr3ls2gkg89IVVmBQ2%2BoL9tSDopcF6jUes6nDZmWyhfr1ToSR1zoKyovDpxci7GzwDi81IyXABfm2ByTS9vZdymP5AwNYahUVkEsHR0b1dYicKocwmNeE9kyZZ0Pn%2FpIllJ3wkZHRw8GnKAPicjmvhRUSetqxQEc7dAXGTdxt3pJw8ksdmlLtKiXqLeCQrZm7Ok3NB9pKabqu7ANVVMeDD%2BV5ivs%2F%2BPAS1jNHVtvqxontldeCq0sqW4mUB4Lg4ICha8EJRfoSogzWtf01VVllgULDrLLLIH2endye9Xnh6293pU7RGuDEmd2A70bAIfBNIJjQur9OPahBLdSIUdUrPBqMkO49xxxN8AWBhjDLM117qMyFK1By5wGF74vq63xqIcP5G4cNlXVCmI1ieJI%2FFnMZNlYhoSnusW53VzpQfO1bP5%2BbQfFFTOk0lQsEclEVIZs8XyECGMtSbTjqm3McXPwGconns0r6MZHpdmO%2FxQUM9qibCevDQtk1T0hL%2F%2FEP9bNslFjo26fLXdaa%2BlaZabCny3O68jWwrzc86u3wtvsjgqzKv0K9Q%2FHkH61WHmyfTryW5nRLgiU1Q0DbdZC2WN4pNm3%2FVsTqxot5XFTdbjsO%2B1On841LFz6iPyopHp4Or0IHxb0g%2F6cyLOG%2F6V%2Bwrs6%2FHrkrGew79ZHvaDYxDTXya4axcwjs%2FSvgY6pwGMPX4GPq8jrIApxOi2FeUNsVLoYFgSkRjyiYktZpVIK%2FwWimiTvG7HhgP1Kh7bSWTJyZESvfISAtPanB%2Fo9j6kMQVxd%2BTR7wuKQP4eMVf49kkeN4TBCIg%2BlTiywsL4O3kzrem6mGlm701JbplIUIhTT246k8Fy3SlbLhlsGdESbIqFZK60ZI%2FMVR0nuZwFECxjATJSbQaXGvaOl%2FvyJvP%2BsBreDi3TuQ%3D%3D&Expires=1742594852)

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