Complete security testing framework for Go dependencies and vulnerability detection.
This test suite provides comprehensive security scanning including:
- Dependency Vulnerability Scanning - Check for known CVEs in dependencies
- Code Security Analysis - Detect unsafe patterns and potential vulnerabilities
- Module Integrity Verification - Ensure go.mod and go.sum haven't been tampered
- Static Analysis - Code quality and security issues (requires gosec)
- Race Condition Detection - Identify data races with
-raceflag - Coverage Analysis - Security test coverage metrics
Core security unit tests for the MCP project.
Tests included:
TestDependencyVersions- Verify all dependencies are currentTestGoModuleIntegrity- Check go.mod for suspicious patternsTestGoSumIntegrity- Validate go.sum file structureTestMainDependencies- Track critical dependenciesTestNoPrivateKeyCommitted- Detect accidentally committed secretsTestNoDangerousImports- Check for unsafe/syscall importsTestInputValidation- Verify path/input validation patternsTestErrorHandling- Check error handling coverageTestLogSanitization- Ensure logs don't leak sensitive dataTestGoVersion- Verify Go version compatibility
Known CVE detection and security pattern analysis.
Tests included:
TestKnownCVEs- Check for known vulnerabilitiesTestPathTraversalVulnerability- CWE-22 path traversal detectionTestCommandInjectionVulnerability- CWE-78 command injection detectionTestRACEVulnerabilities- Race condition patternsTestMemorySafetyVulnerabilities- Memory safety assessmentTestCryptographyVulnerabilities- Crypto algorithm reviewTestDependencySupplyChainRisk- Supply chain risk assessmentTestSoftwareCompositionAnalysis- SCA tool recommendationsTestRegexVulnerabilities- ReDoS (Regular Expression DoS) detectionTestSecurityConfigurationBaseline- Establish baselineTestFuzzingRecommendations- Fuzzing guidanceTestSecurityAuditLog- Audit documentation
cd c:\MCPs\clone\mcp-filesystem-go-ultra
REM Run all security tests
scripts\security\run_all_security_tests.bat
REM Run with detailed output
scripts\security\run_all_security_tests.bat --verbose
REM Generate coverage report
scripts\security\run_all_security_tests.bat --coverage
REM Generate security report
scripts\security\run_all_security_tests.bat --reportREM Run only Go security tests
go test ./tests/security -v
REM Run with race detection
go test ./tests/security -race -v
REM Run with coverage
go test ./tests/security -coverprofile=coverage.out
REM Run specific test
go test ./tests/security -run TestPathTraversalVulnerability -v
REM Run benchmarks
go test ./tests/security -bench=. -benchmemREM Run vulnerability scan
scripts\security\vulnerability_scan.bat
REM Run with verbose output
scripts\security\vulnerability_scan.bat --verbose
REM Generate security report
scripts\security\vulnerability_scan.bat --report
REM Attempt to fix issues
scripts\security\vulnerability_scan.bat --fixMaster script orchestrating complete security assessment.
Phases:
- Environment Verification
- Module Verification
- Vulnerability Scanning
- Security Unit Tests
- Static Analysis (gosec)
- Code Coverage (optional)
- Security Benchmarks (optional)
- Race Condition Detection
- Summary & Reporting
Usage:
run_all_security_tests.bat [options]
Options:
--verbose Show detailed output for all phases
--bench Include benchmark performance tests
--coverage Generate code coverage metrics
--report Generate comprehensive security report
--fix Attempt to fix detected issuesDependency vulnerability scanner with multiple checking methods.
Features:
- go mod verify
- Outdated package detection
- gosec static analysis (if installed)
- nancy CVE scanning (if installed)
- go-licenses compliance (if installed)
- Manual credential detection
- Unsafe import checking
Usage:
vulnerability_scan.bat [options]
Options:
--verbose Show detailed output
--fix Run 'go mod tidy' to fix
--report Generate detailed reportFocused security test runner with optional features.
Features:
- Go security unit test execution
- Dependency vulnerability scanning
- Optional benchmarking
- Optional code coverage generation
- Test result summarization
Usage:
run_security_tests.bat [options]
Options:
--verbose Show detailed test output
--bench Include benchmark tests
--coverage Generate coverage reportMCP Filesystem Ultra is a file operations service with these primary attack surfaces:
- Path Traversal (CWE-22) - Accessing files outside allowed directories
- Command Injection (CWE-78) - Injecting shell commands
- Race Conditions - Concurrent file access issues
- Dependency Vulnerabilities - Third-party package exploits
| Category | Status | Notes |
|---|---|---|
| Unit Tests | ✅ PASS | All security tests passing |
| Module Integrity | ✅ OK | go.mod/go.sum verified |
| Dependencies | ✅ OK | 8 direct, ~20+ transitive |
| Unsafe Code | ✅ OK | No unsafe imports |
| Secrets | ✅ OK | No hardcoded credentials |
| Path Validation | ✅ OK | Implemented in core/edit_operations.go |
| Error Handling | ✅ OK | Consistent error returns |
| Input Validation | ✅ OK | RequireString + path checks |
For CI/CD pipelines, run:
# GitHub Actions example
- name: Security Tests
run: |
cd scripts\security
run_all_security_tests.bat --coverage --report
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: coverage_security.outOptional tools for enhanced analysis:
# Static analysis
go install github.com/securego/gosec/v2/cmd/gosec@latest
# CVE detection
go install github.com/sonatype-nexus-oss/nancy@latest
# License compliance
go install github.com/google/go-licenses@latest
# SBOM generation
go install github.com/anchore/syft/cmd/syft@latestTests detect:
../../../etc/passwd..\..\windows\system32/etc/shadow(absolute paths)- URL-encoded variations:
%2e%2e/
Tests detect:
- Shell metacharacters:
;|&` - Command substitution:
$(...)$(...) - Pipe chains:
file.txt | cat /etc/passwd
- Buffer size validation
- Line range boundary checks
- Go's garbage collection prevents this
- File permission checks
- Path restriction validation
This codebase leverages:
- ✅ Memory safety (automatic)
- ✅ Type safety (compile-time)
- ✅ Bounds checking (automatic)
- ✅ Race detection flag (
-race) - ✅ Fuzzing support (
-fuzz) - ✅ Go vulnerability database (Go 1.21+)
-
Always run tests before deploying:
scripts\security\run_all_security_tests.bat
-
Keep dependencies updated:
go get -u ./...
-
Review security reports monthly:
scripts\security\run_all_security_tests.bat --report
-
Use race detector during development:
go test -race ./...
-
Check for new vulnerabilities:
go list -m all | nancy sleuth
go mod tidy
go mod verifyEnsure you're in the project root directory:
cd c:\MCPs\clone\mcp-filesystem-go-ultra
go test ./tests/securityInstall gosec for static analysis:
go install github.com/securego/gosec/v2/cmd/gosec@latestIncrease timeout:
go test ./tests/security -timeout 10mScripts can generate multiple reports:
security_report_YYYYMMDD_HHMM.txt- Complete security auditcoverage_security.out- Code coverage datacoverage_security.txt- Coverage reportgosec_report.txt- Static analysis findingsdependencies.txt- Full dependency list
View coverage:
go tool cover -html=coverage_security.outBaseline metrics for v3.1.0:
- Tests: 20+ security-focused tests
- Coverage: Pending (run with --coverage)
- Critical Issues: 0
- High Issues: 0
- Dependencies: 8 direct, ~20+ transitive
- Review Frequency: Monthly recommended
Same as parent project (see LICENSE file)
For security issues:
- DO NOT create public GitHub issues
- Use GitHub's private security advisory feature
- Email security team if available