Skip to content

Commit 3eb294f

Browse files
committed
fix(ui): serve the upstream issues URL from the backend
The UI security audit (security-ui.sh, layer A1) forbids hardcoded external URLs in graph-ui source — the callout's GitHub issues link tripped it on all pr-smoke legs. Follow the established pattern for external targets (/api/repo-info deep-links): /api/ui-config now carries upstream_issues_url and the callout consumes it, rendering the issue button only when the backend provides an https URL. The protocol check uses a regex literal on purpose: a bare protocol string in source also aborts the audit's URL extraction. Verified: security-ui.sh passes locally; /api/ui-config serves the URL; the callout opens with the prefilled link in the browser; frontend build + tests green. Refs DeusData#963 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 660b90d commit 3eb294f

2 files changed

Lines changed: 54 additions & 17 deletions

File tree

‎graph-ui/src/components/MissedCallout.tsx‎

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
import { useEffect, useState } from "react";
22
import type { GraphNode } from "../lib/types";
33

4-
/* Upstream tracker for indexing gaps — issues land on the codebase-memory-mcp
5-
* project itself (the tool that failed to index), never the user's repo. */
6-
const UPSTREAM_ISSUES_URL = "https://github.com/DeusData/codebase-memory-mcp/issues/new";
4+
/* Upstream tracker for indexing gaps. The URL is served by the backend
5+
* (/api/ui-config) — the UI security audit forbids hardcoded external URLs in
6+
* graph-ui source, so external targets come from an auditable backend
7+
* response (same pattern as the /api/repo-info deep-links). */
8+
let issuesUrlRequest: Promise<string | null> | null = null;
9+
10+
function fetchIssuesUrl(): Promise<string | null> {
11+
issuesUrlRequest ??= fetch("/api/ui-config")
12+
.then((r) => (r.ok ? r.json() : null))
13+
.then((cfg) => {
14+
const url: unknown = cfg?.upstream_issues_url;
15+
/* Accept only an https URL (regex literal on purpose — the UI security
16+
* audit greps source for protocol strings). */
17+
return typeof url === "string" && /^https:\/\//.test(url) ? url : null;
18+
})
19+
.catch(() => null);
20+
return issuesUrlRequest;
21+
}
722

823
interface MissedCalloutProps {
924
node: GraphNode;
1025
project: string | null;
1126
onClose: () => void;
1227
}
1328

14-
function buildIssueUrl(path: string, project: string | null): string {
29+
function buildIssueUrl(base: string, path: string, project: string | null): string {
1530
const title = `Indexing gap: ${path}`;
1631
const body = [
1732
"## Not fully indexed (best-effort coverage signal)",
@@ -25,17 +40,20 @@ function buildIssueUrl(path: string, project: string | null): string {
2540
"",
2641
"_Reported from the graph UI's missed-coverage view._",
2742
].join("\n");
28-
return `${UPSTREAM_ISSUES_URL}?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`;
43+
return `${base}?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`;
2944
}
3045

31-
function buildAgentPrompt(path: string, project: string | null): string {
46+
function buildAgentPrompt(issuesUrl: string | null, path: string, project: string | null): string {
47+
const where = issuesUrl
48+
? `file a GitHub issue at ${issuesUrl}`
49+
: "file a GitHub issue on the codebase-memory-mcp project";
3250
return (
3351
`codebase-memory-mcp could not fully index \`${path}\`` +
3452
(project ? ` (project \`${project}\`)` : "") +
3553
" — best-effort coverage signal. Please: " +
3654
"1) call the index_status MCP tool and note this file's flagged line ranges under parse_partial; " +
3755
"2) read those ranges in the file and summarize which construct fails to parse; " +
38-
`3) file a GitHub issue at ${UPSTREAM_ISSUES_URL} titled "Indexing gap: ${path}" ` +
56+
`3) ${where}, titled "Indexing gap: ${path}", ` +
3957
"with the summary — include a minimal reproducible snippet ONLY if the code is shareable."
4058
);
4159
}
@@ -46,6 +64,17 @@ function buildAgentPrompt(path: string, project: string | null): string {
4664
export function MissedCallout({ node, project, onClose }: MissedCalloutProps) {
4765
const path = node.file_path || node.name;
4866
const [copied, setCopied] = useState(false);
67+
const [issuesUrl, setIssuesUrl] = useState<string | null>(null);
68+
69+
useEffect(() => {
70+
let cancelled = false;
71+
fetchIssuesUrl().then((url) => {
72+
if (!cancelled) setIssuesUrl(url);
73+
});
74+
return () => {
75+
cancelled = true;
76+
};
77+
}, []);
4978

5079
useEffect(() => {
5180
if (!copied) return;
@@ -55,7 +84,7 @@ export function MissedCallout({ node, project, onClose }: MissedCalloutProps) {
5584

5685
const copyPrompt = async () => {
5786
try {
58-
await navigator.clipboard.writeText(buildAgentPrompt(path, project));
87+
await navigator.clipboard.writeText(buildAgentPrompt(issuesUrl, path, project));
5988
setCopied(true);
6089
} catch {
6190
/* clipboard unavailable (permissions/insecure context) — leave the
@@ -103,14 +132,16 @@ export function MissedCallout({ node, project, onClose }: MissedCalloutProps) {
103132
>
104133
{copied ? "✓ Copied — paste it to your agent" : "Copy agent prompt"}
105134
</button>
106-
<a
107-
href={buildIssueUrl(path, project)}
108-
target="_blank"
109-
rel="noreferrer"
110-
className="text-[12px] font-medium rounded-md border border-white/10 bg-white/[0.03] text-foreground/80 hover:bg-white/[0.07] px-3 py-1.5 transition-all"
111-
>
112-
File a GitHub issue (prefilled) ↗
113-
</a>
135+
{issuesUrl && (
136+
<a
137+
href={buildIssueUrl(issuesUrl, path, project)}
138+
target="_blank"
139+
rel="noreferrer"
140+
className="text-[12px] font-medium rounded-md border border-white/10 bg-white/[0.03] text-foreground/80 hover:bg-white/[0.07] px-3 py-1.5 transition-all"
141+
>
142+
File a GitHub issue (prefilled) ↗
143+
</a>
144+
)}
114145
</div>
115146

116147
<p className="text-[10px] leading-snug text-foreground/35 mt-1">

‎src/ui/http_server.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ static void handle_ui_config(cbm_http_conn_t *c, const cbm_http_req_t *req) {
116116
if (cfg) {
117117
cbm_config_close(cfg);
118118
}
119-
cbm_http_replyf(c, 200, g_cors_json, "{\"lang\":\"%s\"}", lang_buf);
119+
/* upstream_issues_url: where the missed-coverage callout (#963) sends
120+
* edge-case reports. Served from the backend on purpose — the UI security
121+
* audit forbids hardcoded external URLs in graph-ui source (external
122+
* targets must come from an auditable backend response, same pattern as
123+
* the /api/repo-info deep-links). */
124+
cbm_http_replyf(c, 200, g_cors_json, "{\"lang\":\"%s\",\"upstream_issues_url\":\"%s\"}",
125+
lang_buf, "https://github.com/DeusData/codebase-memory-mcp/issues/new");
120126
}
121127

122128
/* ── Server state ─────────────────────────────────────────────── */

0 commit comments

Comments
 (0)