/* ·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━· : : : █▀ █ █▀▀ · Blazing-fast pentesting suite : : ▄█ █ █▀ · BSD 3-Clause License : : : : (c) 2022-2026 vmfunc, xyzeva, : : lunchcat alumni & contributors : : : ·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━· */ package detectors import ( "net/http" "testing" fw "github.com/vmfunc/sif/internal/scan/frameworks" ) func accHeader(name, value string) http.Header { h := http.Header{} h.Set(name, value) return h } func TestDetectorAccuracy_FalsePositives(t *testing.T) { cases := []struct { name string det fw.Detector body string h http.Header }{ {"Express checkout cookie", &expressDetector{}, "", accHeader("Set-Cookie", "express_checkout=1; path=/")}, {"Flask werkzeug docs link", &flaskDetector{}, "", accHeader("Link", "; rel=help")}, {"Symfony domain link", &symfonyDetector{}, "", accHeader("Link", "; rel=help")}, {"Shopify cdn link header", &shopifyDetector{}, "", accHeader("Link", "; rel=preload")}, {"Shopify cdn body only", &shopifyDetector{}, ``, http.Header{}}, {"Spring Boot tutorial prose", &springBootDetector{}, `
To fix the Whitelabel Error Page in Spring Boot, add a controller.
`, http.Header{}}, {"Remix audio asset", &remixDetector{}, ``, http.Header{}}, {"Django settings tutorial", &djangoDetector{}, `
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth']
from django.core.exceptions import ValidationError
`, http.Header{}}, {"Magento migration guide with image mime", &magentoDetector{}, `

How to migrate your Magento store

A guide to Magento 2.
`, http.Header{}}, {"Gatsby plugin comparison prose", &gatsbyDetector{}, `
gatsby-image and gatsby-plugin-sharp used to be the standard way to handle images before gatsby-plugin-image.
`, http.Header{}}, {"Svelte ecosystem comparison prose", &svelteDetector{}, `
popular svelte-native and svelte-check tools round out the ecosystem.
`, http.Header{}}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if conf, _ := c.det.Detect(c.body, c.h); conf > 0.5 { t.Errorf("false positive: confidence = %.3f, want <= 0.5", conf) } }) } } func TestDetectorAccuracy_TruePositives(t *testing.T) { cases := []struct { name string det fw.Detector body string h http.Header }{ {"Express powered-by", &expressDetector{}, "", accHeader("X-Powered-By", "Express")}, {"Flask werkzeug server", &flaskDetector{}, "", accHeader("Server", "Werkzeug/2.3.0 Python/3.11")}, {"Symfony debug token", &symfonyDetector{}, "", accHeader("X-Debug-Token", "a1b2c3")}, {"Shopify storefront header", &shopifyDetector{}, "", accHeader("X-Shopify-Stage", "production")}, {"Spring Boot whitelabel page", &springBootDetector{}, `

Whitelabel Error Page

This application has no explicit mapping for /error

There was an unexpected error (type=Not Found, status=404).
`, http.Header{}}, {"Remix context", &remixDetector{}, ``, http.Header{}}, {"Django admin login form", &djangoDetector{}, `
`, accHeader("Set-Cookie", "csrftoken=xyz; Path=/")}, {"Magento storefront markup", &magentoDetector{}, ``, http.Header{}}, {"Gatsby root div and page-data", &gatsbyDetector{}, `
`, http.Header{}}, {"Svelte runtime global and internal import", &svelteDetector{}, ``, http.Header{}}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if conf, _ := c.det.Detect(c.body, c.h); conf <= 0.5 { t.Errorf("missed: confidence = %.3f, want > 0.5", conf) } }) } } func TestDetectorAccuracy_RemovedDetectors(t *testing.T) { for _, name := range []string{"Gin", "FastAPI"} { if _, ok := fw.GetDetector(name); ok { t.Errorf("%s detector should have been removed (no clean passive signal)", name) } } }