-
Notifications
You must be signed in to change notification settings - Fork 169
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
Crash Analyzer Agent #814
Open
maoyixie
wants to merge
140
commits into
google:main
Choose a base branch
from
maoyixie:dev9
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+794
−124
Open
Crash Analyzer Agent #814
Changes from all commits
Commits
Show all changes
140 commits
Select commit
Hold shift + click to select a range
34b8d65
fix typo
maoyixie 4eb99d2
crash analyzer agent prototype
maoyixie 3d75099
add _execute_agent_cloud in crash analyzer
maoyixie eb556a7
save cloud testcase
maoyixie c11a2ae
support gpt chat model
maoyixie ef90d46
update lldb _handle_conclusion
maoyixie 55fcbed
update prompt, compile project
maoyixie 50d379e
update CrashResult
maoyixie 98e216c
temp, revert later
maoyixie f7096bd
try to fix gpt model
maoyixie c10bd27
try to fix gpt model
maoyixie 705aa06
todo: fix openai prompt
maoyixie 6590fda
add tutorial with add_problem instead of append
maoyixie 8177330
try to fix invalid type for message in gpt(todo)
maoyixie 4d8e354
matain gpt chat session, ugly fix invalid message
maoyixie da6d96e
update
maoyixie 3e59be8
fix agent name
maoyixie 8e8f5e8
fix crash analyzer no benchmark
maoyixie b589684
reformat
maoyixie d10587b
delete unused import
maoyixie 31ac644
fix line to long
maoyixie 9a38d93
fix line too long
maoyixie ab55a08
fix warning
maoyixie a618b4d
fix warning
maoyixie e1985c1
crash result inherit from run result
maoyixie 4087145
reformat
maoyixie 54a0579
pass run_result instead of result_history to crash analyzer execute()
maoyixie 1c50caf
revert to match abstract method in Resykt
maoyixie c0ed437
add type check
maoyixie 732fef3
fix "Prompt" must return value on all code paths
maoyixie 6f9dd49
fix Argument missing for parameter "crash_func"
maoyixie 5d8562e
fix Argument missing for parameter "crash_func"
maoyixie 179d34c
fix Dangerous default value {} as argument
maoyixie 7d87af5
fix crash_func
maoyixie 6d87813
fix Argument missing for parameter "crash_func"
maoyixie fb6b4f3
fix RunResult in execute in crash analyzer
maoyixie be85aeb
fix some errors
maoyixie f7bde92
fix some errors
maoyixie 9140b60
fix Result
maoyixie ea37525
fix Result
maoyixie bacea64
fix Function with declared return type "CrashResult" must return valu…
maoyixie 7fefe34
"benchmark" is unbound
maoyixie 1b2033d
delete output.txt
maoyixie 9568774
fix type
maoyixie 4190fc5
try to fix unterminated s command, more logger info
maoyixie 526aeda
try to fix compile failure
maoyixie bb42587
try to fix -g: not a valid identifier
maoyixie c8842bd
try to fix command in dockerfile
maoyixie e0f0fb3
try to fix command in dockerfile
maoyixie e891bea
TODO: some issues like missing artifact and lldb command failure, del…
maoyixie 24eb2dc
print more info, format
maoyixie 3aed1c9
try to fix Anomalous backslash in string
maoyixie af7e1c7
try to fix did not copy fuzz target and build script
maoyixie c8a8901
Delete output1.txt
maoyixie b9288ec
Delete output2.txt
maoyixie ab73185
adjust cycle times
maoyixie 93fda5c
delete comment
maoyixie a10ae07
reformat
maoyixie 7ce2e71
line break
maoyixie e19eeb0
optimize artifact name
maoyixie 4908f5e
try to fix failed to match conclusion
maoyixie 93393b9
TODO: fix TypeError: Object of type set is not JSON serializable
maoyixie d5c5f1f
optimize lldb prompt, try to fix lldb inconsistency
maoyixie 299b316
delete some info
maoyixie a17f593
reformat
maoyixie f0882a3
optimize lldb prompt, try to fix ERROR: The required directory < does…
maoyixie f9d5b14
try to fix lldb
maoyixie 93561cd
fix -e
maoyixie 6c64fb1
try to fix
maoyixie 11addf8
optimize lldb prompt, ignore insignificant errors
maoyixie 2a117fa
optimize lldb prompt
maoyixie 696494b
optimize lldb prompt
maoyixie e422241
delete info
maoyixie d838f68
fix fuzzing_language
maoyixie 9f43d4b
modify comment
maoyixie bd7b572
Create temp
DonggeLiu 9a947b4
delete temp
maoyixie 7ac49be
fix import
maoyixie 071a000
fix typo
maoyixie 5706e69
fix termination condition
maoyixie f84e821
analysis stage
maoyixie e37a979
work dir
maoyixie 8c7ee9f
cloud builder
maoyixie 1fc462c
lldb
maoyixie aa97a65
fix crash analyzer
maoyixie 3b376aa
execution stage
maoyixie 06bc63a
results
maoyixie 077730c
add info in prototyper
maoyixie 4dc82a8
fix lint
maoyixie a0eb551
fix RunResult
maoyixie 1dc4f16
fix RunResult
maoyixie 6e76339
fix lint, fix prompt
maoyixie b0f20e2
delete info
maoyixie 3cf6555
fix typo
maoyixie fda7118
CFLAGS
maoyixie 806e935
delete language condition
maoyixie c96f116
delete JCC
maoyixie b19b13f
rename image name
maoyixie cc5f8d4
recover build_result
maoyixie a7d7f24
terminate when it is not AnalysisResult
maoyixie 8c7849a
delete blank line
maoyixie f2793f9
assert RunResult
maoyixie 347ca5a
recover comment
maoyixie 98be2ce
assert RunResult
maoyixie 8795862
inherit ProjectContainerTool
maoyixie 0a83974
detach SemanticCheckResult from RunResult
maoyixie e6b6881
OpenAIPrompt append
maoyixie d05a962
lldbtool inherit from containertool
maoyixie 3486a8e
use trial ID to distinguish artifact folder
maoyixie fc248b8
not overwrite _container_handle_bash_command
maoyixie d244370
rename _handle_conclusion
maoyixie 847c683
optimize CrashResult initialization
maoyixie aceae60
use original artifact name
maoyixie 71ddb82
detach _copy_crash_file()
maoyixie 879b460
add trial ID to log
maoyixie 2006aee
optimimze LLDBTool inherit from ProjectContainerTool
maoyixie 1a088ae
optimize model class with chat session
maoyixie 84167ab
optimize handle_lldb_command
maoyixie d52b48b
reuse create_ossfuzz_project
maoyixie 792c1f3
deduplicate chat_llm
maoyixie 5f5ae1b
fix lint
maoyixie 0041af1
change create_ossfuzz_project into staticmethod, fix lint
maoyixie bb120c9
fix lint
maoyixie ca8f522
fix loss t
maoyixie 0ebad67
Merge branch 'main' into dev9
DonggeLiu edd3a74
Fix 'No such file or directory' error
DonggeLiu 7e6a99d
Fix 'NameError: name 'WorkDirs' is not defined'
DonggeLiu 2ffc79f
Merge branch 'main' into dev9
maoyixie a4f30a4
fix lint
maoyixie 406a1aa
Write fuzz target and build script to the expected locations in the n…
DonggeLiu 0f0d5d6
Fix artifact blobing
DonggeLiu cf3b091
Merge branch 'main' into dev9
DonggeLiu 1671da2
fix author
DonggeLiu af2ccfc
Fix blobbing
DonggeLiu 6fafd6c
Various bug fixes
DonggeLiu 4d21afc
Fix initialization
DonggeLiu e8df9e2
code move to _copy_cloud_artifact
maoyixie ec06f99
add bash tool for crash analyzer, add crash analyzer prompt
maoyixie 87ac0fc
fix lint
maoyixie d489b40
fix wrap lldb in bash, use screen to maintain lldb session
maoyixie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
|
||
import utils | ||
from agent.base_agent import BaseAgent | ||
from results import Result | ||
from results import Result, RunResult | ||
|
||
OF_REPO = 'https://github.com/google/oss-fuzz.git' | ||
OFG_ROOT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) | ||
|
@@ -107,12 +107,12 @@ def _prepare_and_upload_archive(self) -> str: | |
return self._upload_to_gcs(archive_path) | ||
|
||
def _request_cloud_build(self, ofg_repo_url: str, agent_dill_url: str, | ||
results_dill_url: str, | ||
results_dill_url: str, artifact_url: str, | ||
new_result_filename: str) -> str: | ||
"""Requests Cloud Build to execute the operation.""" | ||
cloud_build_config = { | ||
'steps': [ | ||
# Step 1: Download the dill files from GCS bucket. | ||
# Step 1: Download the dill and artifact files from GCS bucket. | ||
{ | ||
'name': 'bash', | ||
'dir': '/workspace', | ||
|
@@ -128,6 +128,16 @@ def _request_cloud_build(self, ofg_repo_url: str, agent_dill_url: str, | |
'dir': '/workspace', | ||
'args': ['cp', results_dill_url, 'dills/result_history.pkl'] | ||
}, | ||
{ | ||
'name': 'gcr.io/cloud-builders/gsutil', | ||
'dir': '/workspace', | ||
'args': [ | ||
'cp', artifact_url, | ||
f'/workspace/{os.path.basename(artifact_url)}' | ||
], | ||
# artifact_url only exists in crash analyzer. | ||
'allowFailure': True, | ||
}, | ||
# Step 2: Prepare OFG and OF repos. | ||
{ | ||
'name': | ||
|
@@ -196,7 +206,7 @@ def _request_cloud_build(self, ofg_repo_url: str, agent_dill_url: str, | |
'/workspace/dills/new_result.pkl' | ||
], | ||
}, | ||
# Step 4: Upload the result to GCS bucket | ||
# Step 6: Upload the result to GCS bucket | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
{ | ||
'name': 'bash', | ||
'dir': '/workspace', | ||
|
@@ -309,11 +319,15 @@ def run(self, agent: BaseAgent, result_history: list[Result], | |
ofg_url = self._prepare_and_upload_archive() | ||
agent_url = self._upload_to_gcs(agent_dill) | ||
results_url = self._upload_to_gcs(results_dill) | ||
last_result = result_history[-1] | ||
artifact_url = 'ARTIFACT_URL DOES NOT EXISTS' | ||
if isinstance(last_result, RunResult) and last_result.artifact_path: | ||
artifact_url = self._upload_to_gcs(last_result.artifact_path) | ||
|
||
# Step 3: Request Cloud Build. | ||
new_result_filename = f'{uuid.uuid4().hex}.pkl' | ||
build_id = self._request_cloud_build(ofg_url, agent_url, results_url, | ||
new_result_filename) | ||
artifact_url, new_result_filename) | ||
|
||
# Step 4: Download new result dill. | ||
cloud_build_log = '' | ||
|
@@ -334,7 +348,7 @@ def run(self, agent: BaseAgent, result_history: list[Result], | |
|
||
cloud_build_log += self._get_build_log(build_id) | ||
|
||
# Step 4: Deserialize dilld file. | ||
# Step 5: Deserialize dilld file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
result = utils.deserialize_from_dill(new_result_dill) | ||
if not result: | ||
cloud_build_log += f'Failed to deserialize from dill {new_result_dill}.\n' | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be the same as
_container_tool_reaction()
inPrototyper
?If so, we can relocate that function into
base_agent
so that you don't have to repeat it here.Again, future users/editors will appreciate this because they can read/modify the code in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different from
_container_tool_reaction()
inPrototyper
because the prompt is designed differently.