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.04k stars 1.11k forks source link

Checkov Linter Fails to Recognize comments in JSON After MegaLinter 8 Update #6678

Open nadiahansen opened 1 month ago

nadiahansen commented 1 month ago

Describe the bug After upgrading to MegaLinter version 8, the Checkov linter now fails when encountering comments in JSON files. Previously, these comments were used as Checkov skip commands to bypass certain checks (e.g., // #checkov:skip=CKV_SECRET_6:This is a dummy secret). However, following the update, these skip commands within JSON comments are no longer recognized by Checkov, resulting in linting errors where there were none before.

Example:

"appAuth": { "value": { "clientId": "**", // #checkov:skip=CKV_SECRET_6:This is a dummy secret "clientSecret": "WillBeReplaced", "clientSecretKeyId": "**", "entraIdAppRegistrationName": "**", "entraIdAppRegistrationAssignedGroups": [] } },

In this example, the comment // #checkov:skip=CKV_SECRET_6:This is a dummy secret was previously used to skip the Checkov rule CKV_SECRET_6. However, after updating to MegaLinter 8, this comment is no longer recognized and i get a fail to laod yaml error when running megalinter. It is not only checkov comments. but all comments in json it will throw the same error

****** 04:50:13,344 [MainThread ] [WARNI] Fail to load yaml content, while parsing a flow mapping in "<unicode string>", line 30, column 16: "value": { ^ expected ',' or '}', but got '<scalar>' in "<unicode string>", line 33, column 9: "clientSecret": "WillBeReplace ... ^

To Reproduce Steps to reproduce the behavior:

create json file with "//" comments run megalinter see checkov error

tsmithv11 commented 4 weeks ago

@nadiahansen I wasn't able to reproduce the warning log with the snippet provided. Could you please provide a snippet that reproduces the error with Checkov so we can take a look?

Screenshot 2024-09-09 at 11 08 08 PM