refactor: rename SEP to Keychain and reorganize import commands - Renamed sepunlock.go to keychainunlock.go - Changed all SEP types to Keychain types (SEPUnlockKey -> KeychainUnlockKey) - Updated type string from 'macos-sep' to 'keychain' - Moved 'secret import' to 'secret vault import' for mnemonic imports - Added new 'secret import <secret-name> --source <filename>' for file imports - Updated README to replace all 'Secure Enclave' references with 'macOS Keychain' - Updated directory structure diagrams and examples - Fixed linter error in MarkFlagRequired call - All tests passing, linter clean

This commit is contained in:
2025-05-29 06:07:15 -07:00
parent bb82d10f91
commit 659b5ba508
7 changed files with 424 additions and 330 deletions

142
Makefile
View File

@@ -1,86 +1,55 @@
# Makefile for Secret Manager macOS App with Code Signing
# Makefile for Secret Manager - Simple Go CLI Tool
# Configuration - Update these with your Apple Developer details
DEVELOPER_ID_DEV = "Apple Development: YOUR_NAME (TEAM_ID)"
DEVELOPER_ID_DIST = "Developer ID Application: YOUR_NAME (TEAM_ID)"
ENTITLEMENTS = entitlements.plist
# Configuration
BINARY_NAME = secret
# Build directories
BUILD_DIR = build
DIST_DIR = dist
default: build
default: test
# Development build with code signing
build-dev: clean
@echo "Building development version..."
# Simple build (no code signing needed)
build: clean
@echo "Building secret manager..."
go build -o $(BINARY_NAME) cmd/secret/main.go
@echo "Code signing for development..."
codesign --sign $(DEVELOPER_ID_DEV) \
--entitlements $(ENTITLEMENTS) \
--options runtime \
--force \
--verbose \
./$(BINARY_NAME)
@echo "Development build complete: ./$(BINARY_NAME)"
@echo "Build complete: ./$(BINARY_NAME)"
# Production build with code signing
build-prod: clean
@echo "Building production version..."
go build -ldflags="-s -w" -o $(BINARY_NAME) cmd/secret/main.go
@echo "Code signing for distribution..."
codesign --sign $(DEVELOPER_ID_DIST) \
--entitlements $(ENTITLEMENTS) \
--options runtime \
--force \
--verbose \
./$(BINARY_NAME)
@echo "Production build complete: ./$(BINARY_NAME)"
# Build with verbose output
build-verbose: clean
@echo "Building with verbose output..."
go build -v -o $(BINARY_NAME) cmd/secret/main.go
@echo "Build complete: ./$(BINARY_NAME)"
# Build without code signing (for testing compilation)
build-unsigned: clean
@echo "Building unsigned version..."
go build -o $(BINARY_NAME) cmd/secret/main.go
@echo "Unsigned build complete: ./$(BINARY_NAME)"
# Vet the code
vet:
@echo "Running go vet..."
go vet ./...
# Verify code signing
verify:
@echo "Verifying code signature..."
codesign -dv --verbose=4 ./$(BINARY_NAME)
@echo "\nVerifying entitlements..."
codesign -d --entitlements :- ./$(BINARY_NAME)
# Check certificates and provisioning profiles
check-signing:
@echo "Available code signing identities:"
security find-identity -v -p codesigning
@echo "\nInstalled provisioning profiles:"
ls -la ~/Library/MobileDevice/Provisioning\ Profiles/ 2>/dev/null || echo "No provisioning profiles found"
# Test with linting
test: lint
# Test with linting and vetting
test: vet lint
@echo "Running go tests..."
go test -v ./...
# Run comprehensive test script
test-comprehensive: build
@echo "Running comprehensive test script..."
@chmod +x test_secret_manager.sh
@./test_secret_manager.sh
# Run all tests (unit tests + comprehensive tests)
test-all: test test-comprehensive
# Lint the code
lint:
@echo "Running linter..."
golangci-lint run --timeout 5m
# Check all code quality (build + vet + lint + unit tests)
check: build vet lint test
# Clean build artifacts
clean:
rm -f ./$(BINARY_NAME)
rm -rf $(BUILD_DIR) $(DIST_DIR)
# Create app bundle structure (for future app store distribution)
bundle: build-prod
@echo "Creating app bundle..."
mkdir -p $(DIST_DIR)/Secret.app/Contents/MacOS
mkdir -p $(DIST_DIR)/Secret.app/Contents/Resources
cp $(BINARY_NAME) $(DIST_DIR)/Secret.app/Contents/MacOS/
@echo "App bundle created in $(DIST_DIR)/Secret.app"
# Install to /usr/local/bin (development)
install-dev: build-dev
# Install to /usr/local/bin
install: build
@echo "Installing to /usr/local/bin..."
sudo cp $(BINARY_NAME) /usr/local/bin/
@echo "Installed to /usr/local/bin/$(BINARY_NAME)"
@@ -91,23 +60,34 @@ uninstall:
sudo rm -f /usr/local/bin/$(BINARY_NAME)
@echo "Uninstalled $(BINARY_NAME)"
# Test keychain functionality
test-keychain:
@echo "Testing keychain functionality..."
@./$(BINARY_NAME) --help > /dev/null 2>&1 && echo "Binary runs successfully" || echo "Binary failed to run"
# Help target
help:
@echo "Available targets:"
@echo " build-dev - Build and sign for development"
@echo " build-prod - Build and sign for production/distribution"
@echo " build-unsigned - Build without code signing (testing only)"
@echo " verify - Verify code signature and entitlements"
@echo " check-signing - Show available certificates and profiles"
@echo " test - Run tests with linting"
@echo " lint - Run linter only"
@echo " clean - Remove build artifacts"
@echo " bundle - Create macOS app bundle"
@echo " install-dev - Install development build to /usr/local/bin"
@echo " uninstall - Remove from /usr/local/bin"
@echo " help - Show this help"
@echo "Secret Manager - Simple Go CLI Tool"
@echo "===================================="
@echo ""
@echo "Before using build-dev or build-prod, update the DEVELOPER_ID variables"
@echo "in this Makefile with your Apple Developer certificate names."
@echo "Available targets:"
@echo " build - Build the secret manager (default)"
@echo " build-verbose - Build with verbose output"
@echo " vet - Run go vet"
@echo " lint - Run linter only"
@echo " test - Run unit tests with vet and lint"
@echo " test-comprehensive - Run comprehensive test script"
@echo " test-all - Run both unit tests and comprehensive tests"
@echo " check - Run all code quality checks"
@echo " clean - Remove build artifacts"
@echo " install - Install to /usr/local/bin"
@echo " uninstall - Remove from /usr/local/bin"
@echo " test-keychain - Test basic functionality"
@echo " help - Show this help"
@echo ""
@echo "Usage:"
@echo " make build && ./secret --help"
@echo " make test-all # Run all tests"
@echo " make check # Run all quality checks"
.PHONY: default build-dev build-prod build-unsigned verify check-signing test lint clean bundle install-dev uninstall help
.PHONY: default build build-verbose vet test test-comprehensive test-all lint check clean install uninstall test-keychain help