Skip to content

Nsm modernize with tests#1

Merged
prasincs merged 8 commits into
mainfrom
nsm-modernize-with-tests
Nov 2, 2025
Merged

Nsm modernize with tests#1
prasincs merged 8 commits into
mainfrom
nsm-modernize-with-tests

Conversation

@prasincs
Copy link
Copy Markdown
Owner

@prasincs prasincs commented Nov 2, 2025

Same as hf#6 but I want to make sure CI runs

prasincs and others added 8 commits November 2, 2025 13:21
I used claude to review the code and manually checked every change

- Update Go 1.15 → 1.23, CBOR library v2.2.0 → v2.7.0
- Fix potential panic on empty slice access in IOCTL operations
- Fix resource leaks: only clear fd on successful close
- Fix infinite loop in Read() entropy generation
- Fix inconsistent nil checking patterns throughout codebase
- Fix duplicate JSON tags in response structs
- Document blocking IOCTL behavior and performance implications
- Add basic GitHub Actions CI workflow

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix buffer overrun: validate response length before slicing
- Fix type assertion panics: add safe checks for pool operations
- Fix race condition: use defer for cleanup in Close() method
- Add input validation: check request/response sizes and nil values
- Add error context: wrap CBOR and encoding errors with details
- Fix README examples: correct defer placement after error checks
- Update README: use consistent Go idioms (err != nil)

Addresses memory safety issues that could cause crashes or
data corruption in production AWS Nitro Enclave environments.

Co-Authored-By: Claude <noreply@anthropic.com>
- Add tests validating empty buffer protection against panics
- Add tests for nil session handling and proper error returns
- Add tests for resource cleanup with defer in Close() method
- Add tests for type-safe pool operations without panics
- Add tests for input validation and closed session detection
- Fix nil pool access: check pools before use in Send/Read
- Modernize: use 'any' instead of 'interface{}' for Go 1.18+
- All tests pass, validating production safety of security fixes

Co-Authored-By: Claude <noreply@anthropic.com>
- Add test coverage for ioc package: IOCTL command generation (100%)
- Add test coverage for request package: all Encoded() methods (100%)
- Add test coverage for response package: CBOR unmarshaling (100%)
- Extend nsm package tests: sendMarshaled validation, successful paths
- Improve main package coverage from 44.6% to 63.4%
- Add tests for OpenDefaultSession, pool type safety, error handling
- Tests validate all security fixes and core functionality
- All tests are focused, human-reviewable, and production-ready

Co-Authored-By: Claude <noreply@anthropic.com>
- Add GitHub Actions workflow with lint, test, and coverage checks
- Pin all dependencies: golangci-lint v1.61.0, actions@v4/v5/v6
- Use go.mod version (1.23) for consistent builds
- Enforce 60% minimum test coverage with built-in tooling
- Add Makefile for local development with same standards
- Self-contained pipeline - no external services or tokens required
- Add .gitignore with https://github.com/github/gitignore/blob/main/Go.gitignore

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix unused parameters in test functions by replacing with underscore
- Organize constants and variables at top of nsm.go file
- Add tools.go for development dependencies with go run approach
- Update Makefile to use go run for tools instead of install
- Update CI workflow to use Makefile targets for consistency

Co-Authored-By: Claude <noreply@anthropic.com>
- Add make fmt command with gofmt and goimports
- Make lint target depend on fmt to ensure proper formatting
- Fix unused parameters in test functions by using underscore
- Fix nil pointer dereference warning with else-if pattern
- Fix allocation warnings by using original pool objects
- Add tools.go for development dependencies with go:build tools tag
- Update Makefile to use go run for tools instead of installation
- Ensure consistent code formatting across all files

Co-Authored-By: Claude <noreply@anthropic.com>
@prasincs prasincs merged commit 97eb7f4 into main Nov 2, 2025
4 checks passed
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.

1 participant