moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

Open moelasmar opened 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%2322/moelasmar/CodeQlDemoEcsIssue%2322_results.zip?AWSAccessKeyId=ASIAQUFLP7FHV7G37FZM&Signature=FcvyQwI%2FvMUx6LE%2B9XWW41bgYsA%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEK7%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJIMEYCIQCvsMVq1uFp6fugoYeSL%2BydPAo%2BVUCWZsZCz5HNyXV4cwIhALiMe35wzDSGNWu6BMZWBsQAQLCGCRnhbTn27pAyjaHNKuQECPf%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMDQzMzA5MzMyODE1Igwp607lTS67BIlTOLwquARnvvPvm3IF3%2BDOkx%2BbZq3RIQGmnOTwWawYwTD5V3F5LhS88ptVjauSJfQu1pwRXQXGglz26iA5eqhBhdl8TnKc%2BZanU1BfIvcU3%2Fi43R56cEs6C0ebQ4Qqvv1CWRLxU6%2BO53xXzewZXaPOQsTxE34VIoq84xQEvjpsv27Jrl3mL0GXNamO8dXt9K35c5Eyh2Pwve0mA8IWf%2Fnpkk9C2NhgjOSclunt525Gn22oI4hvNTn3SKJcpbQTTSOrPr%2FuarfBndq3IzfBCMDh8TAv9ygpGc7CqWGIJSyDNIN9dILXNci3hFDDl673YPALuKnwM0INHqa9cq%2FK4Y%2BmqP4ax5aomJYTzecW7LPKPiWUtx%2B9wNv3RmBdOHkJGBZy0HWbeuZCdqPsIRQBrReujfHAgG2yzkZVbRi%2FpvLiI%2BTa1%2BFbpfRFiEp1zsAwgVOmm1MHrAy0S8PVxgBaXn99pbaqT4RssWpExqwFKzs5ZQiM9awtJbbBnXtMTQAbJqowfGLTOBzf0wFHdlrX8RoTAO9kOHIBrEA3wUNTGecEKs16diD8nB6qURFOW0tU%2BOQjj79H9ODDGeShkloMfDfrRC2BwDJSsPe6%2FvUZkJgPWxTYY0wGMkymRW8xeuEBUzwumQS%2B5tKvrDpeiuQ8%2FjM4ngHSOruP2hCqQZfIvmQEYWCghdRg%2F1ASnH0TVhLAfhNkV8CJDNH2im63UYsmmk1FOdeGE9g4z5B9upsC2FQRJM1%2FeVOo1c5E2ySImY31MNfT0r4GOqYBZ7%2BzsB1iS70%2Bt3LodkjWy2FM1agEGvedX8krFcWKe0%2FZhXFh7oHttQlG8N09NGoN%2FTBjT59eh4%2B1FGtviGDgCl8py2G8E3wNlkMw3LsVaZUE9xbbUIEls%2Fa7ZMLYflurqcEgD9jQnfEoFWGl1lHu2ZIjrGCB2vNVZDW5SG7Sfmb8NqWyIqS0L0baikd%2Fa0byZP9CjbzsL75Djl5qmcLumDkF7QSkSw%3D%3D&Expires=1742595290)

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