Browse Source

文件后缀白名单

fulian23 4 months ago
parent
commit
14611eea44
1 changed files with 15 additions and 2 deletions
  1. 15 2
      api/aiRouter.py

+ 15 - 2
api/aiRouter.py

@@ -9,7 +9,6 @@ from http import HTTPStatus
 from dashscope import Application
 from dashscope import Application
 
 
 from models.aiModels import Scan_Tasks, Commit_Summary_Tasks, File_Summary_Tasks
 from models.aiModels import Scan_Tasks, Commit_Summary_Tasks, File_Summary_Tasks
-from models.gitModels import Repos
 
 
 airouter = APIRouter()
 airouter = APIRouter()
 class RequestCommit(BaseModel):
 class RequestCommit(BaseModel):
@@ -170,7 +169,21 @@ async def process_batch2(local_path,path):
 
 
 async def analysis(local_path, task_id):
 async def analysis(local_path, task_id):
     file_list = await get_code_files(local_path)
     file_list = await get_code_files(local_path)
-    print(file_list)
+    all_extensions = [
+         "adoc", "asm", "awk", "bas", "bat", "bib", "c", "cbl", "cls", "clj",
+        "cljc", "cljs", "cmd", "conf", "cpp", "cr", "cs", "css", "cxx", "dart",
+        "dockerfile", "edn", "el", "env", "erl", "ex", "exs", "f", "f90", "f95",
+        "fs", "fsscript", "fsi", "fsx", "g4", "gd", "gql", "graphql", "groovy",
+        "gsh", "gvy", "h", "hbs", "hcl", "hh", "hl", "hpp", "hrl", "hs", "htm",
+        "html", "hx", "ini", "jad", "jade", "java", "jl", "js", "json", "json5",
+        "jsx", "kt", "kts", "less", "lfe", "lgt", "lhs", "log", "ltx", "lua",
+        "m", "mjs", "ml", "mli", "mm", "nim", "nims", "nlogo", "pas", "php",
+        "pl", "plantuml", "pro", "ps1", "pug", "puml", "py", "qml", "r", "rb",
+        "re", "rei", "res", "resi", "rkt", "rs", "rst", "s", "sass", "scala",
+        "scm", "scss", "sed", "sh", "sol", "sql", "ss", "st", "squeak", "swift",
+        "tcl", "tex", "tf", "tfvars", "toml", "ts", "tsx", "txt", "v", "vb",
+        "vbs", "vh", "vhd", "vhdl", "vim", "vue", "xml", "yaml", "yang", "yml"]
+    file_list = [file for file in file_list if file.split(".")[-1]  in all_extensions]
     results = []
     results = []
     tasks = [process_batch2(local_path, file) for file in file_list]
     tasks = [process_batch2(local_path, file) for file in file_list]
     batch_results = await asyncio.gather(*tasks, return_exceptions=True)
     batch_results = await asyncio.gather(*tasks, return_exceptions=True)