diff --git a/py/plugins/semgrep.py b/py/plugins/semgrep.py index fc7812a..05aec11 100644 --- a/py/plugins/semgrep.py +++ b/py/plugins/semgrep.py @@ -143,14 +143,9 @@ def scan_hook(results, mock, props): semgrep_prefix = f"env PATH={semgrep_lib_dir}/bin:$PATH PYTHONPATH={semgrep_lib_dir}" # assuming semgrep rules are located under the 'rules' directory semgrep_rules_dir = os.path.join(results.tmpdir, "semgrep_rules/rules") - # get the chroot root path - ec, output = results.get_cmd_output(mock.get_mock_cmd(["--print-root-path"]), shell=False) - if ec != 0: - results.error("semgrep: failed to get chroot root path", ec=ec) - chroot_root_path = output.rstrip("/\n") # write the chroot root path to the SEMGREP_SCAN_CHROOT_ROOT_PATH - with open(f"{chroot_root_path}{SEMGREP_SCAN_CHROOT_ROOT_PATH}", "w", encoding="utf-8") as f: - f.write(chroot_root_path) + with open(f"{mock.mock_root}{SEMGREP_SCAN_CHROOT_ROOT_PATH}", "w", encoding="utf-8") as f: + f.write(mock.mock_root) # command to run semgrep scan semgrep_scan_cmd = semgrep_prefix + ( @@ -166,8 +161,8 @@ def scan_hook(results, mock, props): # eventually append the target directory to be scanned semgrep_scan_cmd += ( - f" --output={chroot_root_path}{SEMGREP_SCAN_OUTPUT} {chroot_root_path}{SEMGREP_SCAN_DIR}" - f" 2>{chroot_root_path}{SEMGREP_SCAN_LOG}" + f" --output={mock.mock_root}{SEMGREP_SCAN_OUTPUT} {mock.mock_root}{SEMGREP_SCAN_DIR}" + f" 2>{mock.mock_root}{SEMGREP_SCAN_LOG}" ) # run semgrep scan ec = results.exec_cmd(semgrep_scan_cmd, shell=True)