Add policy decode fuzz tests #219
No reviewers
TrueCloudLab/storage-core-developers
Labels
No labels
P0
P1
P2
P3
good first issue
pool
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-sdk-go#219
Loading…
Reference in a new issue
No description provided.
Delete branch "dstepanov-yadro/frostfs-sdk-go:feat/policy_fuzz_tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Relates #216
Fuzz test for policy decode added.
380b21d160
to6d8fffd9f9
@ -0,0 +1,22 @@
//go:build gofuzz
We will use this with libFuzzer https://github.com/AdamKorcz/go-118-fuzz-build?tab=readme-ov-file#using-test-utils-from-other-_testgo-files
So the logic should be in the main package without
_test
prefixdone
6d8fffd9f9
toc2cdb82617
Предлагаю прийти к такому способу хранения фаззинг тестов - <pkg_root>/tests/fuzzing/<pkg_name>/[pkg_test.go, pkg_fuzz.go]
хочется чтобы сам фаззинг тест имел следующую структуру:
f.Fuzz(func(t *testing.T, data []byte) {
DoFuzzMyFunc(data)
})
Это позволит использовать и go test (сохранение совместимости на перспективу), и libfuzzer (более мощный движок + возможность сбора покрытия кода)
Например, тут [https://github.com/etclabscore/core-geth/blob/master/tests/fuzzers/bitutil/compress_test.go] можно посмотреть как это реализовано в других проектах (в данном случае все лежит в одном test файле)
c2cdb82617
tofa2f14c5a3
Поправил
я имел ввиду frostfs-sdk-go/tests/fuzzing/netmap/...
fa2f14c5a3
to1a9de18eb8
done
Do we really need to use fzgen for simple types ([]byte, string)?
Frankly I would rather not have a separate
tests
package and put tests together with the code (it may reuse helpers, for example).It there any reason why you want this besides "one specific not very popular project does this"? @ognev
No, I don't see any major reasons.
The main reason is cluttering of the packages with code.
In addition to tests, we will also need to store a corpus of input data and (possibly) a dictionary (various string values and magic numbers) for more efficient fuzzing.
To generate coverage, we need to take an array of bytes as input regardless of the code.
Of course, we can generate simple types from it ourselves.
This is my argument in favor of storing them together with code. Usually we have unexported test helpers which can generate this corpus. And because structures evolve, static corpus will also need to change.
For an example, see TrueCloudLab/policy-engine#72/files
1a9de18eb8
to1bea561f81
Done
1bea561f81
toeb02e1e595