Repository: bridgecrewio/checkov

Issue:
Crash when running a scan against a plan output
**Describe the issue**
We have Checkov configured in a GitHub Action workflow.  Our configuration creates a Terraform plan, and then we run Checkov against that plan.  This practice was working but recently started failing with a TypeError when attempting a scan of a plan.

**Examples**
terraform plan -no-color --out tfplan.binary 
terraform show -no-color -json tfplan.binary > ${{ github.workspace }}/${{steps.get-plan-file-name.outputs.name}}
checkov -f ${{ github.workspace }}/${{steps.get-plan-file-name.outputs.name}} \
    --framework terraform_plan \
    --skip-check 

**Exception Trace**
```2022-12-14 16:00:44,343 [MainThread  ] [DEBUG]  Leveraging the bundled IAM Definition.
2022-12-14 16:00:44,343 [MainThread  ] [DEBUG]  Leveraging the IAM definition at /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/policy_sentry/shared/data/iam-definition.json
2022-12-14 16:00:44,589 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0> with order 0
2022-12-14 16:00:44,589 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,589 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>]
2022-12-14 16:00:44,590 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0> with order 2
2022-12-14 16:00:44,590 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,590 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0>]
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x7f188cae2950> with order 6
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x7f188cae2950>]
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x7f188cae2f20> with order 0
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,591 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>, <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x7f188cae2f20>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x7f188cae2950>]
2022-12-14 16:00:44,592 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x7f188cae3550> with order 10
2022-12-14 16:00:44,592 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,592 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>, <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x7f188cae2f20>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x7f188cae2950>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x7f188cae3550>]
2022-12-14 16:00:44,593 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x7f188cae39d0> with order 1
2022-12-14 16:00:44,593 [MainThread  ] [DEBUG]  self.features after the sort:
2022-12-14 16:00:44,593 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x7f188f6cffd0>, <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x7f188cae2f20>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x7f188cae39d0>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x7f188cae24d0>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x7f188cae2950>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x7f188cae3550>]
2022-12-14 16:00:44,620 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/bicep/checks/graph_checks
2022-12-14 16:00:44,749 [MainThread  ] [DEBUG]  Popen(['git', 'version'], cwd=/home/runner/work/aws-infra/aws-infra, universal_newlines=False, shell=None, istream=None)
2022-12-14 16:00:44,767 [MainThread  ] [DEBUG]  Popen(['git', 'version'], cwd=/home/runner/work/aws-infra/aws-infra, universal_newlines=False, shell=None, istream=None)
2022-12-14 16:00:45,180 [MainThread  ] [DEBUG]  No API key present; setting include_all_checkov_policies to True
2022-12-14 16:00:45,180 [MainThread  ] [DEBUG]  Run metadata: {
  "checkov_version": "2.2.155",
  "python_executable": "/opt/hostedtoolcache/Python/3.10.8/x64/bin/python",
  "python_version": "3.10.8 (main, Oct 18 2022, 06:43:21) [GCC 9.4.0]",
  "checkov_executable": "/opt/hostedtoolcache/Python/3.10.8/x64/bin/checkov",
  "args": [
    "Command Line Args:   -f formatted_plan_tfplan_infrastructure_workspaces_app_qa1-common_1937.json --framework terraform_plan --skip-check CKV_AWS_18,CKV_AWS_19,CKV_AWS_21,CKV_AWS_26,CKV_AWS_30,CKV_AWS_31,CKV_AWS_65,CKV_AWS_144,CKV_AWS_145,CKV_AWS_166,CKV_AWS_186,CKV_AWS_191,CKV_AWS_224,CKV_AWS_233,CKV2_AWS_5,CKV2_AWS_6,CKV2_AWS_34,CKV_AWS_158",
    "Defaults:",
    "  --branch:          master",
    "  --download-external-modules:False",
    "  --external-modules-download-path:.external_modules",
    "  --evaluate-variables:True",
    "  --secrets-scan-file-type:[]",
    "  --block-list-secret-scan:[]",
    "  --summary-position:top",
    ""
  ]
}
2022-12-14 16:00:45,181 [MainThread  ] [DEBUG]  Resultant set of frameworks (removing skipped frameworks): terraform_plan
2022-12-14 16:00:45,182 [MainThread  ] [DEBUG]  terraform_plan_runner declares no system dependency checks required.
2022-12-14 16:00:45,182 [MainThread  ] [DEBUG]  No API key found. Scanning locally only.
2022-12-14 16:00:45,249 [MainThread  ] [DEBUG]  Got checkov mappings and guidelines from Bridgecrew platform
2022-12-14 16:00:45,249 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/terraform/checks/graph_checks
2022-12-14 16:00:45,250 [MainThread  ] [DEBUG]  Searching through ['gcp', '__pycache__', 'aws', 'azure'] and ['__init__.py']
2022-12-14 16:00:45,250 [MainThread  ] [DEBUG]  Searching through [] and ['GCPContainerRegistryReposAreNotPubliclyAccessible.yaml', 'GCPComputeFirewallOverlyPermissiveToAllTraffic.yaml', 'GKEClustersAreNotUsingDefaultServiceAccount.yaml', 'ServiceAccountHasGCPmanagedKey.yaml', 'GCPAuditLogsConfiguredForAllServicesAndUsers.yaml', 'GCPKMSKeyRingsAreNotPubliclyAccessible.yaml', 'DisableAccessToSqlDBInstanceForRootUsersWithoutPassword.yaml', 'GCPProjectHasNoLegacyNetworks.yaml', 'GCPLogBucketsConfiguredUsingLock.yaml', 'GCPKMSCryptoKeysAreNotPubliclyAccessible.yaml', 'CloudFunctionSecureHTTPTrigger.yaml', 'GCRContainerVulnerabilityScanningEnabled.yaml']
2022-12-14 16:00:45,300 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-310.pyc']
2022-12-14 16:00:45,300 [MainThread  ] [DEBUG]  Searching through [] and ['VPCHasFlowLog.yaml', 'S3BucketHasPublicAccessBlock.yaml', 'EBSAddedBackup.yaml', 'WAF2HasLogs.yaml', 'S3PublicACLRead.yaml', 'S3BucketLogging.yaml', 'AppLoadBalancerTLS12.yaml', 'EFSAddedBackup.yaml', 'Route53ZoneHasMatchingQueryLog.yaml', 'S3KMSEncryptedByDefault.yaml', 'VPCHasRestrictedSG.yaml', 'ALBRedirectsHTTPToHTTPS.yaml', 'S3BucketVersioning.yaml', 'Route53ARecordAttachedResource.yaml', 'AppSyncProtectedByWAF.yaml', 'Route53ZoneEnableDNSSECSigning.yaml', 'SubnetHasACL.yaml', 'RDSClusterHasBackupPlan.yaml', 'AutoScalingEnableOnDynamoDBTables.yaml', 'IAMGroupHasAtLeastOneUser.yaml', 'APIGWLoggingLevelsDefinedProperly.yaml', 'PostgresRDSHasQueryLoggingEnabled.yaml', 'IAMUserHasNoConsoleAccess.yaml', 'APIProtectedByWAF.yaml', 'S3BucketEncryption.yaml', 'VPCPeeringRouteTableOverlyPermissive.yaml', 'ALBProtectedByWAF.yaml', 'PostgresDBHasQueryLoggingEnabled.yaml', 'EC2InstanceHasIAMRoleAttached.yaml', 'S3PublicACLWrite.yaml', 'AWSNATGatewaysshouldbeutilized.yaml', 'SGAttachedToResource.yaml', 'AutoScallingEnabledELB.yaml', 'GuardDutyIsEnabled.yaml', 'HTTPNotSendingPasswords.yaml', 'CodecommitApprovalRulesAttached.yaml', 'S3NotAllowAccessToAllAuthenticatedUsers.yaml', 'CloudFrontHasCustomSSLCertificate.yaml', 'CloudFrontHasResponseHeadersPolicy.yaml', 'EIPAllocatedToVPCAttachedEC2.yaml', 'CloudtrailHasCloudwatch.yaml', 'IAMPolicyNotAllowFullIAMAccess.yaml', 'IAMUsersAreMembersAtLeastOneGroup.yaml', 'AWSSSMParameterShouldBeEncrypted.yaml', 'S3BucketReplicationConfiguration.yaml', 'AMRClustersNotOpenToInternet.yaml', 'EncryptedEBSVolumeOnlyConnectedToEC2s.yaml']
2022-12-14 16:00:45,458 [MainThread  ] [DEBUG]  Searching through [] and ['StorageLoggingIsEnabledForBlobService.yaml', 'SQLServerAuditingEnabled.yaml', 'AzureDataFactoriesEncryptedWithCustomerManagedKey.yaml', 'StorageContainerActivityLogsNotPublic.yaml', 'ApplicationGatewayEnablesWAF.yaml', 'VirtualMachinesUtilizingManagedDisks.yaml', 'AzureActiveDirectoryAdminIsConfigured.yaml', 'AzureNetworkInterfacePublicIPAddressId.yaml', 'AzureAntimalwareIsConfiguredWithAutoUpdatesForVMs.yaml', 'SQLServerAuditingRetention90Days.yaml', 'VAconfiguredToSendReportsToAdmins.yaml', 'MSQLenablesCustomerManagedKey.yaml', 'AzureUnattachedDisksAreEncrypted.yaml', 'VAconfiguredToSendReports.yaml', 'StorageCriticalDataEncryptedCMK.yaml', 'AccessToPostgreSQLFromAzureServicesIsDisabled.yaml', 'PGSQLenablesCustomerManagedKey.yaml', 'AzureMSSQLServerHasSecurityAlertPolicy.yaml', 'StorageLoggingIsEnabledForTableService.yaml', 'AzureStorageAccountsUseCustomerManagedKeyForEncryption.yaml', 'AzureSynapseWorkspacesHaveNoIPFirewallRulesAttached.yaml', 'DataExplorerEncryptionUsesCustomKey.yaml', 'CognitiveServicesCustomerManagedKey.yaml', 'VAsetPeriodicScansOnSQL.yaml', 'VAisEnabledInStorageAccount.yaml', 'VMHasBackUpMachine.yaml']
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/cloudformation/checks/graph_checks
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['__init__.py']
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-310.pyc']
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/kubernetes/checks/graph_checks
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/bicep/checks/graph_checks
2022-12-14 16:00:45,525 [MainThread  ] [DEBUG]  Loading external checks from /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/terraform_plan/checks/graph_checks
2022-12-14 16:00:45,529 [MainThread  ] [DEBUG]  Running without API key, so only open source runners will be enabled
2022-12-14 16:00:45,529 [MainThread  ] [DEBUG]  Filtered list of policies: []
2022-12-14 16:00:45,529 [MainThread  ] [DEBUG]  Received the following policy-level suppressions, that will be skipped from running: []
2022-12-14 16:00:45,529 [MainThread  ] [DEBUG]  Filtered runners based on file type(s). Result: ['terraform_plan']
2022-12-14 16:00:45,530 [MainThread  ] [DEBUG]  Checking if terraform_plan is valid for license
2022-12-14 16:00:45,530 [MainThread  ] [DEBUG]  Open source mode - the runner is {"en" if enabled else "dis"}abled
2022-12-14 16:00:45,530 [MainThread  ] [DEBUG]  [tf_plan] - Parsing file /home/runner/work/aws-infra/aws-infra/formatted_plan_tfplan_infrastructure_workspaces_app_qa1-common_1937.json
2022-12-14 16:00:45,742 [MainThread  ] [DEBUG]  [tf_plan] - Successfully parsed file /home/runner/work/aws-infra/aws-infra/formatted_plan_tfplan_infrastructure_workspaces_app_qa1-common_1937.json
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.8/x64/bin/checkov", line 9, in <module>
    sys.exit(run())
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/main.py", line 399, in run
    scan_reports = runner_registry.run(external_checks_dir=external_checks_dir, files=config.file,
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/common/runners/runner_registry.py", line 87, in run
    self.runners[0].run(root_folder, external_checks_dir=external_checks_dir, files=files,
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/terraform/plan_runner.py", line 104, in run
    censored_definitions = omit_secret_value_from_definitions(definitions=self.definitions,
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/common/util/secrets.py", line 193, in omit_secret_value_from_definitions
    censored_value = omit_secret_value_from_line(secret, secret)
  File "/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/checkov/common/util/secrets.py", line 126, in omit_secret_value_from_line
    secret_length = len(secret)
TypeError: object of type 'bool' has no len()
Error: Process completed with exit code 1.
```

**Desktop (please complete the following information):**
This issue has been replicated  with every combination of the following:
 - OS: Ubuntu 20.04 and Ubuntu 22.04
 - Checkov Version: 2.2.148 and 2.2.155
 - Python Version: 3.10.8 and 3.11.1



Discussion:

Resolving patch:
diff --git a/checkov/common/util/secrets.py b/checkov/common/util/secrets.py
--- a/checkov/common/util/secrets.py
+++ b/checkov/common/util/secrets.py
@@ -120,7 +120,7 @@ def omit_multiple_secret_values_from_line(secrets: set[str], line_text: str) ->
 
 
 def omit_secret_value_from_line(secret: str | None, line_text: str) -> str:
-    if not secret:
+    if not secret or not isinstance(secret, str):
         return line_text
 
     secret_length = len(secret)


Test patch:
diff --git a/tests/unit/test_secrets.py b/tests/unit/test_secrets.py
--- a/tests/unit/test_secrets.py
+++ b/tests/unit/test_secrets.py
@@ -49,6 +49,12 @@ def test_omit_none_secret_from_line(self):
         line = 'text'
         self.assertEqual(line, omit_secret_value_from_line(secret=None, line_text=line))
 
+    def test_omit_non_string_secret_from_line(self):
+        line = 'text'
+        secret = True
+
+        self.assertEqual(line, omit_secret_value_from_line(secret, line))
+
     def test_get_secrets_from_secrets(self):
         s = 'access_key: "AKIAIOSFODNN7EXAMPLE"'