From c0cf4dae503dac35e822e384131ed47a34646c18 Mon Sep 17 00:00:00 2001 From: Fawwaz Anugrah Wiradhika Dharmasatya <13520086.std.stei.itb.ac.id> Date: Fri, 7 Jun 2024 14:17:29 +0700 Subject: [PATCH] feat: support execution in linux --- README.md | 2 +- src/lib/FileReader.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39fa515..9bbe6fc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ cd src/lib ./src/lib/joern/joern --script src/lib/scripts/gen_cfg.sc --param """codeFiles=FileParser.py""" ``` ## Note -For now only work on Linux (Windows command is mucho different) +For now only testes in windows and linux Regex to find uncommented print statement ```sh diff --git a/src/lib/FileReader.py b/src/lib/FileReader.py index e8bc733..a216f1c 100644 --- a/src/lib/FileReader.py +++ b/src/lib/FileReader.py @@ -4,6 +4,7 @@ from lib.utils import format_log from typing import Optional from lib.CFGGenerator import CFGGenerator,CFG from lib.custom_class import ElementContext +from sys import platform class FileReader: ANNOTATION_PATTERN = "\S*@.+" def __init__(self, project_path:str)->None: @@ -152,7 +153,11 @@ class FileReader: for root, dirs, files in os.walk(self.project_path): for file in files: if(self.is_source_code_supported(file)): - file_list.append(f"{root}\\{file}") + if platform.startswith("win"): + # Windows use \ to separate + file_list.append(f"{root}\\{file}") + else: + file_list.append(f"{root}/{file}") return file_list def is_source_code_supported(self,filename:str)->bool: -- GitLab