Skip to content

Commit

Permalink
fix(circleci): fix executors in resource_id (#4008)
Browse files Browse the repository at this point in the history
fix executors in resource_id
  • Loading branch information
marynaKK authored Dec 7, 2022
1 parent 5043e44 commit 090ca11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 090ca11

Please sign in to comment.