Skip to content

cfn-guard validate -o json does not include CDK-Path #251

Closed

Description

@alexpulver

I see CDK-Path in text output, but don't see when using-o json.

By the way, should there be a difference between --print-json and -o json? Why not have only -o json?

Command

cfn-guard validate -d template.json -r rules.guard -o json > output.json

template.json

{
  "Resources": {
    "WebsiteBucket4326D7C2": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "AccessControl": "PublicRead"
      },
      "Metadata": {
        "aws:cdk:path": "LandingPageFrontend/Website/Bucket/Resource"
      }
    }
  }
}

rules.guard

let aws_s3_bucket_resources = Resources.*[ Type == 'AWS::S3::Bucket' ]

rule aws_s3_bucket_versioning_defined {
  when %aws_s3_bucket_resources not empty {
    %aws_s3_bucket_resources {
      Properties {
        VersioningConfiguration exists <<VersioningConfiguration is not defined>>
      }
    }
  }
}

Originally posted by @alexpulver in #204 (comment)

Activity

  1. changed the title [-]cfn-guard validate does not include CDK-Path when using -o json option[/-] [+]cfn-guard validate -o json does not include CDK-Path[/+] on Jul 1, 2022
  2. changed the title [-]cfn-guard validate -o json does not include CDK-Path[/-] [+]cfn-guard validate `-o json` does not include CDK-Path[/+] on Jul 1, 2022
  3. changed the title [-]cfn-guard validate `-o json` does not include CDK-Path[/-] [+]cfn-guard validate `-o json` does not include `CDK-Path`[/+] on Jul 1, 2022
  4. changed the title [-]cfn-guard validate `-o json` does not include `CDK-Path`[/-] [+]`cfn-guard validate -o json` does not include `CDK-Path`[/+] on Jul 1, 2022
  5. razcloud commented on Jul 5, 2022

    @razcloud
    Contributor

    Noted @alexpulver Will bring this back to the team.

  6. akshayrane commented on Jul 11, 2022

    @akshayrane
    Contributor

    --print-json is supposed to print JSON for abstract syntax tree for the clauses in the rule, which tells us more details about how the clauses get evaluated.

    -o json just changes the format of output summary that's emitted for failures, with error message from the rule, if any.

    We will keep this issue opened, and make the --help docs less ambiguous.

  7. alexpulver commented on Jul 12, 2022

    @alexpulver
    Author

    Thank you!

  8. joshfried-aws commented on Apr 18, 2024

    @joshfried-aws
    Contributor

    Hey @alexpulver due to work required to add this, and it leading to possibly a breaking change with existing consumers of the JSON output we have chosen to not add this to the current JSON output.

    Thanks,

  9. alexpulver commented on Apr 19, 2024

    @alexpulver
    Author

    Hi @joshfried-aws, thanks for the update 🙏.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions