bridgecrewio / checkov

Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages with Checkov by Bridgecrew.
https://www.checkov.io/
Apache License 2.0
7.03k stars 1.1k forks source link

Properties in AWS SAM Globals section not merged with associated resources #2758

Closed subnova closed 1 month ago

subnova commented 2 years ago

Describe the issue AWS SAM extends CloudFormation to include a Globals section (https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html) that provides default values for various different types of SAM/CloudFormation resources.

Checkov should merge these values with the associated resources prior to running a check.

Example Value

The template:

Transform:
  - AWS::Serverless-2016-10-31

Globals:
  Function:
    KmsKeyArn: !GetAtt KmsKey.Arn

Resources:
  KmsKey:
    Type: AWS::KMS::Key
    Properties:
      EnableKeyRotation: true
      KeyPolicy:
        Version: "2012-10-17"
        Statement:
          - Effect: "Allow"
            Principal:
              AWS: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:root"
            Action:
              - "kms:*"
            Resource:
              - "*"

  SomeLambda:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src
      Policies:
        - AWSLambdaBasicExecutionRole
      Environment:
        Variables:
          MY_VARIABLE: "This is the variable value"

Should not trigger CKV_AWS_173 for SomeLambda as the KmsKeyArn is specified in the Globals section.

stale[bot] commented 2 years ago

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at https://slack.bridgecrew.io Thanks!

agilesrcmh commented 1 year ago

Any ETA on fixing this issue?

stale[bot] commented 1 year ago

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at https://slack.bridgecrew.io Thanks!

stale[bot] commented 12 months ago

Closing issue due to inactivity. If you feel this is in error, please re-open, or reach out to the community via slack: https://slack.bridgecrew.io Thanks!

TaherKapasi commented 3 months ago

Thanks @Saarett - much appreciated

arielkru commented 2 months ago

Hey @subnova @agilesrcmh @TaherKapasi , if any of you are able to a PR to fix this, it would be highly appreciated and it would help us get to this.

Thank you!