Repository: bridgecrewio/checkov

Issue:
Checkov fails to read utf-8-BOM encoding
**Describe the issue**
As the title says, I don't get any output from files that are encoded with UTF-8-BOM while other encodings get parsed as expected.

Excuse me If I added the wrong label. Imo this doesn't fit under the category of crashes since Checkov doesn't crash or show a stack trace. It just doesn't produce any useful output.

**Examples**
I copied this simple deplyoment from the Kubernetes examples

```yaml
apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: guestbook
      tier: frontend
  replicas: 3
  template:
    metadata:
      labels:
        app: guestbook
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google-samples/gb-frontend:v4
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        env:
        - name: GET_HOSTS_FROM
          value: dns
          # If your cluster config does not include a dns service, then to
          # instead access environment variables to find service host
          # info, comment out the 'value: dns' line above, and uncomment the
          # line below:
          # value: env
        ports:
        - containerPort: 80
```

And if I save it with utf-8-BOM encoding I get only this output:

```
PS H:\k8sexamples> checkov -f .\copy-utf-8-bom.yaml --framework kubernetes
[ kubernetes framework ]: 100%|████████████████████|[1/1], Current File Scanned=copy-utf-8-bom.yaml

       _               _
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V /
  \___|_| |_|\___|\___|_|\_\___/ \_/

By bridgecrew.io | version: 2.3.141

```

While if I save it with encoding UTF-8 the file get parsed as expected.

```
PS H:\k8sexamples> checkov -f .\copy-utf-8.yaml --framework kubernetes
[ kubernetes framework ]: 100%|████████████████████|[1/1], Current File Scanned=copy-utf-8.yaml

       _               _
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V /
  \___|_| |_|\___|\___|_|\_\___/ \_/

By bridgecrew.io | version: 2.3.141

kubernetes scan results:

Passed checks: 70, Failed checks: 18, Skipped checks: 0

Check: CKV_K8S_25: "Minimize the admission of containers with added capability"
        PASSED for resource: Deployment.default.frontend
        File: /copy-utf-8.yaml:1-33
        Guide: https://docs.bridgecrew.io/docs/bc_k8s_24
Check: CKV_K8S_39: "Do not use the CAP_SYS_ADMIN linux capability"
        PASSED for resource: Deployment.default.frontend
        File: /copy-utf-8.yaml:1-33
        Guide: https://docs.bridgecrew.io/docs/bc_k8s_36

[rest of the output omitted]
```

I'll add the debug output from the utf-8-BOM encoded file bellow.


**Versions:**
 - Checkov Version 2.3.141
 - Python Version 3.9.7
 - Windows Version Windows-10-10.0.18363-SP0

**Additional context**

```
PS H:\k8sexamples> checkov -f .\copy-utf-8-bom.yaml --framework kubernetes
2023-03-31 09:01:04,860 [MainThread  ] [DEBUG]  Leveraging the bundled IAM Definition.
2023-03-31 09:01:04,861 [MainThread  ] [DEBUG]  Leveraging the IAM definition at C:\Users\user\AppData\Roaming\Python\Python39\site-packages\policy_sentry\shared\data\iam-definition.json
2023-03-31 09:01:07,839 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90> with order 1
2023-03-31 09:01:07,839 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,842 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>]
2023-03-31 09:01:07,845 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460> with order 0
2023-03-31 09:01:07,845 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,846 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>]
2023-03-31 09:01:07,846 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790> with order 10
2023-03-31 09:01:07,847 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,847 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790>]
2023-03-31 09:01:07,850 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x000002302A460820> with order 6
2023-03-31 09:01:07,851 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,857 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x000002302A460820>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790>]
2023-03-31 09:01:07,867 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.policies_3d_integration.Policies3DIntegration object at 0x000002302A460CD0> with order 11
2023-03-31 09:01:07,869 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,870 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x000002302A460820>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790>, <checkov.common.bridgecrew.integration_features.features.policies_3d_integration.Policies3DIntegration object at 0x000002302A460CD0>]
2023-03-31 09:01:07,872 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x000002302A46ED90> with order 0
2023-03-31 09:01:07,873 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,874 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x000002302A46ED90>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x000002302A460820>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790>, <checkov.common.bridgecrew.integration_features.features.policies_3d_integration.Policies3DIntegration object at 0x000002302A460CD0>]
2023-03-31 09:01:07,876 [MainThread  ] [DEBUG]  Adding the IntegrationFeatureRegistry <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x000002302A47C370> with order 2
2023-03-31 09:01:07,877 [MainThread  ] [DEBUG]  self.features after the sort:
2023-03-31 09:01:07,877 [MainThread  ] [DEBUG]  [<checkov.common.bridgecrew.integration_features.features.policy_metadata_integration.PolicyMetadataIntegration object at 0x000002302A460460>, <checkov.common.bridgecrew.integration_features.features.repo_config_integration.RepoConfigIntegration object at 0x000002302A46ED90>, <checkov.common.bridgecrew.integration_features.features.custom_policies_integration.CustomPoliciesIntegration object at 0x000002302A100A90>, <checkov.common.bridgecrew.integration_features.features.suppressions_integration.SuppressionsIntegration object at 0x000002302A47C370>, <checkov.common.bridgecrew.integration_features.features.licensing_integration.LicensingIntegration object at 0x000002302A460820>, <checkov.common.bridgecrew.integration_features.features.fixes_integration.FixesIntegration object at 0x000002302A44C790>, <checkov.common.bridgecrew.integration_features.features.policies_3d_integration.Policies3DIntegration object at 0x000002302A460CD0>]
2023-03-31 09:01:08,028 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/bicep/checks/graph_checks
2023-03-31 09:01:08,029 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['SQLServerAuditingEnabled.yaml', '__init__.py']
2023-03-31 09:01:08,039 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:08,551 [MainThread  ] [DEBUG]  Popen(['git', 'version'], cwd=H:\k8sexamples, universal_newlines=False, shell=None, istream=None)
2023-03-31 09:01:08,687 [MainThread  ] [DEBUG]  Popen(['git', 'version'], cwd=H:\k8sexamples, universal_newlines=False, shell=None, istream=None)
2023-03-31 09:01:09,594 [MainThread  ] [DEBUG]  No API key present; setting include_all_checkov_policies to True
2023-03-31 09:01:09,613 [MainThread  ] [DEBUG]  Run metadata: {
  "checkov_version": "2.3.141",
  "python_executable": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python39_64\\python.exe",
  "python_version": "3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]",
  "checkov_executable": "C:\\Users\\user\\AppData\\Roaming\\Python\\Python39\\Scripts\\checkov.cmd",
  "args": [
    "Command Line Args:   -f .\\copy-utf-8-bom.yaml --framework kubernetes",
    "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",
    "  --mask:            []",
    "  --secrets-history-timeout:12h",
    ""
  ],
  "OS_system_info": "Windows-10-10.0.18363-SP0",
  "CPU_architecture": "Intel64 Family 6 Model 94 Stepping 3, GenuineIntel",
  "Python_implementation": "CPython"
}
2023-03-31 09:01:09,614 [MainThread  ] [DEBUG]  Using cert_reqs None
2023-03-31 09:01:09,615 [MainThread  ] [DEBUG]  Successfully set up HTTP manager
2023-03-31 09:01:09,622 [MainThread  ] [DEBUG]  Resultant set of frameworks (removing skipped frameworks): kubernetes
2023-03-31 09:01:09,622 [MainThread  ] [DEBUG]  BC_SOURCE = cli, version = 2.3.141
2023-03-31 09:01:09,622 [MainThread  ] [DEBUG]  kubernetes_runner declares no system dependency checks required.
2023-03-31 09:01:09,623 [MainThread  ] [DEBUG]  No API key found. Scanning locally only.
2023-03-31 09:01:10,220 [MainThread  ] [DEBUG]  Got checkov mappings and guidelines from Bridgecrew platform
2023-03-31 09:01:10,221 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/terraform/checks/graph_checks
2023-03-31 09:01:10,223 [MainThread  ] [DEBUG]  Searching through ['aws', 'azure', 'gcp', '__pycache__'] and ['__init__.py']
2023-03-31 09:01:10,224 [MainThread  ] [DEBUG]  Searching through [] and ['ALBProtectedByWAF.yaml', 'ALBRedirectsHTTPToHTTPS.yaml', 'AMRClustersNotOpenToInternet.yaml', 'APIGatewayEndpointsUsesCertificateForAuthentication.yaml', 'APIGatewayRequestParameterValidationEnabled.yaml', 'APIGWLoggingLevelsDefinedProperly.yaml', 'APIProtectedByWAF.yaml', 'AppLoadBalancerTLS12.yaml', 'AppSyncProtectedByWAF.yaml', 'AutoScalingEnableOnDynamoDBTables.yaml', 'AutoScallingEnabledELB.yaml', 'AWSConfigRecorderEnabled.yaml', 'AWSNATGatewaysshouldbeutilized.yaml', 'AWSSSMParameterShouldBeEncrypted.yaml', 'CloudFrontHasCustomSSLCertificate.yaml', 'CloudFrontHasResponseHeadersPolicy.yaml', 'CLoudFrontS3OriginConfigWithOAI.yaml', 'CloudFrontUsesSecureProtocolsForHTTPS.yaml', 'CloudFrontWebACLConfiguredWIthLog4jVulnerability.yaml', 'CloudtrailHasCloudwatch.yaml', 'CodecommitApprovalRulesAttached.yaml', 'ConfigRecorderRecordsAllGlobalResources.yaml', 'DMSEndpointHaveSSLConfigured.yaml', 'EBSAddedBackup.yaml', 'EC2InstanceHasIAMRoleAttached.yaml', 'EFSAddedBackup.yaml', 'EIPAllocatedToVPCAttachedEC2.yaml', 'ElastiCacheRedisConfiguredAutomaticFailOver.yaml', 'ElasticSearchDedicatedMasterEnabled.yaml', 'EMRClusterHasSecurityConfiguration.yaml', 'EncryptedEBSVolumeOnlyConnectedToEC2s.yaml', 'GuardDutyIsEnabled.yaml', 'HTTPNotSendingPasswords.yaml', 'IAMGroupHasAtLeastOneUser.yaml', 'IAMManagedIAMFullAccessPolicy.yaml', 'IAMPolicyNotAllowFullIAMAccess.yaml', 'IAMUserHasNoConsoleAccess.yaml', 'IAMUsersAreMembersAtLeastOneGroup.yaml', 'NeptuneDeletionProtectionEnabled.yaml', 'OpenSearchDomainHasFineGrainedControl.yaml', 'PostgresDBHasQueryLoggingEnabled.yaml', 'PostgresRDSHasQueryLoggingEnabled.yaml', 'RDSClusterHasBackupPlan.yaml', 'RDSEnableCopyTagsToSnapshot.yaml', 'Route53ARecordAttachedResource.yaml', 'Route53ZoneEnableDNSSECSigning.yaml', 'Route53ZoneHasMatchingQueryLog.yaml', 'S3BucketEncryption.yaml', 'S3BucketEventNotifications.yaml', 'S3BucketHasPublicAccessBlock.yaml', 'S3BucketLifecycle.yaml', 'S3BucketLogging.yaml', 'S3BucketReplicationConfiguration.yaml', 'S3BucketVersioning.yaml', 'S3KMSEncryptedByDefault.yaml', 'S3NotAllowAccessToAllAuthenticatedUsers.yaml', 'S3PublicACLRead.yaml', 'S3PublicACLWrite.yaml', 'SecretsAreRotated.yaml', 'SGAttachedToResource.yaml', 'SubnetHasACL.yaml', 'VPCHasFlowLog.yaml', 'VPCHasRestrictedSG.yaml', 'VPCPeeringRouteTableOverlyPermissive.yaml', 'WAF2HasLogs.yaml']
2023-03-31 09:01:10,592 [MainThread  ] [DEBUG]  Searching through [] and ['AccessToPostgreSQLFromAzureServicesIsDisabled.yaml', 'ApplicationGatewayEnablesWAF.yaml', 'AzureACR_HTTPSwebhook.yaml', 'AzureActiveDirectoryAdminIsConfigured.yaml', 'AzureAKSclusterAzureCNIEnabled.yaml', 'AzureAntimalwareIsConfiguredWithAutoUpdatesForVMs.yaml', 'AzureAutomationAccNotOverlyPermissiveNetAccess.yaml', 'AzureConfigMSSQLwithAD.yaml', 'AzureContainerInstanceconfigManagedIdentity.yaml', 'AzureDataFactoriesEncryptedWithCustomerManagedKey.yaml', 'AzureKeyVaultConfigPrivateEndpoint.yaml', 'AzureMSSQLServerHasSecurityAlertPolicy.yaml', 'AzureNetworkInterfacePublicIPAddressId.yaml', 'AzurePostgreSQLFlexServerNotOverlyPermissive.yaml', 'AzureSpringCloudConfigWithVnet.yaml', 'AzureSqlDbEnableTransparentDataEncryption.yaml', 'AzureStorageAccConfigWithPrivateEndpoint.yaml', 'AzureStorageAccountsUseCustomerManagedKeyForEncryption.yaml', 'AzureSubnetConfigWithNSG.yaml', 'AzureSynapseWorkspacesHaveNoIPFirewallRulesAttached.yaml', 'AzureUnattachedDisksAreEncrypted.yaml', 'CognitiveServicesCustomerManagedKey.yaml', 'DataExplorerEncryptionUsesCustomKey.yaml', 'MSQLenablesCustomerManagedKey.yaml', 'PGSQLenablesCustomerManagedKey.yaml', 'SQLServerAuditingEnabled.yaml', 'SQLServerAuditingRetention90Days.yaml', 'StorageContainerActivityLogsNotPublic.yaml', 'StorageCriticalDataEncryptedCMK.yaml', 'StorageLoggingIsEnabledForBlobService.yaml', 'StorageLoggingIsEnabledForTableService.yaml', 'VAconfiguredToSendReports.yaml', 'VAconfiguredToSendReportsToAdmins.yaml', 'VAisEnabledInStorageAccount.yaml', 'VAsetPeriodicScansOnSQL.yaml', 'VirtualMachinesUtilizingManagedDisks.yaml', 'VMHasBackUpMachine.yaml']
2023-03-31 09:01:10,781 [MainThread  ] [DEBUG]  Searching through [] and ['CloudFunctionSecureHTTPTrigger.yaml', 'DisableAccessToSqlDBInstanceForRootUsersWithoutPassword.yaml', 'GCPAuditLogsConfiguredForAllServicesAndUsers.yaml', 'GCPComputeFirewallOverlyPermissiveToAllTraffic.yaml', 'GCPContainerRegistryReposAreNotPubliclyAccessible.yaml', 'GCPdisableAlphaClusterFeatureInKubernetesEngineClusters.yaml', 'GCPKMSCryptoKeysAreNotPubliclyAccessible.yaml', 'GCPKMSKeyRingsAreNotPubliclyAccessible.yaml', 'GCPLogBucketsConfiguredUsingLock.yaml', 'GCPMySQLdbInstancePoint_In_TimeRecoveryBackupIsEnabled.yaml', 'GCPNetworkDoesNotUseDefaultFirewall.yaml', 'GCPPostgreSQLDatabaseFlaglog_durationIsSetToON.yaml', 'GCPPostgreSQLDatabaseFlaglog_executor_statsIsSetToOFF.yaml', 'GCPPostgreSQLDatabaseFlaglog_parser_statsIsSetToOFF.yaml', 'GCPPostgreSQLDatabaseFlaglog_planner_statsIsSetToOFF.yaml', 'GCPPostgreSQLDatabaseFlaglog_statement_statsIsSetToOFF.yaml', 'GCPProjectHasNoLegacyNetworks.yaml', 'GCRContainerVulnerabilityScanningEnabled.yaml', 'GKEClustersAreNotUsingDefaultServiceAccount.yaml', 'ServiceAccountHasGCPmanagedKey.yaml']
2023-03-31 09:01:10,884 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:10,884 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/cloudformation/checks/graph_checks
2023-03-31 09:01:10,888 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['__init__.py']
2023-03-31 09:01:10,889 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:10,889 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/kubernetes/checks/graph_checks
2023-03-31 09:01:10,890 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['ImpersonatePermissions.yaml', 'ModifyServicesStatus.yaml', 'NoCreateNodesProxyOrPodsExec.yaml', 'ReadAllSecrets.yaml', 'RequireAllPodsToHaveNetworkPolicy.yaml', 'RoleBindingPE.yaml', '__init__.py']
2023-03-31 09:01:10,942 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:10,943 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/bicep/checks/graph_checks
2023-03-31 09:01:10,947 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['SQLServerAuditingEnabled.yaml', '__init__.py']
2023-03-31 09:01:10,959 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:10,961 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/terraform_plan/checks/graph_checks
2023-03-31 09:01:10,967 [MainThread  ] [DEBUG]  Running without API key, so only open source runners will be enabled
2023-03-31 09:01:10,967 [MainThread  ] [DEBUG]  Filtered list of policies: []
2023-03-31 09:01:10,968 [MainThread  ] [DEBUG]  Received the following policy-level suppressions, that will be skipped from running: []
2023-03-31 09:01:10,968 [MainThread  ] [DEBUG]  Filtered runners based on file type(s). Result: ['kubernetes']
2023-03-31 09:01:10,969 [MainThread  ] [DEBUG]  Checking if kubernetes is valid for license
2023-03-31 09:01:10,969 [MainThread  ] [DEBUG]  Open source mode - the runner is enabled
2023-03-31 09:01:10,969 [MainThread  ] [INFO ]  [_run_function_multithreaded] starting with 8 workers
2023-03-31 09:01:10,985 [MainThread  ] [INFO ]  creating Kubernetes graph
2023-03-31 09:01:10,986 [MainThread  ] [INFO ]  Successfully created Kubernetes graph
2023-03-31 09:01:10,986 [MainThread  ] [DEBUG]  Loading external checks from C:\Users\user\AppData\Roaming\Python\Python39\site-packages\checkov/kubernetes/checks/graph_checks
2023-03-31 09:01:10,987 [MainThread  ] [DEBUG]  Searching through ['__pycache__'] and ['ImpersonatePermissions.yaml', 'ModifyServicesStatus.yaml', 'NoCreateNodesProxyOrPodsExec.yaml', 'ReadAllSecrets.yaml', 'RequireAllPodsToHaveNetworkPolicy.yaml', 'RoleBindingPE.yaml', '__init__.py']
2023-03-31 09:01:11,045 [MainThread  ] [DEBUG]  Searching through [] and ['__init__.cpython-39.pyc']
2023-03-31 09:01:11,045 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,049 [MainThread  ] [DEBUG]  bc_check_id = BC_K8S_117, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,049 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_3: True
2023-03-31 09:01:11,050 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,050 [MainThread  ] [DEBUG]  bc_check_id = BC_K8S_118, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,051 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_4: True
2023-03-31 09:01:11,051 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,051 [MainThread  ] [DEBUG]  bc_check_id = BC_K8S_116, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,052 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_2: True
2023-03-31 09:01:11,052 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,052 [MainThread  ] [DEBUG]  bc_check_id = BC_K8S_119, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,053 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_5: True
2023-03-31 09:01:11,053 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,053 [MainThread  ] [DEBUG]  bc_check_id = None, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,054 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_6: True
2023-03-31 09:01:11,055 [MainThread  ] [DEBUG]  skip_severity = None, explicit_skip = [], regex_match = False, suppressed_policies: []
2023-03-31 09:01:11,055 [MainThread  ] [DEBUG]  bc_check_id = BC_K8S_115, include_all_checkov_policies = True, is_external = False, explicit_run: []
2023-03-31 09:01:11,056 [MainThread  ] [DEBUG]  should_run_check CKV2_K8S_1: True
2023-03-31 09:01:11,056 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_3
2023-03-31 09:01:11,061 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_4
2023-03-31 09:01:11,062 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_2
2023-03-31 09:01:11,062 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_5
2023-03-31 09:01:11,063 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_6
2023-03-31 09:01:11,063 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_K8S_1
2023-03-31 09:01:11,065 [MainThread  ] [DEBUG]  Getting exit code for report kubernetes
2023-03-31 09:01:11,066 [MainThread  ] [DEBUG]  Soft fail severity threshold: None
2023-03-31 09:01:11,066 [MainThread  ] [DEBUG]  Soft fail checks: []
2023-03-31 09:01:11,066 [MainThread  ] [DEBUG]  Hard fail severity threshold: None
2023-03-31 09:01:11,067 [MainThread  ] [DEBUG]  Hard fail checks: []
2023-03-31 09:01:11,067 [MainThread  ] [DEBUG]  Use enforcement rules is FALSE
2023-03-31 09:01:11,068 [MainThread  ] [DEBUG]  In get_exit_code; exit code thresholds: {'soft_fail': False, 'soft_fail_checks': [], 'soft_fail_threshold': None, 'hard_fail_checks': [], 'hard_fail_threshold': None}, hard_fail_on_parsing_errors: False
2023-03-31 09:01:11,068 [MainThread  ] [DEBUG]  No failed checks in this report - returning 0

       _               _
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V /
  \___|_| |_|\___|\___|_|\_\___/ \_/

By bridgecrew.io | version: 2.3.141

```



Discussion:
I've looked a bit around in the code and saw that [you use `charset_normalizer` to read the files](https://github.com/bridgecrewio/checkov/blob/a0eb392814f9013e85243fa804e51362cae82bf6/checkov/cloudformation/parser/cfn_yaml.py#L251), but that seems to work as expected on my end:

```
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from charset_normalizer import from_path
>>> str(from_path(r"H:/k8sexamples/copy-utf-8-bom.yaml").best())
"apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1\r\nkind: Deployment\r\nmetadata:\r\n  name: frontend\r\nspec:\r\n  selector:\r\n    matchLabels:\r\n      app: guestbook\r\n      tier: frontend\r\n  replicas: 3\r\n  template:\r\n    metadata:\r\n      labels:\r\n        app: guestbook\r\n        tier: frontend\r\n    spec:\r\n      containers:\r\n      - name: php-redis\r\n        image: gcr.io/google-samples/gb-frontend:v4\r\n        resources:\r\n          requests:\r\n            cpu: 100m\r\n            memory: 100Mi\r\n        env:\r\n        - name: GET_HOSTS_FROM\r\n          value: dns\r\n          # If your cluster config does not include a dns service, then to\r\n          # instead access environment variables to find service host\r\n          # info, comment out the 'value: dns' line above, and uncomment the\r\n          # line below:\r\n          # value: env\r\n        ports:\r\n        - containerPort: 80\r\n"
```
The problem might be in [`checkov.common.parsers.yaml.loaders.py`](https://github.com/bridgecrewio/checkov/blob/a0eb392814f9013e85243fa804e51362cae82bf6/checkov/common/parsers/yaml/loader.py)

Executing the load function on the BOM encoded file doesn't parse the BOM correctly:

```
>>> load("H:/k8sexamples/copy-utf-8-bom.yaml")
([{'ï»¿apiVersion': ...
```

---

Edit

Bingo!  
Adding the encoding to `file_path.read_text` on line 35 fixes the load function:

```python
content = file_path.read_text(encoding="utf-8-sig")
```

Parsing the file through ./Checkov still doesn't work though.
I was close, the problem was in the [Kubernetes parser](https://github.com/bridgecrewio/checkov/blob/40f5920217f6200cc36bc4dba8c08f5af4ae6d26/checkov/kubernetes/parser/k8_yaml.py#L34)

Adding the encoding there as described above fixes the issue for me.
hey @jurgyy thanks for reaching out.
Great investigation 💪 I can see we didn't add our typical approach on handling encoding issues. I will create a PR to fix it.

Resolving patch:
diff --git a/checkov/kubernetes/parser/k8_json.py b/checkov/kubernetes/parser/k8_json.py
--- a/checkov/kubernetes/parser/k8_json.py
+++ b/checkov/kubernetes/parser/k8_json.py
@@ -1,15 +1,19 @@
 from __future__ import annotations
 
+import logging
 from collections.abc import Hashable
 from pathlib import Path
 from typing import Tuple, Dict, Any, List, TYPE_CHECKING
 
 import yaml
+from charset_normalizer import from_path
 from yaml.loader import SafeLoader
 
 if TYPE_CHECKING:
     from yaml import MappingNode
 
+logger = logging.getLogger(__name__)
+
 
 def loads(content: str) -> list[dict[str, Any]]:
     """
@@ -35,7 +39,12 @@ def load(filename: Path) -> Tuple[List[Dict[str, Any]], List[Tuple[int, str]]]:
     """
 
     file_path = filename if isinstance(filename, Path) else Path(filename)
-    content = file_path.read_text()
+
+    try:
+        content = file_path.read_text()
+    except UnicodeDecodeError:
+        logger.debug(f"Encoding for file {file_path} is not UTF-8, trying to detect it")
+        content = str(from_path(file_path).best())
 
     if not all(key in content for key in ("apiVersion", "kind")):
         return [{}], []
diff --git a/checkov/kubernetes/parser/k8_yaml.py b/checkov/kubernetes/parser/k8_yaml.py
--- a/checkov/kubernetes/parser/k8_yaml.py
+++ b/checkov/kubernetes/parser/k8_yaml.py
@@ -1,15 +1,19 @@
 from __future__ import annotations
 
+import logging
 from collections.abc import Hashable
 from pathlib import Path
 from typing import List, Dict, Any, Tuple, TYPE_CHECKING
 
 import yaml
+from charset_normalizer import from_path
 from yaml.loader import SafeLoader
 
 if TYPE_CHECKING:
     from yaml import MappingNode
 
+logger = logging.getLogger(__name__)
+
 
 def loads(content: str) -> List[Dict[str, Any]]:
     """
@@ -31,7 +35,12 @@ def load(filename: Path) -> Tuple[List[Dict[str, Any]], List[Tuple[int, str]]]:
     """
 
     file_path = filename if isinstance(filename, Path) else Path(filename)
-    content = file_path.read_text()
+
+    try:
+        content = file_path.read_text()
+    except UnicodeDecodeError:
+        logging.debug(f"Encoding for file {file_path} is not UTF-8, trying to detect it")
+        content = str(from_path(file_path).best())
 
     if not all(key in content for key in ("apiVersion", "kind")):
         return [{}], []


Test patch:
diff --git a/tests/kubernetes/parser/examples/yaml/busybox_utf8_bom.yaml b/tests/kubernetes/parser/examples/yaml/busybox_utf8_bom.yaml
new file mode 100644
--- /dev/null
+++ b/tests/kubernetes/parser/examples/yaml/busybox_utf8_bom.yaml
@@ -0,0 +1,28 @@
+﻿apiVersion: v1
+kind: Pod
+metadata:
+  labels: 
+    test: liveness
+  name: liveness-exec
+spec: 
+  containers: 
+  - name: liveness
+    image: k8s.gcr.io/busybox
+    args:
+    - /bin/sh
+    - -c 
+    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
+    livenessProbe: 
+      exec: 
+        command:
+        - cat
+        - /tmp/healthy
+      initialDelaySeconds: 5
+      periodSeconds: 5
+    readinessProbe:
+      exec:
+        command:
+        - cat 
+        - /tmp/healthy
+      initialDelaySeconds: 5
+      periodSeconds: 5
diff --git a/tests/kubernetes/parser/test_k8_yaml.py b/tests/kubernetes/parser/test_k8_yaml.py
--- a/tests/kubernetes/parser/test_k8_yaml.py
+++ b/tests/kubernetes/parser/test_k8_yaml.py
@@ -3,10 +3,10 @@
 
 from checkov.kubernetes.parser.k8_yaml import load
 
-
 EXAMPLES_DIR = Path(__file__).parent / "examples"
-class TestScannerRegistry(unittest.TestCase):
 
+
+class TestScannerRegistry(unittest.TestCase):
     def test_load_pod(self):
         # given
         file_path = EXAMPLES_DIR / "yaml/busybox.yaml"
@@ -54,6 +54,20 @@ def test_load_helm_vars_file(self):
         # then
         assert template == [{}]
         assert file_lines == []
-        
+
+    def test_load_utf8_bom_file(self):
+        # given
+        file_path = EXAMPLES_DIR / "yaml/busybox_utf8_bom.yaml"
+
+        # when
+        template, file_lines = load(file_path)
+
+        # then
+        assert len(template) == 1
+        assert template[0]["apiVersion"] == "v1"
+        assert template[0]["kind"] == "Pod"
+        assert len(file_lines) == 28
+
+
 if __name__ == '__main__':
     unittest.main()