- Register DockerHub, Kubernetes, Terraform, Helm as credentialless sources - Update RegisterAll tests and integration test to expect 32 sources
88 lines
2.2 KiB
Go
88 lines
2.2 KiB
Go
package sources
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/salvacybersec/keyhunter/pkg/providers"
|
|
"github.com/salvacybersec/keyhunter/pkg/recon"
|
|
)
|
|
|
|
// registerTestRegistry builds a minimal registry with one synthetic provider so
|
|
// BuildQueries inside individual sources does not panic.
|
|
func registerTestRegistry() *providers.Registry {
|
|
return providers.NewRegistryFromProviders([]providers.Provider{
|
|
{Name: "openai", Keywords: []string{"sk-proj-"}},
|
|
})
|
|
}
|
|
|
|
// TestRegisterAll_WiresAllThirtyTwoSources asserts that RegisterAll registers
|
|
// every Phase 10 + Phase 11 + Phase 12 + Phase 13 source by its stable name on a fresh engine.
|
|
func TestRegisterAll_WiresAllThirtyTwoSources(t *testing.T) {
|
|
eng := recon.NewEngine()
|
|
cfg := SourcesConfig{
|
|
Registry: registerTestRegistry(),
|
|
Limiters: recon.NewLimiterRegistry(),
|
|
}
|
|
RegisterAll(eng, cfg)
|
|
|
|
got := eng.List()
|
|
want := []string{
|
|
"azureblob",
|
|
"binaryedge",
|
|
"bing",
|
|
"bitbucket",
|
|
"brave",
|
|
"censys",
|
|
"codeberg",
|
|
"codesandbox",
|
|
"dockerhub",
|
|
"duckduckgo",
|
|
"fofa",
|
|
"gcs",
|
|
"gist",
|
|
"gistpaste",
|
|
"github",
|
|
"gitlab",
|
|
"google",
|
|
"helm",
|
|
"huggingface",
|
|
"k8s",
|
|
"kaggle",
|
|
"netlas",
|
|
"pastebin",
|
|
"pastesites",
|
|
"replit",
|
|
"s3",
|
|
"sandboxes",
|
|
"shodan",
|
|
"spaces",
|
|
"terraform",
|
|
"yandex",
|
|
"zoomeye",
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("RegisterAll names mismatch\n got: %v\nwant: %v", got, want)
|
|
}
|
|
}
|
|
|
|
// TestRegisterAll_MissingCredsStillRegistered asserts that sources whose
|
|
// credentials are absent are still registered (so eng.List() reports them),
|
|
// but their Enabled() returns false. This keeps the CLI surface uniform
|
|
// regardless of which tokens are configured.
|
|
func TestRegisterAll_MissingCredsStillRegistered(t *testing.T) {
|
|
eng := recon.NewEngine()
|
|
RegisterAll(eng, SourcesConfig{
|
|
Registry: registerTestRegistry(),
|
|
Limiters: recon.NewLimiterRegistry(),
|
|
})
|
|
|
|
if n := len(eng.List()); n != 32 {
|
|
t.Fatalf("expected 32 sources registered, got %d: %v", n, eng.List())
|
|
}
|
|
|
|
// SweepAll with an empty config should filter out cred-gated sources
|
|
// (github, gitlab, bitbucket, gist, kaggle) and still run the credless
|
|
// ones. We only check List() here; the integration test covers Sweep.
|
|
}
|