🏡 Mood: Ready for a 3 day weekend.

🎵 Soundtrack: Big Red Machine Mix

📚 Reading Github Issues

Read 13 new github issues. None of them really stuck out.

🐈‍⬛ Code Reviews

I ended up submitting my go vet check code last night, with the hope of having someone review it before I got into work today. And that’s what happened!

I went back and forth twice more today with code reviews. Per the reviewers’ requests I:

  • Changed regexp.Compile (which returns an error) -> regexp.MustCompile (which does not return an error and panics instead). This was nice to get rid of the error handling.
  • Stopped running rexep.(Must)Compile for every example and instead did it once globally.
  • Added a comment that the file’s comments are guaranteed to be in order of appearance.
  • Got rid of an unnessesary else statement.
  • Added a test for multiple output comments.

🧶 Back to Fuzzing

In between code reviews, I went back to investigating the fuzzing minimizer. I ended up writing some code (and tests!) to extend the minimizer to make the results “cleaner” when they are strings.

For example, if a function always failed when a string had a length of 5 with the current implementation the result could be some very unreadable things like: aQQ\x89\x9f, MEow\xbc, or m$\x80\x00K.

With my implementation, I try to replace every character with 0. If that doesn’t work I try to replace letters with a, symbols with $, and punctuation with ..Thus if a function always failed when a string had a length of 5 then the result would ALWAYS be 00000.

The code ended up looking like this:

	for i, c := range string(v) {
		candidate := make([]byte, len(v))
		copy(candidate, v)

		// Try to replace everything with zeros.
		candidate[i] = 48 // 0
		if try(candidate) {
			v = candidate
			continue
		}

    // If 0 doesn't work, try to replace with the simpliest example of same
    // "type" of character.
		if unicode.IsLetter(c) {
			candidate[i] = 97 // a
		}
		if unicode.IsSymbol(c) {
			candidate[i] = 36 // $
		}
		if unicode.IsPunct(c) {
			candidate[i] = 46 // .
		}
		if !try(candidate) {
			break
		}
		// Set v to the new value to continue iterating.
		v = candidate
	}

At the end of the day I was struggling to merge it in with the current code DRYly. I’m sure there is a way, but my attention has started to wane with the weekend just 2 hours away.

My next step is to open an issue for this and offer to work on it. I wanted to get a little rough draft complete before I created an issue just to make sure I could do it 😅.