feat(01-01): create main.go, test scaffolding, and testdata fixtures

- main.go entry point (7 lines) delegates to cmd.Execute()
- cmd/root.go stub so go build ./... compiles (Plan 05 replaces)
- pkg/providers, pkg/storage, pkg/engine package stubs
- Test stubs with t.Skip() for providers, storage, engine packages
- testdata/samples: openai_key.txt, anthropic_key.txt, multiple_keys.txt, no_keys.txt
- go build ./... and go test ./... -short both exit 0
This commit is contained in:
salvacybersec
2026-04-05 00:04:42 +03:00
parent 7994220fbe
commit 58259cb9d3
12 changed files with 103 additions and 0 deletions

8
cmd/root.go Normal file
View File

@@ -0,0 +1,8 @@
package cmd
import "os"
// Execute is a stub. The real command tree is built in Plan 05.
func Execute() {
_ = os.Args
}

7
main.go Normal file
View File

@@ -0,0 +1,7 @@
package main
import "github.com/salvacybersec/keyhunter/cmd"
func main() {
cmd.Execute()
}

3
pkg/engine/engine.go Normal file
View File

@@ -0,0 +1,3 @@
// Package engine implements the core scanning pipeline.
// Scanner stages (keyword pre-filter, regex matching, entropy analysis) are implemented in Plan 04.
package engine

View File

@@ -0,0 +1,23 @@
package engine_test
import (
"testing"
)
// TestShannonEntropy verifies the entropy function returns expected values.
// Stub: will be implemented when entropy.go exists (Plan 04).
func TestShannonEntropy(t *testing.T) {
t.Skip("stub — implement after entropy.go exists")
}
// TestKeywordPreFilter verifies Aho-Corasick pre-filter rejects files without keywords.
// Stub: will be implemented when filter.go exists (Plan 04).
func TestKeywordPreFilter(t *testing.T) {
t.Skip("stub — implement after filter.go exists")
}
// TestScannerPipeline verifies end-to-end scan of testdata returns expected findings.
// Stub: will be implemented when engine.go exists (Plan 04).
func TestScannerPipeline(t *testing.T) {
t.Skip("stub — implement after engine.go exists")
}

View File

@@ -0,0 +1,3 @@
// Package providers handles loading and managing API key provider definitions.
// Provider YAML files are loaded from the embedded filesystem (Plan 02).
package providers

View File

@@ -0,0 +1,23 @@
package providers_test
import (
"testing"
)
// TestRegistryLoad verifies that provider YAML files are loaded from embed.FS.
// Stub: will be implemented when registry.go exists (Plan 02).
func TestRegistryLoad(t *testing.T) {
t.Skip("stub — implement after registry.go exists")
}
// TestProviderSchemaValidation verifies format_version and last_verified are required.
// Stub: will be implemented when schema.go validation exists (Plan 02).
func TestProviderSchemaValidation(t *testing.T) {
t.Skip("stub — implement after schema.go validation exists")
}
// TestAhoCorasickBuild verifies Aho-Corasick automaton builds from provider keywords.
// Stub: will be implemented when registry builds automaton (Plan 02).
func TestAhoCorasickBuild(t *testing.T) {
t.Skip("stub — implement after registry AC build exists")
}

23
pkg/storage/db_test.go Normal file
View File

@@ -0,0 +1,23 @@
package storage_test
import (
"testing"
)
// TestDBOpen verifies SQLite database opens and creates schema.
// Stub: will be implemented when db.go exists (Plan 03).
func TestDBOpen(t *testing.T) {
t.Skip("stub — implement after db.go exists")
}
// TestEncryptDecryptRoundtrip verifies AES-256-GCM encrypt/decrypt roundtrip.
// Stub: will be implemented when encrypt.go exists (Plan 03).
func TestEncryptDecryptRoundtrip(t *testing.T) {
t.Skip("stub — implement after encrypt.go exists")
}
// TestArgon2KeyDerivation verifies Argon2id produces 32-byte key deterministically.
// Stub: will be implemented when crypto.go exists (Plan 03).
func TestArgon2KeyDerivation(t *testing.T) {
t.Skip("stub — implement after crypto.go exists")
}

3
pkg/storage/storage.go Normal file
View File

@@ -0,0 +1,3 @@
// Package storage handles SQLite database operations with AES-256 encryption.
// Database schema and encryption are implemented in Plan 03.
package storage

2
testdata/samples/anthropic_key.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
# Test file: synthetic Anthropic key pattern
export ANTHROPIC_API_KEY="sk-ant-api03-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy01234567890-ABCDE"

3
testdata/samples/multiple_keys.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
# Multiple providers in one file
OPENAI_API_KEY=sk-proj-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr5678
ANTHROPIC_API_KEY=sk-ant-api03-XYZabcdefghijklmnopqrstuvwxyz01234567890ABCDEFGH-XYZAB

3
testdata/samples/no_keys.txt vendored Normal file
View File

@@ -0,0 +1,3 @@
# This file contains no API keys
# Used to verify false-positive rate is zero for clean files
Hello world

2
testdata/samples/openai_key.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
# Test file: synthetic OpenAI key pattern
OPENAI_API_KEY=sk-proj-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr1234