Skip to content

Commit

Permalink
webapp: api: add more blockers to test-case paths (#1790)
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored Oct 21, 2024
1 parent a9e1362 commit bd13106
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ json-java
java-diff-utils
idna
configparser
tinyxml2
libheif

29 changes: 22 additions & 7 deletions tools/web-fuzzing-introspection/app/webapp/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,8 +2140,22 @@ def all_project_header_files():
return {'result': 'failed', 'msg': 'did not find project'}


def should_ignore_testpath(test_path: str) -> bool:
"""Returns true if the test path should be ignored"""
banned_paths = {
'/src/fuzztest/', '/src/libfuzzer/', '/src/aflplusplus/', '/LPM/',
'/googletest/', '/third_party/', '/thirdparty/', 'fuzz', '/depends/',
'/external/', '/build/', '/src/inspector/', '/source-code/',
'/workspace/'
}
if [bp for bp in banned_paths if bp in test_path]:
return True
return False


def extract_project_tests(project_name,
refine: bool = True) -> Optional[List[str]]:
"""Extracts the tests in terms of file paths of a given project"""
tests_file = os.path.join(
os.path.dirname(__file__),
f"../static/assets/db/db-projects/{project_name}/test_files.json")
Expand All @@ -2151,22 +2165,18 @@ def extract_project_tests(project_name,
with open(tests_file, 'r') as f:
tests_file_list = json.load(f)

banned_paths = {
'/src/fuzztest/', '/src/libfuzzer/', '/src/aflplusplus/', '/LPM/',
'/googletest/', '/third_party/', '/thirdparty/', 'fuzz', '/depends/',
'/external/', '/build/', '/src/inspector/', '/source-code/'
}
if refine:
refined_list = []
for test_file in tests_file_list:
if [bp for bp in banned_paths if bp in test_file]:
if should_ignore_testpath(test_file):
continue
refined_list.append(test_file)
tests_file_list = refined_list
return tests_file_list


def _light_project_tests(project_name):
"""Returns the list of test files in a project based on FI light."""
target_project = get_project_with_name(project_name)
if not target_project:
return []
Expand All @@ -2175,7 +2185,12 @@ def _light_project_tests(project_name):
return []

light_test_files = target_project.light_analysis.get('test-files', [])
return light_test_files
returner_list = []
for test_file in light_test_files:
if should_ignore_testpath(test_file):
continue
returner_list.append(test_file)
return returner_list


@blueprint.route('/api/project-tests')
Expand Down

0 comments on commit bd13106

Please sign in to comment.