diff --git a/api/openapi.yaml b/api/openapi.yaml index 1a9cbbf..e989261 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -1346,7 +1346,7 @@ components: type: object required: - ip - - checks + - blacklists - listed_count - score - grade @@ -1355,7 +1355,7 @@ components: type: string description: The IP address that was checked example: "192.0.2.1" - checks: + blacklists: type: array items: $ref: '#/components/schemas/BlacklistCheck' @@ -1375,3 +1375,8 @@ components: enum: [A+, A, B, C, D, E, F] description: Letter grade representation of the score example: "A+" + whitelists: + type: array + items: + $ref: '#/components/schemas/BlacklistCheck' + description: List of DNS whitelist check results (informational only) diff --git a/internal/api/handlers.go b/internal/api/handlers.go index 80c8f9a..470136e 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -41,7 +41,7 @@ import ( type EmailAnalyzer interface { AnalyzeEmailBytes(rawEmail []byte, testID uuid.UUID) (reportJSON []byte, err error) AnalyzeDomain(domain string) (dnsResults *DNSResults, score int, grade string) - CheckBlacklistIP(ip string) (checks []BlacklistCheck, listedCount int, score int, grade string, err error) + CheckBlacklistIP(ip string) (checks []BlacklistCheck, whitelists []BlacklistCheck, listedCount int, score int, grade string, err error) } // APIHandler implements the ServerInterface for handling API requests @@ -359,7 +359,7 @@ func (h *APIHandler) CheckBlacklist(c *gin.Context) { } // Perform blacklist check using analyzer - checks, listedCount, score, grade, err := h.analyzer.CheckBlacklistIP(request.Ip) + checks, whitelists, listedCount, score, grade, err := h.analyzer.CheckBlacklistIP(request.Ip) if err != nil { c.JSON(http.StatusBadRequest, Error{ Error: "invalid_ip", @@ -372,7 +372,8 @@ func (h *APIHandler) CheckBlacklist(c *gin.Context) { // Build response response := BlacklistCheckResponse{ Ip: request.Ip, - Checks: checks, + Blacklists: checks, + Whitelists: &whitelists, ListedCount: listedCount, Score: score, Grade: BlacklistCheckResponseGrade(grade), diff --git a/pkg/analyzer/analyzer.go b/pkg/analyzer/analyzer.go index 83eafe6..a16829b 100644 --- a/pkg/analyzer/analyzer.go +++ b/pkg/analyzer/analyzer.go @@ -121,12 +121,12 @@ func (a *APIAdapter) AnalyzeDomain(domain string) (*api.DNSResults, int, string) return dnsResults, score, grade } -// CheckBlacklistIP checks a single IP address against DNS blacklists -func (a *APIAdapter) CheckBlacklistIP(ip string) ([]api.BlacklistCheck, int, int, string, error) { +// CheckBlacklistIP checks a single IP address against DNS blacklists and whitelists +func (a *APIAdapter) CheckBlacklistIP(ip string) ([]api.BlacklistCheck, []api.BlacklistCheck, int, int, string, error) { // Check the IP against all configured RBLs checks, listedCount, err := a.analyzer.generator.rblChecker.CheckIP(ip) if err != nil { - return nil, 0, 0, "", err + return nil, nil, 0, 0, "", err } // Calculate score using the existing function @@ -138,5 +138,11 @@ func (a *APIAdapter) CheckBlacklistIP(ip string) ([]api.BlacklistCheck, int, int } score, grade := a.analyzer.generator.rblChecker.CalculateScore(results) - return checks, listedCount, score, grade, nil + // Check the IP against all configured DNSWLs (informational only) + whitelists, _, err := a.analyzer.generator.dnswlChecker.CheckIP(ip) + if err != nil { + whitelists = nil + } + + return checks, whitelists, listedCount, score, grade, nil } diff --git a/web/src/routes/blacklist/[ip]/+page.svelte b/web/src/routes/blacklist/[ip]/+page.svelte index 0cddb22..89676ed 100644 --- a/web/src/routes/blacklist/[ip]/+page.svelte +++ b/web/src/routes/blacklist/[ip]/+page.svelte @@ -3,7 +3,7 @@ import { onMount } from "svelte"; import { checkBlacklist } from "$lib/api"; import type { BlacklistCheckResponse } from "$lib/api/types.gen"; - import { BlacklistCard, GradeDisplay, TinySurvey } from "$lib/components"; + import { BlacklistCard, GradeDisplay, TinySurvey, WhitelistCard } from "$lib/components"; import { theme } from "$lib/stores/theme"; let ip = $derived($page.params.ip); @@ -122,8 +122,8 @@ >

This IP address is listed on {result.listed_count} of - {result.checks.length} checked blacklist{result - .checks.length > 1 + {result.blacklists.length} checked blacklist{result + .blacklists.length > 1 ? "s" : ""}.

@@ -150,12 +150,23 @@ - - +
+ +
+ +
+ + + {#if result.whitelists && result.whitelists.length > 0} +
+ +
+ {/if} +