Skip to content

Commit

Permalink
fix(helm): Remove helm target dir after scanning (#6767)
Browse files Browse the repository at this point in the history
* remove helm target dir after scanning

* blank line at the end of file
  • Loading branch information
rotemavni authored Oct 14, 2024
1 parent 12d48f9 commit f2527ce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions checkov/helm/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
import logging
import os
import shutil
import subprocess # nosec
import tempfile
import threading
Expand Down Expand Up @@ -369,6 +370,12 @@ def convert_helm_to_k8s(
list(parallel_runner.run_function(func=Runner._convert_chart_to_k8s, items=chart_items))
return Runner._get_processed_chart_dir_and_meta(chart_dir_and_meta, self.root_folder)

def remove_target_folder(self) -> None:
try:
shutil.rmtree(self.target_folder_path) # delete directory
except OSError as exc:
logging.debug("failed to remove helm target folder path", exc_info=exc)

def run(
self,
root_folder: str | None,
Expand All @@ -387,6 +394,7 @@ def run(
k8s_runner.tmp_root_dir = self.get_k8s_target_folder_path()
report = k8s_runner.run(self.get_k8s_target_folder_path(), external_checks_dir=external_checks_dir, runner_filter=runner_filter)
self.graph_manager = k8s_runner.graph_manager
self.remove_target_folder()
return report


Expand Down

0 comments on commit f2527ce

Please sign in to comment.