从json文件中获取输入参数
(scan_files=None)
| 196 | |
| 197 | @staticmethod |
| 198 | def get_input_params(scan_files=None): |
| 199 | """ |
| 200 | 从json文件中获取输入参数 |
| 201 | """ |
| 202 | if scan_files: # 如果命令行指定了扫描文件路径,直接使用 |
| 203 | scan_rel_paths = [] |
| 204 | for rel_path in scan_files: |
| 205 | scan_rel_paths.append({ |
| 206 | "path": rel_path, |
| 207 | "type": "file" |
| 208 | }) |
| 209 | return { |
| 210 | "scan_path": scan_rel_paths |
| 211 | } |
| 212 | |
| 213 | params = {} |
| 214 | input_env_key = "TCA_QUICK_SCAN_INPUT" |
| 215 | input_file_env = os.getenv(input_env_key) |
| 216 | if input_file_env: |
| 217 | input_file_path = os.path.abspath(input_file_env) |
| 218 | if os.path.exists(input_file_path): |
| 219 | with open(input_file_path, "r") as rf: |
| 220 | params = json.load(rf) |
| 221 | else: |
| 222 | LogPrinter.warning(f"env {input_env_key} not exists, scan the source dir.") |
| 223 | # 未指定扫描路径,扫描整个代码仓库目录 |
| 224 | params = { |
| 225 | "scan_path": [ |
| 226 | { |
| 227 | "path": "", # 空字符串的目录,表示代码根目录 |
| 228 | "type": "dir" |
| 229 | } |
| 230 | ] |
| 231 | } |
| 232 | return params |
| 233 | |
| 234 | @staticmethod |
| 235 | def get_scan_paths(params, source_dir): |
no test coverage detected