question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--check and --skip-check lists defined in files

See original GitHub issue

Is your feature request related to a problem? Please describe. We have a need to either define multiple skip checks or multiple checks. Would be great if we could load them from a file and not define explicitly in the cli param

Describe the solution you’d like --skip-check-list /path/to/file --check-list /path/to/file

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
larryboymicommented, Jun 4, 2021

To further illustrate the point I was trying to make, I established a very simple/checkov-compatible initial data contract for exceptions, such as:

[{
  "policyId": "CKV_AWS_62",
  "comment": "Spike testing suppression",
  "resourceType": "aws_iam_policy",
  "resourceName": "iac_poc"
}]

Now we just need a mechanism (currently) to get those suppressions in-line (although my preference would lean towards a new mechanism where skips could be passed automatically to the filter where they’re utilized). However, the current model can be processed by a shell script such as:

#!/usr/bin/env bash

grep_result=$(grep --exclude=process_exceptions.sh --exclude-dir=.git --exclude-dir=.terraform -r ".*checkov:skip=.*" .)

if [ $? -eq 1 ]; then
  echo "Phew, nobody messes with checkov."
else
  echo "Uh oh, someone is already trying to get by checkov."
  exit 1
fi

exceptions=$(cat exceptions.json | jq -r '.[] | @base64')

for exception in $exceptions; do
  _jq() {
    echo ${exception} | base64 --decode | jq -r ${1}
  }
  policyId=$(_jq '.policyId')
  comment=$(_jq '.comment')
  resourceType=$(_jq '.resourceType')
  resourceName=$(_jq '.resourceName')
  insert="#checkov:skip=$policyId:$comment"
  match='(^resource[ \t]*\"'"$resourceType"'\"[ \t]*\"'"$resourceName"'\".*$)'

  if [ "$(uname)" == "Darwin" ]; then
    LC_ALL=C find . -type f -not -path '*/\.*' -exec sed -i '' -E "s/$match/\1\n$insert/i" {} +
  else
    LC_ALL=C find . -type f -not -path '*/\.*' -exec sed -r "s/$match/\1\n$insert/i" {} +
  fi
done

This would need to be paired with a CLI flag to disable in-line suppressions (for audits sake an enterprise needs to track such security exceptions to established policy, things like approvals, requestor, requested date, expiration, last update, etc). I feel like the data retrieval on the JSON can be handled outside of checkov, and that checkov itself would not need all of this data, since it is purely doing the exception handling, but it would need a way to be passed in as a JSON blob or file.

Note: this is just a preliminary analysis, something such as moduleName might also be necessary in the JSON to help distinguish between similar named resources at different levels, etc.

1reaction
tronxdcommented, Apr 14, 2021

@tronxd do those let you specify which resources/modules to skip the check for?

@larryboymi you can use the --framework / --skip-framework flags for restrictions on specific IaC type(s). The --check flag restricts specific checks on specific resource types, so tweaking it to scan only specific resource types is feasible. Explicit resource types granularity is not supported yet, but that’s a great idea. @schosterbarak WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suppressing and Skipping Policies - checkov
To skip a check on a given Terraform definition block or CloudFormation ... and then the --skip-check list will be applied to remove...
Read more >
SKIPCHECK - IBM
(Skipping rules-calculated cells will cause consolidated totals to be incorrect). When the sparse consolidation algorithm is turned off, every cell is checked ......
Read more >
Prioritize, skip, and fail with policy severities in Checkov
Policy severities are now included in Checkov to help prioritize findings and make CI/CD skip and fail flags more manageable.
Read more >
pt-online-schema-change — Percona Toolkit Documentation
Do not use this tool before reading its documentation and checking your backups carefully. ... Read this comma-separated list of config files; if...
Read more >
Package Deployer tool - Power Platform | Microsoft Learn
You will be modifying these files as described later in this topic. ... Enter pac package help to see the list of subcommands....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found