From abe6ae26419ddf9c758f43ac40d00668e9ad0cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Gr=C3=BCbel?= Date: Tue, 18 Oct 2022 10:31:57 +0200 Subject: [PATCH] feat(kustomize): stop kustomize run, if there is nothing to process (#3681) * stop kustomize run, if there is nothing to process * remove pip upgrade --- .github/workflows/pr-test.yml | 1 - checkov/kustomize/runner.py | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 0cdaa9c5ec3..0a056ec7c50 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -99,7 +99,6 @@ jobs: - name: Build & install checkov package run: | pipenv --python ${{ matrix.python }} - pipenv run pip install --upgrade pip pipenv run pip install pytest pytest-xdist pipenv run python setup.py sdist bdist_wheel bash -c 'pipenv run pip install dist/checkov-*.whl' diff --git a/checkov/kustomize/runner.py b/checkov/kustomize/runner.py index 33bfc738609..089313e367e 100644 --- a/checkov/kustomize/runner.py +++ b/checkov/kustomize/runner.py @@ -421,6 +421,10 @@ def run_kustomize_to_k8s( self, root_folder: str | None, files: list[str] | None, runner_filter: RunnerFilter ) -> None: kustomize_dirs = find_kustomize_directories(root_folder, files, runner_filter.excluded_paths) + if not kustomize_dirs: + # nothing to process + return + for kustomize_dir in kustomize_dirs: self.kustomizeProcessedFolderAndMeta[kustomize_dir] = self._parseKustomization(kustomize_dir) self.target_folder_path = tempfile.mkdtemp() @@ -474,6 +478,11 @@ def run( self.run_kustomize_to_k8s(root_folder, files, runner_filter) report = Report(self.check_type) + + if not self.kustomizeProcessedFolderAndMeta: + # nothing to process + return report + target_dir = "" try: k8s_runner = K8sKustomizeRunner()