Skip to content

Commit cf3e8d1

Browse files
authored
Merge pull request #24 from GitHubSecurityLab/fix_cases
use lower cases for various file viewers
2 parents fb9c498 + a34aa0e commit cf3e8d1

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/seclab_taskflows/mcp_servers/gh_file_viewer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ async def fetch_file_from_gh(
126126
"""
127127
Fetch the content of a file from a GitHub repository.
128128
"""
129+
owner = owner.lower()
130+
repo = repo.lower()
131+
129132
r = await call_api(
130133
url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}",
131134
params={}
@@ -146,6 +149,9 @@ async def get_file_lines_from_gh(
146149
length: int = Field(description="The ending line number to fetch from the file", default=10)) -> str:
147150
"""Fetch a range of lines from a file in a GitHub repository.
148151
"""
152+
owner = owner.lower()
153+
repo = repo.lower()
154+
149155
r = await call_api(
150156
url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}",
151157
params={}
@@ -171,6 +177,9 @@ async def search_file_from_gh(
171177
"""
172178
Search for a term in a file from a GitHub repository.
173179
"""
180+
owner = owner.lower()
181+
repo = repo.lower()
182+
174183
r = await call_api(
175184
url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}",
176185
params={}
@@ -193,6 +202,9 @@ async def search_files_from_gh(
193202
"""
194203
Search for a term in a list of files from a GitHub repository.
195204
"""
205+
owner = owner.lower()
206+
repo = repo.lower()
207+
196208
paths_list = [path.strip() for path in paths.split(',')]
197209
if not paths_list:
198210
return "No paths provided for search."
@@ -238,6 +250,9 @@ async def list_directory_from_gh(
238250
"""
239251
Fetch the content of a directory from a GitHub repository.
240252
"""
253+
owner = owner.lower()
254+
repo = repo.lower()
255+
241256
r = await call_api(
242257
url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}",
243258
params={}
@@ -259,6 +274,9 @@ async def search_repo_from_gh(
259274
"""
260275
Search for the search term in the entire repository.
261276
"""
277+
owner = owner.lower()
278+
repo = repo.lower()
279+
262280
with tempfile.TemporaryDirectory() as tmp_dir:
263281
result = await _fetch_source_zip(owner, repo, tmp_dir)
264282
source_path = Path(f"{tmp_dir}/{owner}/{repo}.zip")

src/seclab_taskflows/mcp_servers/local_file_viewer.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ async def fetch_file_content(
111111
"""
112112
Fetch the content of a file from a local GitHub repository.
113113
"""
114+
owner = owner.lower()
115+
repo = repo.lower()
116+
114117
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
115118
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
116119
if not source_path or not source_path.exists():
@@ -133,6 +136,9 @@ async def get_file_lines(
133136
length: int = Field(description="The ending line number to fetch from the file", default=10)) -> str:
134137
"""Fetch a range of lines from a file in a local GitHub repository.
135138
"""
139+
owner = owner.lower()
140+
repo = repo.lower()
141+
136142
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
137143
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
138144
if not source_path or not source_path.exists():
@@ -155,6 +161,9 @@ async def list_files(
155161
"""
156162
Recursively list the files of a directory from a local GitHub repository.
157163
"""
164+
owner = owner.lower()
165+
repo = repo.lower()
166+
158167
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
159168
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
160169
if not source_path or not source_path.exists():
@@ -173,6 +182,9 @@ async def list_files_non_recursive(
173182
List the files of a directory from a local GitHub repository non-recursively.
174183
Subdirectories will be listed and indicated with a trailing slash.
175184
"""
185+
owner = owner.lower()
186+
repo = repo.lower()
187+
176188
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
177189
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
178190
if not source_path or not source_path.exists():
@@ -191,6 +203,9 @@ async def search_repo(
191203
"""
192204
Search for the search term in the repository or a subdirectory/file in the repository.
193205
"""
206+
owner = owner.lower()
207+
repo = repo.lower()
208+
194209
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
195210
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
196211
if not source_path or not source_path.exists():

src/seclab_taskflows/mcp_servers/local_gh_resources.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ async def fetch_repo_from_gh(
9595
"""
9696
Download the source code from GitHub to the local file system to speed up file search.
9797
"""
98+
owner = owner.lower()
99+
repo = repo.lower()
100+
98101
result = await _fetch_source_zip(owner, repo, LOCAL_GH_DIR)
99102
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
100103
if not source_path.exists():
@@ -106,6 +109,9 @@ async def clear_local_repo(owner: str, repo: str):
106109
"""
107110
Delete the local repo.
108111
"""
112+
owner = owner.lower()
113+
repo = repo.lower()
114+
109115
source_path = Path(f"{LOCAL_GH_DIR}/{owner}/{repo}.zip")
110116
source_path = sanitize_file_path(source_path, [LOCAL_GH_DIR])
111117
if not source_path:

0 commit comments

Comments
 (0)