8000 Add text search across trials/samples by myanvoos · Pull Request #1134 · google/oss-fuzz-gen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add text search across trials/samples #1134

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
61 changes: 61 additions & 0 deletions report/parse_run_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A dedicated parser to parse the run log and extract
information such as the crash details, crash symptoms,
stack traces, etc. to be rendered in the report."""

import re


class RunLogsParser:
"""Parse the run log."""

def __init__(self, run_logs: str):
self._run_logs = run_logs
self._lines = run_logs.split('\n')

def get_crash_details(self) -> str:
"""Get the raw crash details for the given sample."""
crash_details = ""
start_idx = 0
end_idx = len(self._lines) - 1

for idx, line in enumerate(self._lines):
if "==========" in line:
start_idx = idx
if 0 < start_idx < idx and "artifact_prefix" in line:
end_idx = idx

# If we found a start index, then we can get the crash details
# Otherwise, return an empty string (for rendering purposes,
# because then this will just be the entire run log)
if start_idx > 0:
crash_details = '\n'.join(self._lines[start_idx:end_idx + 1])

return crash_details

def get_crash_symptom(self) -> str:
"""Get the crash symptom from the run log."""
crash_symptom = ""

pattern = re.compile(r"(?:^\s*\x1b\[[0-9;]*m)*==\d+==\s*(ERROR:.*)",
re.DOTALL)

for line in self._lines:
match = pattern.search(line)
if match:
crash_symptom = match.group(1)
break

return crash_symptom
Loading
0