BloodHound icon indicating copy to clipboard operation
BloodHound copied to clipboard

Cypher shortcuts

Open JonasBK opened this issue 4 months ago • 1 comments

Description

  • Use Cypher shortcuts in saved cypher queries
  • Add Cypher shortcuts to cypher autocomplete

Motivation and Context

Resolves BED-4907

We want to make use of the nice shortcuts we have.

How Has This Been Tested?

Locally and with updated and new tests

Screenshots (optional):

image

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x] I have met the contributing prerequisites
    • Assigned myself to this PR
    • Added the appropriate labels
    • Associated an issue: https://github.com/SpecterOps/BloodHound/issues/672
    • Read the Contributing guide: https://github.com/SpecterOps/BloodHound/wiki/Contributing
  • [x] I have ensured that related documentation is up-to-date
    • Open API docs
    • Code comments (GoDocs / JSDocs)
  • [x] I have followed proper test practices
    • Added/updated tests to cover my changes
    • All new and existing tests passed

Summary by CodeRabbit

  • New Features

    • Added relationship shortcut aliases for attack path traversal (:ALL_ATTACK_PATHS, :AD_ATTACK_PATHS, :AZ_ATTACK_PATHS) usable in searches/queries.
    • Editor autocomplete and schema validation now recognize these shortcuts.
  • Refactor

    • Standardized common searches to use explicit AD/AZ attack path types for consistent, predictable query behavior (no functional change).

JonasBK avatar Aug 29 '25 08:08 JonasBK

Walkthrough

Introduces centralized attack path relationship shortcut aliases and integrates them into schema awareness. Replaces dynamically derived edge lists in Cypher queries with explicit shortcut labels for AD and Azure paths. Updates tests to accept and verify these shortcuts. Adjusts graphSchema to include shortcut aliases among relationship types.

Changes

Cohort / File(s) Summary
Shortcut Aliases Module
packages/javascript/bh-shared-ui/src/attackPathShortcuts.ts
Adds ATTACK_PATH_RELATIONSHIP_SHORTCUTS (':ALL_ATTACK_PATHS', ':AD_ATTACK_PATHS', ':AZ_ATTACK_PATHS') and AttackPathRelationshipShortcut type; documents server-side macro expansion.
Query Updates to Use Shortcuts
packages/javascript/bh-shared-ui/src/commonSearchesAGI.ts, packages/javascript/bh-shared-ui/src/commonSearchesAGT.ts
Removes dynamic edge-type derivations; replaces usages with [:AD_ATTACK_PATHS*...] and [:AZ_ATTACK_PATHS*...] in Cypher queries.
Schema Awareness of Shortcuts
packages/javascript/bh-shared-ui/src/constants.ts
Updates graphSchema() to append relationship shortcut aliases to known relationship types for editor/autocomplete and filtering.
Tests: Accept and Verify Shortcuts
packages/javascript/bh-shared-ui/src/commonSearches.test.ts, packages/javascript/bh-shared-ui/src/constants.test.ts
Adjusts validation to allow shortcut aliases and adds test ensuring graphSchema() includes all shortcut aliases in relationshipTypes.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement, user interface

Suggested reviewers

  • neumachen
  • mvlipka

Poem

I skitter through graphs with whiskered delight,
New paths marked clear for my moonlit flight—
AD and AZ, shortcuts I chase,
Hops turn to hops in a swift, tidy trace.
With schema seeds tucked in my pack,
I nibble tests—no edges lack. 🐇✨

[!TIP]

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch bed-4907

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Aug 29 '25 08:08 coderabbitai[bot]