Skip to content

Commit 896a25a

Browse files
committed
fixed bug for things like reading whole modules of context code
1 parent ea710ad commit 896a25a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,4 @@ cython_debug/
165165

166166
# repos
167167
repos/
168+
.vscode/launch.json

Diff for: vulnhuntr/symbol_finder.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,13 @@ def _search_string_in_file(self, file_path, string):
226226
file.read().replace(' ', '').replace('\n', '').replace('"', "'").replace('\r', '').replace('\t', '')
227227

228228
def _get_definition_source(self, file_path: pathlib.Path, start, end):
229-
if not start or not end:
230-
return
231-
232229
with file_path.open(encoding='utf-8') as f:
233230
lines = f.readlines()
234231

232+
if not start and not end:
233+
s = ''.join(lines)
234+
return s
235+
235236
definition = lines[ start[0]-1:end[0] ]
236237
end_len_diff = len(definition[-1]) - end[1]
237238

@@ -248,9 +249,11 @@ def _create_match_obj(self, name: Name, symbol_name: str) -> Dict[str, Any]:
248249
# Extract the third party library name
249250
source = f'Third party library. Claude, use what you already know about {name.full_name} to understand the code.'
250251
else:
252+
start = name.get_definition_start_position()
253+
end = name.get_definition_end_position()
251254
source = self._get_definition_source(name.module_path,
252-
name.get_definition_start_position(),
253-
name.get_definition_end_position()
255+
start,
256+
end
254257
)
255258

256259
return {'name': name.name,

0 commit comments

Comments
 (0)