feat(graph-ui): dead-code filtering, node code preview, GitHub deep-links#863
Merged
Conversation
…inks Distilled from #789 (safe features only). Adds backend dead-code classification (status + in_calls in the layout JSON), a GET /api/repo-info endpoint for GitHub deep-links, and the frontend dead-code filters, node code preview, and deep-links. The render-cap revert was dropped (kept 2000 for DEFAULT_MAX_NODES/HARD_MAX_NODES and GRAPH_RENDER_NODE_LIMIT); the sidebar regex-search refactor was omitted. Security fixes over the original: repo-info strips credentials from any returned remote_url; the legitimate https blob-URL construction is allow-listed so the static gate passes; libgit2 is not re-initialized/shutdown per request (reuses the process-wide init from cbm_alloc_init); deep-link path segments are URL-encoded. Co-authored-by: Andy Zehady <azehady@ciroos.ai> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> # Conflicts: # graph-ui/src/components/FilterPanel.tsx
…tures (UI security audit) Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(graph-ui): dead-code filtering, node code preview, GitHub deep-links
Distilled from #789 (safe features only). Original feature authorship: Andy Zehady
azehady@ciroos.ai. This PR takes the reviewable, low-risk parts of that 6-concern
bundle, drops the risky ones, and fixes the issues flagged in review.
Refs #789.
What this adds
Backend — dead-code classification (
src/ui/layout3d.c/.h)is_entry_point/is_test/is_exported/route_path.cbm_store_batch_count_degrees(chunked at 500 ids — the batch IN-clause caps at~2045 placeholders and silently drops the tail beyond that, which would masquerade
as dead code).
status(dead/single/entry/test/exported/normal/structural) andin_callsinto the layout JSON, plusqualified_name/start_line/end_line.as dead code.
Backend —
GET /api/repo-info(src/ui/http_server.c)originremote via libgit2 and normalizes it (scp / ssh / https) to aweb_base+blob_basefor GitHub deep-links.Frontend
show-only-dead, hide-entry-points, hide-tests). Pairs with the
is_testbackendalready on main (fix(extract-rust): mark #[test]/#[tokio::test] fns is_test so they are filtered #857). (
FilterPanel.tsx,GraphTab.tsx,lib/colors.ts,lib/types.ts)/rpc get_code_snippettool,rendered as React-escaped text inside
<pre>— neverdangerouslySetInnerHTML/innerHTML. (NodeDetailPanel.tsx)target="_blank" rel="noopener noreferrer". (NodeDetailPanel.tsx,NodeTooltip.tsx)What was dropped (and why)
DEFAULT_MAX_NODES/HARD_MAX_NODES(src/ui/layout3d.c) andGRAPH_RENDER_NODE_LIMIT = 2000(useGraphData.ts).useGraphData.test.ts(whichasserts 2000) is unchanged and green.
#include <git2/sys/alloc.h>build fix. Already on main via fix(build): gate libgit2 allocator support #829.new RegExp(search)per keystrokeis a ReDoS smell and a separate concern — omitted entirely;
Sidebar.tsxis untouched.Security notes addressed (review fixes)
/api/repo-infonever echoeshttps://user:token@host/…:the returned
remote_urlis credential-stripped (cbm_ui_git_strip_credentials), andweb_base/blob_baseare built cred-free. Guarded by a reproduce-first test.by
cbm_alloc_init(which binds its allocator to mimalloc); re-init/shutdown per HTTPrequest could drop the global refcount and tear that binding down. The handler reuses
the global state.
https://blob-URL construction is added toscripts/security-allowlist.txt(URL:https://%s) sosecurity-staticpasses; thisis URL construction, not a network call.
githubUrl()percent-encodes each path segment(
encodeURI/encodeURIComponent), so an unusualfile_pathcan't break or escape theURL. The scheme is already https-forced by the backend.
Tests
tests/test_ui.c—layout_dead_code_classification: dead / entry / test (flag andfile-path) / exported / single / normal / structural, and
in_callsdegree counting;asserts the classification survives JSON serialization.
tests/test_httpd.c—repo_info_web_base_normalizes_to_httpsandrepo_info_strips_credentials_from_remote: https normalization across scp/ssh/https andcredential stripping (incl. an
@-in-path negative case).graph-uivitest —NodeDetailPanel.test.tsxproves the code preview renders a<script>payload as literal text (no injected element, no execution) and builds anhttps deep-link with URL-encoded path segments;
GraphTab.deadcode.test.tsxcovers thestatus filter toggles.
Verification
make -f Makefile.cbm cbm(-Werror clean),make -f Makefile.cbm lint-ciclean,security audit passes (URL gate clears),
test-runner ui(17/17) +httpd(40/40) green.npx vitest run(20/20, incl.useGraphDataat 2000),npx tsc -bclean.