Skip to content

Implement untrusted RPCS for fuzzing and reproduction. - #888

Merged
oliverchang merged 8 commits into
masterfrom
untrusted_rpc
Aug 27, 2019
Merged

oliverchang merged 8 commits into
masterfrom
untrusted_rpc

Conversation

@oliverchang

@oliverchang oliverchang commented Aug 26, 2019 •

Copy link
Copy Markdown
Collaborator

For the new fuzzing pipeline (#483).

  • Write integration tests.
  • Simplify testcase pulling pushing for testcase minimization/cleansing.
  • Make file_host.rebase_to_worker_root idempotent.

@googlebot googlebot added the cla: yes CLA signed. label Aug 26, 2019
@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang oliverchang changed the title WIP: implement untrusted RPCS for fuzzing and reproduction. Implement untrusted RPCS for fuzzing and reproduction. Aug 26, 2019
@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@Dor1s Dor1s left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@@ -123,7 +123,17 @@ func (s *UntrustedRunnerServer) PruneCorpus(context.Context, *pb.PruneCorpusRequ
}

// ProcessTestcase is processes a testcase with a fuzzing engine (e.g. minimization).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (not your change): "is " is a typo

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment thread src/protos/untrusted_runner.proto Outdated
optional bytes output = 4;
}

message RunEngineFuzzerRequest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a random thought: would it be better to name all of these starting with "Engine", e.g. "EngineRunFuzzerRequest", IMO that way it still sounds good, but kinda easier to attribute to the in-process fuzzing pipeline

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or how about just EngineRunRequest, EngineRunResponse ?
I don't see you use Fuzzer in any of the other fields like EngineCrash or stuff.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to EngineFuzz{Request,Response}. Want to make it explicit that this is for fuzzing.

build_dir = environment.get_value('BUILD_DIR')
target_path = engine_common.find_fuzzer_path(build_dir, target_name)
if not target_path:
raise TargetNotFoundError('Failed to find target ' + target_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not leave this logic in the constructor? Isn't it better to fail earlier?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't call this in the constructor, which lives on the host and therefore doesn't have access to the build.

raise ValueError('Unknown stat type for ' + key)

packed_value.Unpack(value)
unpacked_stats[key] = value.value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two lines doing what they're expected to do? Doesn't look like a typical Python code to me, but I'm not familiar with that Unpack method :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's protobuf-generated code. See e.g. protocolbuffers/protobuf#4420 (comment)

engine_impl = engine.get(request.engine)
result = testcase_manager.engine_reproduce(
engine_impl, request.target_name, request.testcase_path,
list(request.arguments), request.timeout)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for some reason, I don't like the conversion to the list here, maybe do it inside engine_reproduce? That way it will work with both lists and whatever protobuf object there is, without requiring the caller to cast the type epxlicitly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Moved!

Comment thread src/protos/untrusted_runner.proto Outdated
optional bytes output = 4;
}

message RunEngineFuzzerRequest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or how about just EngineRunRequest, EngineRunResponse ?
I don't see you use Fuzzer in any of the other fields like EngineCrash or stuff.


@classmethod
def setUpClass(cls):
cls.saved_env = os.environ.copy()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not test_helpers.patch_environ(self) and then remove code in tearDownClass

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That only works for setUp, not setUpClass

build_manager.setup_build()
with self.assertRaises(testcase_manager.TargetNotFoundError):
testcase_manager.engine_reproduce(libfuzzer_engine.LibFuzzerEngine(),
'not_found', testcase_file_path, [], 30)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/not_found/not_exist ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@oliverchang oliverchang left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/gcbrun

build_dir = environment.get_value('BUILD_DIR')
target_path = engine_common.find_fuzzer_path(build_dir, target_name)
if not target_path:
raise TargetNotFoundError('Failed to find target ' + target_name)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't call this in the constructor, which lives on the host and therefore doesn't have access to the build.

raise ValueError('Unknown stat type for ' + key)

packed_value.Unpack(value)
unpacked_stats[key] = value.value

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's protobuf-generated code. See e.g. protocolbuffers/protobuf#4420 (comment)

engine_impl = engine.get(request.engine)
result = testcase_manager.engine_reproduce(
engine_impl, request.target_name, request.testcase_path,
list(request.arguments), request.timeout)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Moved!

build_manager.setup_build()
with self.assertRaises(testcase_manager.TargetNotFoundError):
testcase_manager.engine_reproduce(libfuzzer_engine.LibFuzzerEngine(),
'not_found', testcase_file_path, [], 30)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


@classmethod
def setUpClass(cls):
cls.saved_env = os.environ.copy()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That only works for setUp, not setUpClass

Comment thread src/protos/untrusted_runner.proto Outdated
optional bytes output = 4;
}

message RunEngineFuzzerRequest {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to EngineFuzz{Request,Response}. Want to make it explicit that this is for fuzzing.

@@ -123,7 +123,17 @@ func (s *UntrustedRunnerServer) PruneCorpus(context.Context, *pb.PruneCorpusRequ
}

// ProcessTestcase is processes a testcase with a fuzzing engine (e.g. minimization).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@oliverchang
oliverchang merged commit 4cb3cb3 into master Aug 27, 2019
@oliverchang
oliverchang deleted the untrusted_rpc branch August 27, 2019 01:29
@stfsdr6sgs-eng stfsdr6sgs-eng mentioned this pull request Nov 25, 2025
@Sovann87 Sovann87 mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes CLA signed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants