Add fuzz tests, property-based tests, dead code detection, and docs CNAME#37
Merged
Add fuzz tests, property-based tests, dead code detection, and docs CNAME#37
Conversation
Introduce extensive fuzz testing for parsing, rendering, and managing hosts, including address, hostname, comment, CIDR handling, and combined operations. Ensure robust error handling and validation against arbitrary inputs.
…ants Introduce extensive property-based test coverage using `testing/quick` and `rapid`. Verify correctness and consistency in parsing, rendering, host addition/removal, comment handling, and bulk operations.
… `HostAddressLookup` Clarify method purposes, improve readability, and specify use cases for better consumer understanding.
Introduce `dead-code` target to identify unreachable code, excluding specific public API methods. Add `mutate` target for mutation testing using `gremlins`.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive testing upgrade adding Go native fuzz tests (OpenSSF Scorecard Fuzzing check), property-based tests with
testing/quickandrapid, dead code detection tooling, and GitHub Pages custom domain fix.Fuzz Tests (
fuzz_test.go) -- OpenSSF Scorecard: Fuzzing 0 -> 1010 fuzz tests covering every major API surface:
FuzzParseHostsFromStringFuzzRoundTripFuzzAddHostFuzzAddHostWithCommentFuzzRemoveHostFuzzRemoveAddressFuzzRemoveCIDRsFuzzListOperationsFuzzRemoveByCommentFuzzListHostsByCommentFuzzCombinedOperationsAll tests validate: no panics on arbitrary input, state consistency (rendered output always re-parseable), correct line types on ADDRESS entries.
Property-Based Tests (
property_test.go)6
testing/quick(stdlib) invariant tests:TestProperty_ParseRenderRoundTrip_AlwaysParseable-- rendered output is always validTestProperty_AddHost_ThenLookup_FindsIt-- add then lookup always succeedsTestProperty_RemoveHost_ThenLookup_NeverFindsIt-- remove guarantees absenceTestProperty_RemoveAddress_RemovesAllHostnames-- address removal is completeTestProperty_AddHost_InvalidIP_IsNoOp-- invalid IPs never modify stateTestProperty_ParsedLineCount_MatchesInputLines-- parser preserves line count7
rapid(pgregory.net/rapid) property tests with controlled generators:TestRapid_AddRemove_Symmetry-- add then remove restores absenceTestRapid_AddHost_Idempotent-- duplicate adds don't create duplicatesTestRapid_RemoveHost_Idempotent-- removing non-existent host is safe no-opTestRapid_BulkAddRemove_StateConsistency-- 5-30 random ops never corrupt stateTestRapid_CommentOperations_Consistent-- add-with-comment / list / remove-by-comment cycleTestRapid_HostnameMoveBetweenAddresses-- re-adding to new IP removes from oldTestRapid_RenderParse_PreservesAddressEntries-- render/re-parse preserves all entriesDead Code Detection & Mutation Testing
make dead-codetarget usinggolang.org/x/tools/cmd/deadcodemake mutatetarget usinggremlinsmutation testing (60% threshold)Reload,RemoveByComments,HostAddressLookup) excluded from dead code check -- documented as public API for external consumers (e.g., kubefwd)Public API Documentation
Updated doc comments on 3 exported methods to clarify their role as public API:
Hosts.Reload-- for long-lived instances that re-read from diskHosts.RemoveByComments-- bulk comment-based cleanup (kubefwd teardown)Hosts.HostAddressLookup-- direct address lookups by IP familyDocs CNAME
docs/CNAMEwithtxeh.txn2.comto fix GitHub Pages 404Files Changed
OpenSSF Scorecard Impact
Combined with the enterprise-standards merge (already on master), next weekly scorecard run should also pick up: Security-Policy (0->10), SAST, Pinned-Dependencies, Token-Permissions.