Skip to content

Commit

Permalink
webapp: routes: include light-only searching for source code APIs (#1797
Browse files Browse the repository at this point in the history
)

* webapp: routes: include light-only searching for source code APIs

Signed-off-by: David Korczynski <[email protected]>

* nit

Signed-off-by: David Korczynski <[email protected]>

* nit

Signed-off-by: David Korczynski <[email protected]>

---------

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Oct 23, 2024
1 parent a7616d9 commit 8c55ed6
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tools/web-fuzzing-introspection/app/webapp/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
allow_shutdown = False
local_oss_fuzz = ''

NO_KEY_MSG = '<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.'

# Add functions in here to make the oracles focus on a specific API.
ALLOWED_ORACLE_RETURNS: List[str] = []

Expand Down Expand Up @@ -1499,7 +1501,10 @@ def api_project_source_code():

latest_introspector_datestr = get_latest_introspector_date(project_name)
if not latest_introspector_datestr:
return {'result': 'error', 'msg': 'No introspector builds.'}
# Backup to capture simply the latest build.
for ps in data_storage.PROJECT_TIMESTAMPS:
if ps.project_name == project_name:
latest_introspector_datestr = ps.date

source_code = extract_lines_from_source_code(project_name,
latest_introspector_datestr,
Expand Down Expand Up @@ -1554,11 +1559,22 @@ def api_project_test_code():
latest_introspector_datestr = get_latest_introspector_date(
project_name)
if not latest_introspector_datestr:
return {'result': 'error', 'msg': 'No introspector builds.'}

for ps in data_storage.PROJECT_TIMESTAMPS:
if ps.project_name == project_name:
latest_introspector_datestr = ps.date
source_code = extract_lines_from_source_code(
project_name, latest_introspector_datestr, filepath, 0, 100000)

# If an error happened, try the latest one.
if source_code and NO_KEY_MSG in source_code:
new_datestr = ''
for ps in data_storage.PROJECT_TIMESTAMPS:
if ps.project_name == project_name:
new_datestr = ps.date
if new_datestr and new_datestr != latest_introspector_datestr:
source_code = extract_lines_from_source_code(
project_name, new_datestr, filepath, 0, 100000)

if source_code is None:
return {'result': 'error', 'msg': 'no source code'}

Expand Down

0 comments on commit 8c55ed6

Please sign in to comment.