Skip to content

webapp: Use recommended None checking method #1589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions tools/web-fuzzing-introspection/app/webapp/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_frontpage_summary_stats():
projects_to_use = []
# Only include fuzz introspector projects
#for project in all_projects:
# if project.introspector_data != None:
# if project.introspector_data is not None:
# projects_to_use.append(project)

total_number_of_projects = len(all_projects)
Expand Down Expand Up @@ -292,7 +292,7 @@ def project_profile():

project = get_project_with_name(target_project_name)

if project != None:
if project is not None:
# Get the build status of the project
all_build_status = data_storage.get_build_status()
project_build_status = None
Expand Down Expand Up @@ -322,7 +322,7 @@ def project_profile():

latest_coverage_report = get_coverage_report_url(
project.name, datestr, project_language)
if ps.introspector_data != None:
if ps.introspector_data is not None:
latest_fuzz_introspector_report = get_introspector_url(
project.name, datestr)
latest_introspector_datestr = datestr
Expand Down Expand Up @@ -390,7 +390,7 @@ def project_profile():
latest_coverage_report = get_coverage_report_url(
build_status.project_name, datestr,
build_status.language)
if ps.introspector_data != None:
if ps.introspector_data is not None:
latest_fuzz_introspector_report = get_introspector_url(
build_status.project_name, datestr)
latest_introspector_datestr = datestr
Expand Down Expand Up @@ -726,7 +726,7 @@ def api():
@blueprint.route('/api/annotated-cfg')
def api_annotated_cfg():
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide project name'}

target_project = None
Expand Down Expand Up @@ -756,7 +756,7 @@ def api_annotated_cfg():
@blueprint.route('/api/project-summary')
def api_project_summary():
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide project name'}
target_project = None
all_projects = data_storage.get_projects()
Expand All @@ -780,7 +780,7 @@ def api_project_summary():
@blueprint.route('/api/branch-blockers')
def branch_blockers():
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide project name'}

target_project = None
Expand Down Expand Up @@ -828,17 +828,17 @@ def get_function_from_func_signature(func_signature, project_name):
def api_cross_references():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}

function_signature = request.args.get('function_signature', None)
if function_signature == None:
if function_signature is None:
return {'result': 'error', 'msg': 'No function signature provided'}

# Get function from function signature
target_function = get_function_from_func_signature(function_signature,
project_name)
if target_function == None:
if target_function is None:
return {
'result': 'error',
'msg': 'Function signature could not be found'
Expand Down Expand Up @@ -876,7 +876,7 @@ def api_cross_references():
def api_project_all_functions():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}

# Get all of the functions
Expand All @@ -894,7 +894,7 @@ def api_project_all_functions():
def api_project_all_jvm_constructors():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}

# Get all of the constructor
Expand Down Expand Up @@ -940,18 +940,18 @@ def _convert_function_return_list(project_functions):
def api_project_source_code():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}
filepath = request.args.get('filepath', None)
if filepath == None:
if filepath is None:
return {'result': 'error', 'msg': 'No filepath provided'}

begin_line = request.args.get('begin_line', None)
if begin_line == None:
if begin_line is None:
return {'result': 'error', 'msg': 'No begin line provided'}

end_line = request.args.get('end_line', None)
if end_line == None:
if end_line is None:
return {'result': 'error', 'msg': 'No end line provided'}

try:
Expand All @@ -968,7 +968,7 @@ def api_project_source_code():
source_code = extract_lines_from_source_code(project_name, '',
filepath, begin_line,
end_line)
if source_code == None:
if source_code is None:
return {'result': 'error', 'msg': 'no source code'}

return {'result': 'success', 'source_code': source_code}
Expand All @@ -983,17 +983,17 @@ def api_project_source_code():
for ps in project_statistics:
if ps.project_name == project_name:
datestr = ps.date
if ps.introspector_data != None:
if ps.introspector_data is not None:
latest_introspector_datestr = datestr

if latest_introspector_datestr == None:
if latest_introspector_datestr is None:
return {'result': 'error', 'msg': 'No introspector builds.'}

source_code = extract_lines_from_source_code(project_name,
latest_introspector_datestr,
filepath, int(begin_line),
int(end_line))
if source_code == None:
if source_code is None:
return {'result': 'error', 'msg': 'no source code'}

return {'result': 'success', 'source_code': source_code}
Expand All @@ -1003,16 +1003,16 @@ def api_project_source_code():
def api_type_info():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}
type_name = request.args.get('name', None)
if type_name == None:
if type_name is None:
return {'result': 'error', 'msg': 'No function name provided'}

print("Type name: %s" % (type_name))
debug_info = data_storage.get_project_debug_report(project_name)
return_elem = list()
if debug_info != None:
if debug_info is not None:
for elem_type in debug_info.all_types:
if elem_type.get('name') == type_name:
return_elem.append(elem_type)
Expand All @@ -1026,10 +1026,10 @@ def api_type_info():
def api_function_signature():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}
function_name = request.args.get('function', None)
if function_name == None:
if function_name is None:
return {'result': 'error', 'msg': 'No function name provided'}

all_functions = data_storage.get_functions()
Expand All @@ -1053,11 +1053,11 @@ def api_function_signature():
def api_function_source_code():
"""Returns a json representation of all the functions in a given project"""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}

function_signature = request.args.get('function_signature', None)
if function_signature == None:
if function_signature is None:
return {'result': 'error', 'msg': 'No function signature provided'}

# Get function from function signature
Expand All @@ -1076,12 +1076,12 @@ def api_function_source_code():
for ps in project_statistics:
if ps.project_name == project_name:
datestr = ps.date
if ps.introspector_data != None:
if ps.introspector_data is not None:
latest_introspector_datestr = datestr
if is_local:
latest_introspector_datestr = "norelevant"

if latest_introspector_datestr == None:
if latest_introspector_datestr is None:
return {'result': 'error', 'msg': 'No introspector builds.'}

src_begin = target_function.source_line_begin
Expand All @@ -1102,7 +1102,7 @@ def api_function_source_code():
src_begin,
src_end,
sanity_check_function_end=True)
if source_code == None:
if source_code is None:
return {'result': 'error', 'msg': 'No source code'}
return {
'result': 'succes',
Expand All @@ -1129,7 +1129,7 @@ def api_oracle_2():
"""API for getting fuzz targets with easy fuzzable arguments."""
err_msgs = list()
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand Down Expand Up @@ -1179,7 +1179,7 @@ def api_oracle_2():
def api_oracle_1():
err_msgs = list()
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand Down Expand Up @@ -1229,7 +1229,7 @@ def api_oracle_1():
def project_repository():
err_msgs = list()
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand All @@ -1253,7 +1253,7 @@ def project_repository():
def far_reach_but_low_coverage():
err_msgs = list()
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand All @@ -1270,7 +1270,7 @@ def far_reach_but_low_coverage():
# exists in OSS-Fuzz but is present on the ClusterFuzz instance.
bs = get_build_status_of_project(project_name)

if bs == None:
if bs is None:
return {
'result':
'error',
Expand Down Expand Up @@ -1335,7 +1335,7 @@ def far_reach_but_low_coverage():
err_msgs.append('No functions found.')
bs = get_build_status_of_project(project_name)

if bs == None:
if bs is None:
return {
'result':
'error',
Expand Down Expand Up @@ -1422,7 +1422,7 @@ def shutdown():
@blueprint.route('/api/all-header-files')
def all_project_header_files():
project = request.args.get('project', None)
if project == None:
if project is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand All @@ -1441,14 +1441,14 @@ def all_project_header_files():
@blueprint.route('/api/addr-to-recursive-dwarf-info')
def type_at_addr():
project = request.args.get('project', None)
if project == None:
if project is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
}

addr = request.args.get('addr', None)
if addr == None:
if addr is None:
return {
'result': 'error',
'extended_msgs': ['Please provide project name']
Expand Down Expand Up @@ -1527,17 +1527,17 @@ def sample_cross_references():
"""Returns a list of strings with functions that call into a given
target function."""
project_name = request.args.get('project', None)
if project_name == None:
if project_name is None:
return {'result': 'error', 'msg': 'Please provide a project name'}

function_signature = request.args.get('function_signature', None)
if function_signature == None:
if function_signature is None:
return {'result': 'error', 'msg': 'No function signature provided'}

# Get function from function signature
target_function = get_function_from_func_signature(function_signature,
project_name)
if target_function == None:
if target_function is None:
return {
'result': 'error',
'msg': 'Function signature could not be found'
Expand Down Expand Up @@ -1582,10 +1582,10 @@ def sample_cross_references():
for ps in project_statistics:
if ps.project_name == project_name:
datestr = ps.date
if ps.introspector_data != None:
if ps.introspector_data is not None:
latest_introspector_datestr = datestr

if latest_introspector_datestr == None:
if latest_introspector_datestr is None:
return {'result': 'error', 'msg': 'No introspector builds.'}

source_code_xrefs = []
Expand Down