diff --git a/src/verinfast/agent.py b/src/verinfast/agent.py index 2949482..78ed287 100755 --- a/src/verinfast/agent.py +++ b/src/verinfast/agent.py @@ -458,9 +458,16 @@ def parseRepo(self, path: str, repo_name: str, branch: str = None): ] findings_success = False + if not self.config.dry: + self.log(msg=repo_name, tag="Scanning repository", display=True) try: with contextlib.redirect_stdout(io.StringIO()): - semgrep_scan.scan(custom_args) + if not self.config.dry: + semgrep_scan.scan(custom_args) + if os.path.exists(findings_file): + with open(findings_file) as f: + results = json.load(f) + self.cache.set(findings_file, results) findings_success = True except SystemExit as e: if e.code == 0: @@ -597,7 +604,7 @@ def preflight(self): else: repo_name = repo_url.rsplit('/', 1)[-1] if "@" in repo_name and re.search(r"^.*@.*\..*:", repo_url): - repo_url = "@".join(repo_url.split("@")[0:2]) + repo_url = "@".join(repo_url.split("@")[0:2]) elif "@" in repo_name: repo_url = repo_url.split("@")[0] try: @@ -620,7 +627,7 @@ def preflight(self): if cloud_config is not None: for provider in cloud_config: try: - if (provider.provider == "aws" and + if (provider.provider == "aws" and self.checkDependency("aws", "AWS Command-line tool")): account_id = str(provider.account).replace('-', '') if find_profile(account_id, self.log) is None: diff --git a/tests/test_dry.py b/tests/test_dry.py index e6fc757..2e08c87 100644 --- a/tests/test_dry.py +++ b/tests/test_dry.py @@ -37,8 +37,13 @@ def test_no_config(self): assert get_url == "/report/uuid/9a6e8696-f93a-4402-a64e-342ccb37592b/CorsisCode", get_url # noqa: E501 agent.scan() assert Path(results_dir).exists() - files = os.listdir(results_dir) - assert len(files) == 1 + # Make sure there are no .json results files + results_path = Path(results_dir) + assert results_path.exists() + + # Check if there are any JSON files + json_files = list(results_path.glob("*.json")) + assert not json_files, f"Found JSON files: {json_files}" with open(agent.debug.file) as f: logText = f.read() assert "Error" not in logText