diff --git a/internal/scan/frameworks/detect_test.go b/internal/scan/frameworks/detect_test.go index f52bfd7..d12d4e1 100644 --- a/internal/scan/frameworks/detect_test.go +++ b/internal/scan/frameworks/detect_test.go @@ -1043,3 +1043,50 @@ func TestDetectFramework_ShopifyFalsePositive(t *testing.T) { t.Errorf("false positive: article mentioning Shopify detected as Shopify (%.2f)", result.Confidence) } } + +func TestDetectFramework_SpringBoot(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(`

Whitelabel Error Page

` + + `

This application has no explicit mapping for /error, so you are seeing this as a fallback.

` + + `
There was an unexpected error (type=Internal Server Error, status=500).
` + + ``)) + })) + defer server.Close() + + result, err := frameworks.DetectFramework(server.URL, 5*time.Second, "") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if result == nil { + t.Fatal("expected result, got nil") + } + if result.Name != "Spring Boot" { + t.Errorf("expected framework 'Spring Boot', got '%s'", result.Name) + } +} + +func TestDetectFramework_SpringBootFalsePositive(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte(` + + + +

Getting started with spring-boot

+

Add spring-boot-starter-web to your pom.xml and run the app.

+ spring.io + + + `)) + })) + defer server.Close() + + result, err := frameworks.DetectFramework(server.URL, 5*time.Second, "") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if result != nil && result.Name == "Spring Boot" { + t.Errorf("expected no Spring Boot match for prose mentioning it, got %.2f confidence", result.Confidence) + } +} diff --git a/internal/scan/frameworks/detectors/backend.go b/internal/scan/frameworks/detectors/backend.go index 8713102..b5831d3 100644 --- a/internal/scan/frameworks/detectors/backend.go +++ b/internal/scan/frameworks/detectors/backend.go @@ -251,9 +251,9 @@ func (d *springBootDetector) Name() string { return "Spring Boot" } func (d *springBootDetector) Signatures() []fw.Signature { return []fw.Signature{ - {Pattern: "spring-boot", Weight: 0.5}, - {Pattern: "actuator", Weight: 0.3}, - {Pattern: "whitelabel", Weight: 0.2}, + {Pattern: "Whitelabel Error Page", Weight: 0.5}, + {Pattern: "This application has no explicit mapping for /error", Weight: 0.4}, + {Pattern: "There was an unexpected error (type=", Weight: 0.3}, } }