Comments (6)
Figured I would add my 2 cents even though I'm not a framework author.
I've definitely used reflection in my harnesses. I don't see what could go wrong with doing this.
What do you mean by state by the way? This approach is stateless and I beleive it solves your problem:
std::string DeserializeA(A& a_msg) {
return DeserializeB(a_msg.b(), a_msg.c())
}
std::string DeserializeB(B& b_msg, bool is_c) {
if (!is_c) {
return std::string(b_msg.d());
}
return std::string(b_msg.d()) + b_msg.e();
}
from libprotobuf-mutator.
@jonathanmetzman The harness you shared is really helpful, thank you :)
I think a visitor pattern might be sufficient for my use case. What I meant by state is for example, writing the proto converter such that the conversion of a given proto message happens differently based on the context that message appears in.
But there's also another notion of state that is important in the context of compiler fuzzing and that is related to making the proto converter respect programming language scoping rules e.g., only reference a previously declared variable.
from libprotobuf-mutator.
What I meant by state is for example, writing the proto converter such that the conversion of a given proto message happens differently based on the context that message appears in.
Ah so I guess my "stateless" solution doesn't qualify under this definition.
But there's also another notion of state that is important in the context of compiler fuzzing and that is related to making the proto converter respect programming language scoping rules e.g., only reference a previously declared variable.
Ah I've run into similar problems myself when exploring the possibility of writing LPM for different formats (such as glsl shaders). I don't have any great ideas for how to solve this problem (maybe LPM is better for "stateless" formats while a fully-custom mutator works better for "stateful" ones). It can get even nastier if we worry about types as well.
If you do implement a nice solution please share!
I don't quite remember how this fuzzer works, but it is a successful LPM fuzzer for SQL queries in SQLite. Maybe it uses some neat tricks for dealing with state?
from libprotobuf-mutator.
maybe LPM is better for "stateless" formats while a fully-custom mutator works better for "stateful" ones
This is definitely something worth pondering over. I remember @kcc mentioning something about the pros and cons of using LPM natively versus defining a custom mutator.
Just thinking out loud here:
- A proto spec is like a regular expression
- A program in a programming language has context-free grammar but in reality is context-sensitive (e.g., due to scoping rules etc.)
- This means a proto spec has weaker expressivity than a program
- It follows that what we may be trying to do is the "impossible" in theory but "hackable" in practice :)
- If LPM natively (without a custom mutation function tailored to the format under test) mutates a proto spec, it might generate trees that don't obey scoping rules. I just don't know how often it won't
- Either we need a custom stateful mutator or a stateful proto converter
- A custom mutator is probably more efficient because meaningless programs are not generated in the first place
If you do implement a nice solution please share!
Will do :) Also, thank you for the sqlite fuzzer, I will check it out. I can imagine sql queries also depend on context (like some sub-queries make sense for a specific set of queries or so), so I can learn from this example.
If you know of stateful custom mutators in the chromium project, please share! Thanks once again.
from libprotobuf-mutator.
Sorry for the late (and unhelpful =) response to this.
I agree with your "out loud" thoughts.
If you know of stateful custom mutators in the chromium project, please share! Thanks once again.
Not off the top of my head.
from libprotobuf-mutator.
Closing because the original question was answered
from libprotobuf-mutator.
Related Issues (20)
- OSS-Fuzz issue 57094 HOT 1
- OSS-Fuzz issue 57096 HOT 1
- Mutator breaks content of Any
- Ninja check failing HOT 2
- clang++ filed HOT 8
- OSS-Fuzz issue 61338 HOT 1
- OSS-Fuzz issue 61395 HOT 1
- How can I start with macos???? HOT 6
- What is a correct way to disable code coverage instrumentation?
- Ninja check failed HOT 1
- Propagate `seed` to `DEFINE_PROTO_FUZZER`
- OSS-Fuzz issue 63081 HOT 1
- Error during ninja check: no type named `string_view` in namespace `absl` HOT 1
- ninja check fails on stddef.h HOT 1
- feasibility of using libprofobuf-mutator for highly complex nested protobuf in heavy compuation program
- OSS-Fuzz issue 65416 HOT 1
- OSS-Fuzz issue 65495 HOT 1
- OSS-Fuzz issue 65497 HOT 1
- OSS-Fuzz issue 65516 HOT 1
- error: use of undeclared identifier 'absl' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libprotobuf-mutator.