Skip to content

Commit

Permalink
Fix bugs, typing and formatting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan committed Jun 12, 2024
1 parent c932b9d commit 0d1beef
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tools/web-fuzzing-introspection/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def create_app():
if __name__ == "__main__":
create_app().run(debug=False,
host="0.0.0.0",
port=os.environ.get("WEBAPP_PORT", 8080))
port=int(os.environ.get("WEBAPP_PORT", '8080')))
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def extract_new_introspector_constructors(project_name, date_str):
# Read the introspector artifact
try:
raw_introspector_json_request = requests.get(
introspector_functions_url, timeout=10)
introspector_constructor_url, timeout=10)
introspector_constructors = json.loads(
raw_introspector_json_request.text)
except:
Expand Down
27 changes: 27 additions & 0 deletions tools/web-fuzzing-introspection/app/temp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/scripts/oss-fuzz-gen-e2e/build_all.sh b/scripts/oss-fuzz-gen-e2e/build_all.sh
index 6afbfcf..b135109 100755
--- a/scripts/oss-fuzz-gen-e2e/build_all.sh
+++ b/scripts/oss-fuzz-gen-e2e/build_all.sh
@@ -20,7 +20,7 @@ mkdir -p workdir
cd workdir
WORKDIR=$PWD

-python3.11 -m virtualenv .venv
+python3 -m virtualenv .venv
. .venv/bin/activate


diff --git a/tools/web-fuzzing-introspection/app/webapp/routes.py b/tools/web-fuzzing-introspection/app/webapp/routes.py
index 5f09b3f..77b444a 100644
--- a/tools/web-fuzzing-introspection/app/webapp/routes.py
+++ b/tools/web-fuzzing-introspection/app/webapp/routes.py
@@ -932,6 +932,9 @@ def _convert_function_return_list(project_functions):
function.return_type,
'runtime_coverage_percent':
function.runtime_code_coverage,
+ 'function_signature': function.func_signature,
+ 'source_line_begin': function.source_line_begin,
+ 'source_line_end': function.source_line_end,
})
return list_to_return

2 changes: 0 additions & 2 deletions tools/web-fuzzing-introspection/app/webapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def is_db_valid():
def load_db():
"""Loads the database"""
print("Loading db")
if not is_db_valid():
update_db()

db_timestamps_file = os.path.join(
os.path.dirname(__file__), "../static/assets/db/db-timestamps.json")
Expand Down
18 changes: 9 additions & 9 deletions tools/web-fuzzing-introspection/app/webapp/data_storage.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Auto-generated
#from app.site.models import *

from typing import List
from typing import List, Any

import os
import json

from .models import *

PROJECT_TIMESTAMPS = []
PROJECT_TIMESTAMPS: List[ProjectTimestamp] = []

DB_TIMESTAMPS = []
DB_TIMESTAMPS: List[DBTimestamp] = []

PROJECTS = []
PROJECTS: List[Project] = []

FUNCTIONS = []
FUNCTIONS: List[Function] = []

CONSTRUCTORS = []
CONSTRUCTORS: List[Function] = []

BLOCKERS = []
BLOCKERS: List[BranchBlocker] = []

BUILD_STATUS: List[BuildStatus] = []

PROJECT_DEBUG_DATA = []
PROJECT_DEBUG_DATA: List[DebugStatus] = []

ALL_HEADER_FILES = []
ALL_HEADER_FILES: List[Any] = []


def get_projects():
Expand Down
4 changes: 1 addition & 3 deletions tools/web-fuzzing-introspection/app/webapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ def __init__(self,
self.is_accessible = is_accessible
self.is_jvm_library = is_jvm_library
self.is_enum_class = is_enum_class

def __dict__(self):
return {
self.__dict__ = {
'function_name': self.name,
'function_arguments': self.function_arguments,
'project': self.project,
Expand Down
18 changes: 14 additions & 4 deletions tools/web-fuzzing-introspection/app/webapp/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,8 @@ def api_annotated_cfg():
'result': 'success',
'project': {
'name': project_name,
'annotated_cfg': project.introspector_data['annotated_cfg'],
'annotated_cfg':
target_project.introspector_data['annotated_cfg'],
}
}
except KeyError:
Expand All @@ -771,8 +772,8 @@ def api_project_summary():
'result': 'success',
'project': {
'name': project_name,
'runtime_coverage_data': project.coverage_data,
'introspector_data': project.introspector_data
'runtime_coverage_data': target_project.coverage_data,
'introspector_data': target_project.introspector_data
}
}

Expand Down Expand Up @@ -1300,6 +1301,16 @@ def far_reach_but_low_coverage():
err_msgs.append('No functions found.')
bs = get_build_status_of_project(project_name)

if bs == None:
return {
'result':
'error',
'extended_msgs': [
'Project not in OSS-Fuzz (likely only contains a project.yaml file).'
]
}
err_msgs.append('Missing a recent introspector build.')

# Check that builds are failing
if bs.introspector_build_status is False:
err_msgs.append('No successful build: introspector.')
Expand Down Expand Up @@ -1370,7 +1381,6 @@ def shutdown():
if is_local or allow_shutdown:
sig = getattr(signal, "SIGKILL", signal.SIGTERM)
os.kill(os.getpid(), sig)
shutdown_server()
return {'result': 'success', 'msg': 'shutdown'}
else:
return {'result': 'failed', 'msg': 'not a local server'}
Expand Down

0 comments on commit 0d1beef

Please sign in to comment.