Repository navigation
test: add comprehensive unit tests, fixtures, and golangci-lint config - #24
Merged
Merged
Conversation
#2, #22) - Add .golangci.yml with standard Go linters (govet, errcheck, staticcheck, revive, gosec, misspell) - Add testdata/ fixtures for DAS events, S3 notifications, SNS envelopes, and EventBridge events - Add filter_test.go covering EvaluateFilter for all DSL node types (not, dimensionExists, selector, and, or, contains) and LoadFilterConfig (JSON, YAML, default fallback) - Add convert_test.go covering convertJSONToParquet (heartbeat filtering, drop fields, query matching, empty events, exit codes), decompressZlib, and ESDK decryption - Fix gosec G110 decompression bomb vulnerability in decompressZlib using io.LimitReader - Fix nil pointer panic in parquet.NewWriter on empty event batches by supplying explicit schema - Fix dimensionExists and selector in filter.go to return false for invalid dimensions - Achieve 83.2% statement test coverage across the repository
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.
Fixes #2
Fixes #22
Summary of Changes
1. Test Coverage (Closes #2)
filter_test.gowith tests for:not,dimensionExists,selector,and,or,containsacross string, slice, map, and numeric values).LoadFilterConfigloading YAML, JSON, falling back to default, and failing on malformed configs.convert_test.gowith tests for:convertJSONToParquetscenarios: heartbeat filtering, dropped fields, query matching, malformed JSON, empty event list, and numeric exitCode formatting.decompressZlibround-trip, invalid/corrupt stream, and empty input.decryptAWSEncryptionSDKPayloadwith matching key, mismatched key, and invalid ciphertext.2. Linter & Tooling (Closes #22)
.golangci.ymlconfigured withgovet,errcheck,staticcheck,revive,gosec,misspell,ineffassign,gosimple, andgofmt.Makefilelinttarget to automatically look in$GOPATH/binifgolangci-lintis not directly in$PATH.3. Test Fixtures (Closes #22)
testdata/containing:das_events.json: Sample raw DAS database activity events list.s3_event_notification.json: Standard S3 Event Notification format.sns_s3_event.json: SNS-wrapped S3 event envelope.eventbridge_s3_event.json: Amazon EventBridge S3 event format.das_heartbeat_only.json&das_empty.json: Boundary fixtures for edge case verification.4. Bugs Uncovered & Fixed During Testing
decompressZlibwithio.LimitReader(..., 256MB)resolving gosec G110 vulnerability.parquet.NewWriterwith explicit schemaparquet.SchemaOf(new(DatabaseActivityEvent))to prevent nil pointer segmentation fault when writing empty event batches.dimensionExistsandselectorto properly returnfalsewhen dimensions or values are invalid/missing.