Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(circleci): fix executors in resource_id #4008

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkov/circleci_pipelines/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_resource(self, file_path: str, key: str, supported_entities: Iterable[st
new_key = f'jobs({job_name}).docker.image{image_name}' if job_name else "jobs"
elif 'executors.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}':
executor_name = self.resolve_sub_name(definition, start_line, end_line, tag='executors')
image_name = self.resolve_image_name(definition['jobs'].get(executor_name), start_line, end_line)
image_name = self.resolve_image_name(definition['executors'].get(executor_name), start_line, end_line)
new_key = f'executors({executor_name}).docker.image{image_name}' if executor_name else "executors"
return new_key

Expand Down
10 changes: 8 additions & 2 deletions tests/circleci_pipelines/image_referencer/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ def test_extract_images_from_workflow_no_images(circle_ci_filepath_workflow_no_i
(21,
22,
'jobs',
('jobs.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}',),
('jobs.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}',),
'jobs.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}.jobs.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}.CKV_CIRCLECIPIPELINES_1[85:86]',
"jobs(test-docker-versioned-img).docker.image[1](mongo:2.6.8)"),
],
(16,
18,
'executors',
('executors.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}',),
'executors.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}.executors.*.docker[].{image: image, __startline__: __startline__, __endline__:__endline__}.CKV_CIRCLECIPIPELINES_8[16:18]',
"executors(image-executor).docker.image[1](mongo:2.6.8)")
]
)
def test_generate_resource_key_generates_same_key_as_get_resource(file_path,
start_line, end_line, tag,
Expand Down