dense-analysis / dense-analysis/ale
checkov error: Key not present in Dictionary: "guideline"
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
## Information
**VIM version**
```
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 03 2021 13:17:57)
Included patches: 1-3455
```
Operating System: Debian 11
## What went wrong
When editing a `.tf` file with the following contents:
```
resource "aws_ecr_repository" "foo" {
name = "foo"
}
```
...an error periodically briefly flashes in vim:
```
Error detected while processing function 105_VimCloseCallback[11]..105_VimExitCallback[22]..function 105_VimCloseCallback[11]..105_VimExitCallback[15]..41[1]..103_ExitCallback[28]..102_HandleExit[24]..ale_linters#terraform#checkov#Handle:
line 6:
E716: Key not present in Dictionary: "guideline"
E116: Invalid arguments for function add
Error detected while processing function 105_VimCloseCallback:
line 11:
E171: Missing :endif
```
## Reproducing the bug
1. I edit a `.tf` file
2. The error above sporadically appears and quickly disappears, and Checkov hints aren't displayed.
If I delete `. l:violation['guideline']` from [this line in `~/.vim/bundle/ale/ale_linters/terraform/checkov.vim`](https://github.com/dense-analysis/ale/blob/091592bfb09e7e994bd860fa3776e8cf4346bf5a/ale_linters/terraform/checkov.vim#L27):
```
" \ 'For more information, see: '. l:violation['guideline'],
```
... then the error above does not appear, and Checkov hints are displayed as expected (e.g. `Ensure that ECR repositories are encrypted using KMS [CKV_AWS_136]`).
### :ALEInfo
```
Current Filetype: terraform
Available Linters: ['checkov', 'terraform', 'terraform_ls', 'terraform_lsp', 'tflint']
Enabled Linters: ['checkov', 'terraform', 'terraform_ls', 'terraform_lsp', 'tflint']
Ignored Linters: []
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'terraform' - Fix tf and hcl files with terraform fmt.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_terraform_checkov_executable = 'checkov'
let g:ale_terraform_checkov_options = ''
let g:ale_terraform_langserver_executable = 'terraform-lsp'
let g:ale_terraform_langserver_options = ''
let g:ale_terraform_ls_executable = 'terraform-ls'
let g:ale_terraform_ls_options = ''
let g:ale_terraform_terraform_executable = 'terraform'
let g:ale_terraform_tflint_executable = 'tflint'
let g:ale_terraform_tflint_options = ''
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let b:ale_fixers = ['prettier', 'eslint', 'autopep8', 'remark-lint', 'remove_trailing_lines']
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'typescript': ['eslint', 'tsserver', 'prettier'], 'javascript': ['eslint']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) checkov
(finished - exit code 1) ['/bin/bash', '-c', '''checkov'' -f ''/tmp/v8h5qIp/1/alerepro.tf'' -o json --quiet ']
<<>>
{
"check_type": "terraform",
"results": {
"failed_checks": [
{
"check_id": "CKV_AWS_163",
"bc_check_id": null,
"check_name": "Ensure ECR image scanning on push is enabled",
"check_result": {
"result": "FAILED",
"evaluated_keys": [
"image_scanning_configuration/[0]/scan_on_push"
]
},
"code_block": [
[
1,
"resource \"aws_ecr_repository\" \"foo\" {\n"
],
[
2,
" name = \"foo\"\n"
],
[
3,
"}\n"
]
],
"file_path": "/alerepro.tf",
"file_abs_path": "/tmp/v8h5qIp/1/alerepro.tf",
"repo_file_path": "/../../../../../../tmp/v8h5qIp/1/alerepro.tf",
"file_line_range": [
1,
3
],
"resource": "aws_ecr_repository.foo",
"evaluations": null,
"check_class": "checkov.terraform.checks.resource.aws.ECRImageScanning",
"fixed_definition": null,
"entity_tags": null,
"caller_file_path": null,
"caller_file_line_range": null
},
{
"check_id": "CKV_AWS_136",
"bc_check_id": null,
"check_name": "Ensure that ECR repositories are encrypted using KMS",
"check_result": {
"result": "FAILED",
"evaluated_keys": [
"encryption_configuration/[0]/encryption_type"
]
},
"code_block": [
[
1,
"resource \"aws_ecr_repository\" \"foo\" {\n"
],
[
2,
" name = \"foo\"\n"
],
[
3,
"}\n"
]
],
"file_path": "/alerepro.tf",
"file_abs_path": "/tmp/v8h5qIp/1/alerepro.tf",
"repo_file_path": "/../../../../../../tmp/v8h5qIp/1/alerepro.tf",
"file_line_range": [
1,
3
],
"resource": "aws_ecr_repository.foo",
"evaluations": null,
"check_class": "checkov.terraform.checks.resource.aws.ECRRepositoryEncrypted",
"fixed_definition": null,
"entity_tags": null,
"caller_file_path": null,
"caller_file_line_range": null
},
{
"check_id": "CKV_AWS_51",
"bc_check_id": null,
"check_name": "Ensure ECR Image Tags are immutable",
"check_result": {
"result": "FAILED",
"evaluated_keys": [
"image_tag_mutability"
]
},
"code_block": [
[
1,
"resource \"aws_ecr_repository\" \"foo\" {\n"
],
[
2,
" name = \"foo\"\n"
],
[
3,
"}\n"
]
],
"file_path": "/alerepro.tf",
"file_abs_path": "/tmp/v8h5qIp/1/alerepro.tf",
"repo_file_path": "/../../../../../../tmp/v8h5qIp/1/alerepro.tf",
"file_line_range": [
1,
3
],
"resource": "aws_ecr_repository.foo",
"evaluations": null,
"check_class": "checkov.terraform.checks.resource.aws.ECRImmutableTags",
"fixed_definition": null,
"entity_tags": null,
"caller_file_path": null,
"caller_file_line_range": null
}
]
},
"summary": {
"passed": 0,
"failed": 3,
"skipped": 0,
"parsing_errors": 0,
"resource_count": 1,
"checkov_version": "2.0.425"
}
}
<<>>
(executable check - success) terraform
(finished - exit code 0) ['/bin/bash', '-c', '''terraform'' validate -no-color -json < ''/tmp/v8h5qIp/2/alerepro.tf''']
<<>>
{
"format_version": "0.1",
"valid": true,
"error_count": 0,
"warning_count": 0,
"diagnostics": []
}
<<>>
(executable check - failure) terraform-ls
(executable check - failure) terraform-lsp
(executable check - success) tflint
(finished - exit code 2) ['/bin/bash', '-c', 'cd ''/home/aj/git/quantgene/infra/serenity-resources'' && ''tflint'' -f json < ''/tmp/v8h5qIp/4/alerepro.tf''']
<<>>
{"issues":[],"errors":[{"message":"Incompatible API version with plugin \"aws\". Plugin version: 8, TFLint versions: [9]"}]}
<<>>
```
Contributor guide
Assessment
This issue has not been assessed yet.