Skip to content

Commit 2b50b82

Browse files
Automatically install Python QL pack
1 parent 5be4848 commit 2b50b82

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/seclab_taskflows/mcp_servers/codeql_python/mcp_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import json
2121
from sqlalchemy import create_engine
2222
from sqlalchemy.orm import Session
23+
import subprocess
24+
import importlib.resources
2325

2426
from .codeql_sqlite_models import Base, Source
2527
from ..utils import process_repo
@@ -211,4 +213,9 @@ def clear_codeql_repo(owner: str, repo: str):
211213
return f"Cleared {deleted_sources} sources from repo {repo}."
212214

213215
if __name__ == "__main__":
216+
# Check if codeql/python-all pack is installed, if not install it
217+
if not os.path.isdir('/.codeql/packages/codeql/python-all'):
218+
pack_path = importlib.resources.files('seclab_taskflows.mcp_servers.codeql_python.queries').joinpath('mcp-python')
219+
print(f"Installing CodeQL pack from {pack_path}")
220+
subprocess.run(["codeql", "pack", "install", pack_path])
214221
mcp.run(show_banner=False, transport="http", host="127.0.0.1", port=9998)

src/seclab_taskflows/taskflows/audit/remote_sources_local.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ taskflow:
3333
toolboxes:
3434
- seclab_taskflows.toolboxes.gh_code_scanning
3535
- seclab_taskflows.toolboxes.codeql_python
36+
- task:
37+
must_complete: true
38+
exclude_from_context: true
39+
model: general_tasks
40+
agents:
41+
- seclab_taskflow_agent.personalities.assistant
42+
user_prompt: |
43+
Fetch the zipball of the repository {{ GLOBALS_repo }}.
44+
toolboxes:
45+
- seclab_taskflows.toolboxes.local_gh_resources
3646
- task:
3747
must_complete: true
3848
exclude_from_context: true
@@ -53,7 +63,6 @@ taskflow:
5363
agents:
5464
- seclab_taskflows.personalities.auditor
5565
user_prompt: |
56-
Fetch the zipball of the repository {{ GLOBALS_repo }} and use it to analyze the source.
5766
The source is a {{ RESULT_type }} in {{ RESULT_repo }} in the location {{ RESULT_source_location }} on line {{ RESULT_line }}.
5867
If the source is in a folder relating to tests or demo code, skip the analysis and update the source entry in the codeql_sqlite database indicating it is not relevant.
5968
Analyze what the source endpoint is used for.
@@ -75,12 +84,11 @@ taskflow:
7584
the error you encountered.
7685
toolboxes:
7786
- seclab_taskflows.toolboxes.codeql_python
78-
- seclab_taskflows.toolboxes.local_gh_resources
7987
- seclab_taskflows.toolboxes.local_file_viewer
8088
- task:
8189
must_complete: true
8290
agents:
83-
- seclab_taskflows.personalities.web_application_security_expert
91+
- seclab_taskflows.personalities.auditor
8492
model: code_analysis
8593
user_prompt: |
8694
Fetch the sources of the repo {{ GLOBALS_repo }} and give a summary of the notes.

0 commit comments

Comments
 (0)