moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

Closed moelasmar closed 2 months ago

moelasmar commented 2 months 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 2 months ago

This issue has been queued for processing by our automated system.

moelasmar commented 2 months 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%2316/moelasmar/CodeQlDemoEcsIssue%2316_results.zip?AWSAccessKeyId=ASIAQUFLP7FHSXPVJOKZ&Signature=M588OBLJJCOkny%2B0S6KEUpjgdxI%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEKv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQCtbmGrCwtNJ%2Bux9zCWg56cqA3XPi2pZ7IV4r5VaKuaMgIgHjTnQHJYXp4NJLAjdiaLiirJ7BG2V9wtkGg%2FJgP8ZTEq5AQI9P%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDAkoi%2F%2BGQuII4m8FEiq4BCDzKo5aYjr4L9LdtyZQ7FVzojGdFlfHMJIY47DhlidSEs%2BHCKIkGdDMOIZF8RMn76iEMRjdU8LBrepYzbEz%2F4JodeKRDCBafuJR35pbQxe0yqwzFBFjMMq7NzC5RgSl9ouq4BHRDWGKYOpfJc6Ir%2FGM2gHxxKWLN6RVmTkeWVtKn9SDi%2BoP2x%2FPazO8mNKPcAoNjCqHoxPifF6EcRHiir5A9mQYi1JG5PZFvtCzKriYUe%2FAarfBKWHE9qQazYFxz8ry9GgpKWxrAqcYklBuO%2Fqq0ZKGJ4KwdJT39%2FQl11532%2FrSiDDEnmAfy1re9o6YUnnJsK6sR7VRZzIbGoA3CCHzjVEnqDTr%2Fuv2GDJrkPWX8M8RPac3Kg9SuK5zo5RvElTWsNpb64GAiKDUX%2B60s4RIaVD%2BM95OtpFyzQJo582qc6WVaLYLHzDkmkEoR0Fyozvv%2BJW7QNPxuovkg%2FOL45SpUGl%2B1fenPm7nPvs2wsu9GGW8hvBXjbIbshG0ph56%2FJlxCirYHMd6ZMaG94DZtaohu7yNRdGgBFA92uoM4B7zxrW8k4XmVMPbafgx9F%2Bd5vAIguCyr5zU6NtH8EucjmoOOajRt5BOzwalus10zcfIxzVMkqzfKFIBhw%2FLLjgjqKRNjY2Ei6YjsersxJbAdG2NOyNdHWgjEL3Jd8fKWI8xUWH1O4Ud4UK8k%2FSFUOd%2BobjNYX4qSKsjZ5caPUlfjhsv%2FQMwU5o7%2Ff5koBCqbobchia633o4zmQw%2BfLRvgY6pwEMsAaVZIqSsIr%2FB531Ng9IjKYsVxYa%2Bkv2Ok75coSkWYshKrUrFh8e5VvWxIvXaucUeG1ykxXrf4khw5Pq1f%2FB10nAHtY3C2sEHnan%2FPUtBU0X68B4erm6RZaAy6%2BzSy0hdomb%2F%2FyMpzweiiaX5VZF5xYKaeODwb4WgiSgIGVYtQvUUcQHgGbWd8tJ3IEJg9bjsC5H6aguvn%2BMD%2F8usRVV93jerqs2KA%3D%3D&Expires=1742583008)

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