Comments (4)
If you want to have gofuzz just generate random times across the whole
spectrum, we can "fix" this problem at the kubernetes layer. Works either
way. I figured it was good enough and not worth much more thought.
On Wed, Mar 4, 2015 at 3:42 PM, Daniel Smith [email protected]
wrote:
A default fuzzer for time.Time is now in. @thockin
https://github.com/thockin changed it to generate times only in the
next 1000 years or so; json marshalling has difficulties with negative
times and times with more than four digit years.Should the set of time values we produce include invalid times, or no?
There are use cases where people could want either behavior. Users can
override this default, but we should document what we decide.—
Reply to this email directly or view it on GitHub
#14.
from gofuzz.
Yeah, I don't think it's worth additional thought right now.
from gofuzz.
I found a possibly related issue today. time.Time
implements BinaryMarshaller
. I'm trying to fuzz a custom codec that relies on that. Currently fuzzTime
will generate any uint64 value for nsec
which the time.Time
does do explicitly say is "valid" although they don't say what is meant by valid
!
It seems though that when a value of nsec
greater than 999,999,999
is chosen, MarshallBinary
will always fail with Time.MarshalBinary: unexpected zone offset
(I guess dependent on your local timezone!). At least, that's my understanding!
If I replace the implementation like this:
f := fuzz.New().Funcs(
func(t *time.Time, c fuzz.Continue) {
var sec, nsec int64
// Allow for about 1000 years of random time values, which keeps things
// like JSON parsing reasonably happy.
sec = c.Rand.Int63n(1000 * 365 * 24 * 60 * 60)
nsec = c.Rand.Int63n(999_999_999) // <=== changed line
*t = time.Unix(sec, nsec)
},
)
My test always (so far!) passes. If I use the default one, my test pretty consistently fails (I'm looping 1000 times in the test so the chance of hitting a uint64 greater than a billion is extremely high!)
I'd be very happy to PR that change if others thing this is more useful? It seems the second range was chosen to make JSON parsing happier for a similar reason?
Also happy to open a separate issue if that's deemed necessary since this is a more specific fix than this issue in general!
from gofuzz.
I think that seems OK to me, please send a PR :)
(if people want to fuzz with invalid times, they can write their own function. We could also provide a "WeirdTimeFuzz" function or something to make that extra easy.
from gofuzz.
Related Issues (20)
- Improve quality of integer output HOT 2
- Idea: Fuzzing with only non-zero values?
- Add golint to automated tests
- comparison with go-fuzz HOT 1
- presence of an interface value always panics HOT 20
- issue building with go 1.11.3 and previous
- Is this repository still alive? HOT 1
- go mod checksum mismatch HOT 1
- Integrate with fuzzit?
- Add note to docs that private fields of structs cannot be fuzzed using this package HOT 2
- Generating blank strings even though nilChance is set to 0 HOT 2
- go-fuzz integration may give nil values despite NilChance(0) HOT 2
- New Release? HOT 2
- UnicodeRanges as shown in example cause `go vet` to fail
- Test failure on 32 bits arch
- NewFromGoFuzz doesn't work well with go-fuzz HOT 1
- Can we add support for unexported field? HOT 2
- Is / should gofuzz safe for concurrent use? HOT 2
- Tag a new release: 1.3.0
- Regarding newer versions
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 gofuzz.