diff --git a/checkov/circleci_pipelines/runner.py b/checkov/circleci_pipelines/runner.py index 25cb243dd31..6ba1a66dd3a 100644 --- a/checkov/circleci_pipelines/runner.py +++ b/checkov/circleci_pipelines/runner.py @@ -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 diff --git a/tests/circleci_pipelines/image_referencer/test_provider.py b/tests/circleci_pipelines/image_referencer/test_provider.py index f022c12334a..4f342a9000b 100644 --- a/tests/circleci_pipelines/image_referencer/test_provider.py +++ b/tests/circleci_pipelines/image_referencer/test_provider.py @@ -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,