Skip to content

test: add make fuzz and a urunc.json fuzz target - #1095

Open
pocopepe wants to merge 1 commit into
urunc-dev:mainfrom
pocopepe:feat/fuzzing
Open

pocopepe wants to merge 1 commit into
urunc-dev:mainfrom
pocopepe:feat/fuzzing

Conversation

@pocopepe

@pocopepe pocopepe commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adding a Makefile stub to extend the suite to fuzzing, and a bare bones fuzz target that runs locally and feeds arbitrary bytes as urunc.json through GetUnikernelConfig.

Related issues

How was this tested?

Ran make fuzz

pocopepe@pocopepe:~/urunc$ make fuzz 
Fuzzing FuzzGetUnikernelConfig in pkg/unikontainers/
fuzz: elapsed: 0s, gathering baseline coverage: 0/147 completed
fuzz: elapsed: 1s, gathering baseline coverage: 147/147 completed, now fuzzing with 16 workers
fuzz: elapsed: 3s, execs: 5970 (1987/sec), new interesting: 2 (total: 149)
fuzz: elapsed: 6s, execs: 9173 (1069/sec), new interesting: 4 (total: 151)
fuzz: elapsed: 9s, execs: 15685 (2170/sec), new interesting: 5 (total: 152)
fuzz: elapsed: 12s, execs: 18047 (788/sec), new interesting: 6 (total: 153)
fuzz: elapsed: 15s, execs: 23180 (1711/sec), new interesting: 6 (total: 153)
fuzz: elapsed: 16s, execs: 23180 (0/sec), new interesting: 6 (total: 153)
PASS
ok      github.com/urunc-dev/urunc/pkg/unikontainers    16.095s

LLM usage

N/A

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit e1ae619
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6acf6934648dc50c5e0d9dbd

@cmainas cmainas 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.

Hello @pocopepe ,

thank you for the PR. A few questions:

  • Is the first fuzzing example actual or just a placeholder to ensure evrything works well?
  • I do not think we need any discovery loop for fuzzing targets. Instead, we can use fuzzing targets in the same way we use unit tests per packages right now. So we cna name the fuzzing functions with a specific pattern to match a target.

Comment thread Makefile Outdated
fns=$$($(GO) test -list '^Fuzz' ./$$pkg) || exit 1; \
for fn in $$(echo "$$fns" | grep '^Fuzz'); do \
echo "Fuzzing $$fn in $$pkg"; \
$(GO) test -run='^$$' -fuzz="^$$fn$$" -fuzztime=$(FUZZTIME) ./$$pkg || exit 1; \

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.

We should also add the GOFLAGS=$(TEST_FLAGS) and other test flags that apply cleanly for fuzzing. If they do not apply, we can refactor a bit the existing variables so they cna be more re-usable.

Ref: urunc-dev#852
Signed-off-by: viju <avijusanjai@gmail.com>
@pocopepe

Copy link
Copy Markdown
Contributor Author

Hi @cmainas,

  • The target isn't a placeholder, it actually fuzzes, checks that urunc returns either a config or an error. It's small, but felt like something worth keeping around.
  • Noted. I was thinking of a ClusterFuzzLite build, where a discovery loop keeps things less hands-on. I'll keep that in its build script instead.

I've made the changes and added the Go flags as well.

@cmainas cmainas 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.

Thank you @pocopepe for the fixes in the Makefile.

Since this is an actual fuzzing test, I added some comments. However we need to enrich it in follow ups.

}

conf, err := GetUnikernelConfig("", &specs.Spec{Root: &specs.Root{Path: rootfs}})
if (conf == nil) == (err == nil) {

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.

This check does not catch any issues. Every return pair is either (conf, nil) or (nil, err),

f.Add([]byte(`{"` + annotType + `":"bGludXg=","` + annotHypervisor + `":"cWVtdQ==","` + annotBinary + `":"L2FwcA=="}`))

f.Fuzz(func(t *testing.T, data []byte) {
rootfs := t.TempDir()

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.

We do not have to re-create the tempDir every time. This wll slow down the whole test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants