Skip to content

Conversation

@seanjSO
Copy link

@seanjSO seanjSO commented Dec 22, 2025

Description

Adds a filter stage to the SearchCurrentNodes component to filter out edges from the list of nodes.

Motivation and Context

Resolves BED-6940

Why is this change required? What problem does it solve?

How Has This Been Tested?

  • Added a graph edge to the test cases included with the component
  • Manually tested search scenarios to ensure edges are not included in search list

Screenshots (optional):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

Summary by CodeRabbit

  • New Features

    • Added support for graph edge relationships in the search component, enabling proper handling of more complex graph structures.
  • Bug Fixes

    • Fixed filtering logic to prevent edges from being incorrectly displayed as nodes in search results.

✏️ Tip: You can customize this high-level summary in your review settings.

@seanjSO seanjSO self-assigned this Dec 22, 2025
@seanjSO seanjSO added bug Something isn't working user interface A pull request containing changes affecting the UI code. labels Dec 22, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce new GraphEdge and GraphEdges type definitions to represent graph edges, update the SearchCurrentNodes component to filter out edges during node flattening, and extend test fixtures to include edge data structures alongside existing node data.

Changes

Cohort / File(s) Summary
Type definitions
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts
Added new GraphEdge type with id1, id2, optional end1/end2 arrow configurations, optional color, optional data map, and label; added GraphEdges type as a string-keyed mapping of GraphEdge objects.
Component filtering logic
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx
Updated node flattening transformation to filter out edge-like entries by excluding items where both id1 and id2 are present before mapping to FlatNode.
Test fixtures
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.test.tsx
Widened test data type from GraphNodes to GraphNodes | GraphEdges; added sample edge entry rel_2_MemberOf_3 with id1, id2, and end2 arrow configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Type additions are straightforward without complex constraints or interactions
  • Filtering logic introduces a single condition (id1 && id2 presence check) that is easy to verify
  • Test data extension follows existing patterns with minimal cognitive overhead

Suggested reviewers

  • urangel
  • maffkipp

Poem

🐰 New edges drawn in tests so bright,
Filter them out—let nodes take flight!
Types declared with id1, id2 care,
Graph relations dance through the air! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: filtering edges from the graph search with ticket reference BED-6940.
Description check ✅ Passed The description covers required sections (Description, Motivation/Context with ticket reference, Testing approach, Type of change, and completed checklist) with sufficient detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2e3a8 and de01743.

📒 Files selected for processing (3)
  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.test.tsx
  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx
  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-09-08T19:01:53.112Z
Learnt from: jvacca-specterops
Repo: SpecterOps/BloodHound PR: 1823
File: packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/CypherSearch.tsx:108-148
Timestamp: 2025-09-08T19:01:53.112Z
Learning: In BloodHound's CypherSearch component (packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/CypherSearch.tsx), the sharing state reset for sharedIds and isPublic after the two-step permissions update is handled elsewhere in the codebase, so additional state reset callbacks in the updateQueryPermissions function are not needed.

Applied to files:

  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx
  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.test.tsx
📚 Learning: 2025-08-27T19:22:50.905Z
Learnt from: jvacca-specterops
Repo: SpecterOps/BloodHound PR: 1823
File: packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/SavedQueries/CommonSearches.tsx:71-74
Timestamp: 2025-08-27T19:22:50.905Z
Learning: In BloodHound's CommonSearches component (packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/SavedQueries/CommonSearches.tsx), the useEffect that resets filteredList to queryList when userQueries.data changes is intentional behavior - filters should be cleared when the underlying saved queries data updates.

Applied to files:

  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx
📚 Learning: 2025-09-08T19:22:49.284Z
Learnt from: jvacca-specterops
Repo: SpecterOps/BloodHound PR: 1823
File: packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/SavedQueries/TagToZoneLabelDialog.tsx:34-35
Timestamp: 2025-09-08T19:22:49.284Z
Learning: In BloodHound's TagToZoneLabelDialog component (packages/javascript/bh-shared-ui/src/views/Explore/ExploreSearch/SavedQueries/TagToZoneLabelDialog.tsx), importing AssetGroupTag type from 'js-client-library' to type tag shapes is incorrect - this type should not be used for typing tags in this context.

Applied to files:

  • packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.test.tsx
🧬 Code graph analysis (3)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx (1)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts (1)
  • FlatNode (17-17)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts (1)
packages/javascript/js-client-library/src/types.ts (4)
  • GraphEdge (396-405)
  • GraphNodes (394-394)
  • GraphNode (381-390)
  • GraphEdges (407-407)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.test.tsx (2)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts (2)
  • GraphNodes (46-46)
  • GraphEdges (47-47)
packages/javascript/js-client-library/src/types.ts (2)
  • GraphNodes (394-394)
  • GraphEdges (407-407)
🪛 GitHub Actions: Build UI
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx

[error] 45-45: ESLint: '_' is defined but never used. (no-unused-vars)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build BloodHound Container Image / Build and Package Container
  • GitHub Check: run-tests
  • GitHub Check: run-analysis
🔇 Additional comments (3)
packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/types.ts (2)

30-44: GraphEdge type definition looks correct for UI graph representation.

The structure with id1, id2, and arrow configurations is appropriate for UI graph rendering. Note that this differs from the GraphEdge in js-client-library/src/types.ts which uses source/target fields, but both serve different purposes (UI rendering vs API/domain model).


46-47: Remove the unused GraphEdges type definition or clarify its purpose.

The GraphEdges type exported from SearchCurrentNodes/types.ts (line 47) is never imported or used anywhere in the codebase. Either remove it as dead code or add documentation if it's intended for future use. Note: The GraphNodes pattern (Record-based) is used locally and differs from js-client-library's array-based design, but since GraphEdges isn't used, this is not a data flow issue.

Likely an incorrect or invalid review comment.

packages/javascript/bh-shared-ui/src/components/SearchCurrentNodes/SearchCurrentNodes.tsx (1)

49-59: Mapping logic correctly transforms node data to FlatNode.

The three-case transformation handles:

  1. Direct GraphNode objects with objectId
  2. Graph data with nested data and label structures
  3. Fallback for malformed entries

This approach properly accommodates the different node shapes that may appear in currentNodes.

@seanjSO seanjSO marked this pull request as draft December 22, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working user interface A pull request containing changes affecting the UI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants