Skip to content

Added shortcut commands to set graph_driver config#26

Merged
chrismaddalena merged 3 commits into
mainfrom
feature/db-backend-shortcuts
Apr 23, 2026
Merged

Added shortcut commands to set graph_driver config#26
chrismaddalena merged 3 commits into
mainfrom
feature/db-backend-shortcuts

Conversation

@chrismaddalena

@chrismaddalena chrismaddalena commented Apr 23, 2026

Copy link
Copy Markdown
Member

Added shortcut commands for setting graph_driver to make it easier for users to discover how to do this for OpenGraph. This also updates some terminal output to provide a documentation reference.

Summary by CodeRabbit

  • New Features

    • Added shortcut commands to switch the backend between Neo4j and PostgreSQL; updates configuration and advises restarting containers.
  • Documentation

    • Enhanced config command output and long description with a link to the configuration guide and clearer usage examples.
  • Tests

    • Added tests for the new backend-switching shortcuts and relaxed an existing config-test to accept additional keys.

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2420d07a-4bc1-46f8-824a-71d7d270397e

📥 Commits

Reviewing files that changed from the base of the PR and between 5baa339 and 591726e.

📒 Files selected for processing (1)
  • cmd/graphDriver.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/graphDriver.go

Walkthrough

Adds two new CLI shortcuts (neo4j, pg / postgres / postgresql) to set the graph_driver config, updates the config command help to link configuration docs and show usage examples, adds tests for the shortcuts, and relaxes a test that validates total configuration keys.

Changes

Cohort / File(s) Summary
Changelog Documentation
CHANGELOG.md
Added 0.2.1 entry documenting new graph driver shortcut commands and updated config command documentation link.
Config Command Updates
cmd/config.go
Extended config command long description with documentation URL; narrowed display header and added user-facing examples for config set/config get showing graph_driver.
Graph Driver CLI
cmd/graphDriver.go
Added neo4j and pg/postgres/postgresql Cobra subcommands and setGraphDriver helper to persist graph_driver and print restart instructions.
Graph Driver Tests
cmd/graphDriver_test.go
New test exercising both shortcut commands and asserting persisted graph_driver values.
Env Test Relaxation
cmd/internal/env_test.go
Relaxed assertion: configuration key count must be >= 13 instead of exactly 13.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudge the config, switch with a hop,
Neo4j, Postgres — flip-flop!
A short command, a tiny cheer,
Containers down, then up next year.
Hooray, the graph runs without a stop!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding shortcut commands to set the graph_driver configuration, which is the primary focus of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/db-backend-shortcuts

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
cmd/config.go (1)

17-18: Consider centralizing the documentation URL in a constant.

The same URL is printed in multiple places. A shared constant prevents drift during future doc URL updates.

♻️ Suggested refactor
 package cmd
 
 import (
 	"fmt"
 
 	env "github.com/SpecterOps/BloodHound_CLI/cmd/internal"
 	"github.com/spf13/cobra"
 )
 
+const configDocsURL = "https://bloodhound.specterops.io/manage-bloodhound/bh-config"
+
 // configCmd represents the config command
 var configCmd = &cobra.Command{
@@
 Configuration values are documented here:
-https://bloodhound.specterops.io/manage-bloodhound/bh-config`,
+` + configDocsURL,
 	Run: configDisplay,
 }
@@
-	fmt.Println("  https://bloodhound.specterops.io/manage-bloodhound/bh-config")
+	fmt.Println("  " + configDocsURL)
 }

Also applies to: 34-35

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/config.go` around lines 17 - 18, Create a package-level constant (e.g.,
bhConfigURL or DocsURL) and replace the hard-coded string occurrences in
cmd/config.go (the printed
"https://bloodhound.specterops.io/manage-bloodhound/bh-config" at the two
locations shown around the current lines 17-18 and 34-35) with that constant;
update any fmt/print/log calls that use the literal so they reference the new
constant to centralize the documentation URL and avoid duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/graphDriver_test.go`:
- Around line 14-16: Extend the test around pgCmd to also exercise the alias
commands for "postgres" and "postgresql": call the command(s) or invoke the same
execution path as pgCmd for the "postgres" and "postgresql" aliases, then call
env.GetConfig([]string{"graph_driver"}) and assert the returned setting equals
"pg" (same pattern as pgSetting and assert.Equal used currently); update or add
assertions to verify both aliases set graph_driver to "pg" using the existing
pgCmd/test helpers so tests cover all new alias behaviors.

In `@cmd/graphDriver.go`:
- Around line 21-23: The Run handlers for the shortcut commands currently ignore
extra positional arguments (e.g., "neo4j foo"); add argument validation so
unexpected args are rejected: set Args: cobra.ExactArgs(0) on the command
definitions (or explicitly check len(args)==0 at the top of the Run functions
and return an error) for the command(s) that call setGraphDriver("neo4j") and
the other Run handler referenced (the other shortcut at lines 33-35), so the
commands fail fast when any positional arguments are provided.

---

Nitpick comments:
In `@cmd/config.go`:
- Around line 17-18: Create a package-level constant (e.g., bhConfigURL or
DocsURL) and replace the hard-coded string occurrences in cmd/config.go (the
printed "https://bloodhound.specterops.io/manage-bloodhound/bh-config" at the
two locations shown around the current lines 17-18 and 34-35) with that
constant; update any fmt/print/log calls that use the literal so they reference
the new constant to centralize the documentation URL and avoid duplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc804c67-0a2b-48be-8de1-e5dda171f670

📥 Commits

Reviewing files that changed from the base of the PR and between 19e79d9 and 5baa339.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • cmd/config.go
  • cmd/graphDriver.go
  • cmd/graphDriver_test.go
  • cmd/internal/env_test.go

Comment thread cmd/graphDriver_test.go
Comment thread cmd/graphDriver.go
@chrismaddalena chrismaddalena merged commit b11dac7 into main Apr 23, 2026
2 of 3 checks passed
@chrismaddalena chrismaddalena deleted the feature/db-backend-shortcuts branch April 23, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant