Skip to content

Commit bf963fa

Browse files
hyperpolymathclaude
andcommitted
fix(backend): security scanner KeyError on miniKanren port findings
The convert_kanren_findings/1 function accessed finding.message and finding.severity on all findings, but proto_findings from the kanren engine only have :port, :protocol, :risk, :source (no :message or :severity). Now uses Map.get with fallbacks for both finding shapes. Also verified full backend stack: - PostgreSQL via Podman container (postgres:17-alpine) - Ecto migrations run (stacks, users, user_settings tables) - DbStore auto-fallback working (NativeBridge.available?/0) - POST /api/stacks creates + persists to PostgreSQL - POST /api/stacks/:id/validate returns real findings (12 checks) - POST /api/stacks/:id/security-scan returns real vulnerabilities - POST /api/stacks/:id/gap-analysis returns 8 real gaps with fixes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b6e302b commit bf963fa

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

backend/lib/stapeln/security_scanner.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,14 @@ defmodule Stapeln.SecurityScanner do
474474

475475
defp convert_kanren_findings(port_findings) do
476476
Enum.map(port_findings, fn finding ->
477+
# Handle both db_findings (%{message, severity}) and proto_findings (%{protocol, risk})
478+
message = Map.get(finding, :message, "Port #{finding.port} (#{Map.get(finding, :protocol, "unknown")})")
479+
severity = Map.get(finding, :severity, Map.get(finding, :risk, :info))
480+
477481
%{
478-
title: finding.message,
479-
severity: Atom.to_string(finding.severity),
480-
description: "miniKanren reasoning engine flagged port #{finding.port}: #{finding.message}",
482+
title: message,
483+
severity: if(is_atom(severity), do: Atom.to_string(severity), else: severity),
484+
description: "miniKanren reasoning engine flagged port #{finding.port}: #{message}",
481485
affectedComponent: "port:#{finding.port}",
482486
cveId: nil,
483487
fixAvailable: false,

0 commit comments

Comments
 (0)