BloodHound icon indicating copy to clipboard operation
BloodHound copied to clipboard

feat(OpenGraph): DB - Update/Delete Extension Node Kind Schema Entry - BED-6793

Open LawsonWillard opened this issue 3 weeks ago • 1 comments

Description

Adds update and delete functions for schema node kinds Updates the schema node kind db integration test to account for these new functions

Motivation and Context

Resolves: BED-6793

This feature is required to enable OpenGraph schema management.

How Has This Been Tested?

  • Added new integration tests that cover the new functions

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 ability to update and delete schema node kinds, enabling full management of schema configurations and improved error handling for duplicates and missing items.
  • Tests

    • Expanded test coverage to exercise create/read/update/delete/list flows and error cases for schema node kinds.
  • Chores

    • Updated mock database interfaces to support new operations and added license header documentation.

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

LawsonWillard avatar Dec 01 '25 22:12 LawsonWillard

[!WARNING]

Rate limit exceeded

@LawsonWillard has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 12f86650173ce07e937d8bdbc4afb145f4ee27a5 and 236404133a4ecc5ad6ecbbe2dcbd8ef704b28e4d.

📒 Files selected for processing (1)
  • cmd/api/src/database/graphschema_test.go (2 hunks)

Walkthrough

Adds UpdateSchemaNodeKindById and DeleteSchemaNodeKindById to the OpenGraphSchema interface and BloodhoundDB implementation; expands schema-node-kind tests to a full CRUD flow; updates gomock mocks to match new methods; inserts an Apache-2.0 header and a trailing newline in two JS hook files.

Changes

Cohort / File(s) Summary
Core DB interface & implementation
cmd/api/src/database/graphschema.go
Adds UpdateSchemaNodeKindById(ctx context.Context, targetNodeKind model.SchemaNodeKind) (model.SchemaNodeKind, error) and DeleteSchemaNodeKindById(ctx context.Context, schemaNodeKindId int32) error to OpenGraphSchema and implements them on BloodhoundDB (SQL UPDATE with RETURNING, duplicate-key mapped to ErrDuplicateSchemaNodeKindName, not-found handling; DELETE with not-found handling).
Tests (CRUD)
cmd/api/src/database/graphschema_test.go
Renames test to TestBloodhoundDB_SchemaNodeKind_CRUD and expands to full CRUD: create, read, update (including duplicate-name constraint and not-found checks), delete, and post-delete not-found verifications.
Mocks (gomock)
cmd/api/src/database/mocks/db.go
Adds UpdateSchemaNodeKindById and DeleteSchemaNodeKindById mock methods and recorder entries; adjusts related edge-kind mock signatures to align with interface changes.
License header
packages/javascript/bh-shared-ui/src/hooks/useTheme.tsx
Inserts an Apache-2.0 license header only; no runtime changes.
Whitespace
packages/javascript/bh-shared-ui/src/hooks/usePZParams/usePZPathParams.tsx
Adds trailing newline; no behavior changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Check SQL statement correctness (UPDATE columns, parameter order, RETURNING scan).
  • Verify unique-constraint error mapping to ErrDuplicateSchemaNodeKindName.
  • Confirm DeleteSchemaNodeKindById returns ErrNotFound when zero rows deleted.
  • Ensure mocks in mocks/db.go precisely match updated interface signatures.
  • Review test isolation and deterministic expectations in TestBloodhoundDB_SchemaNodeKind_CRUD.

Possibly related PRs

  • SpecterOps/BloodHound#2083 — Continues implementing schema node-kind CRUD (create/get) and touches the same graphschema types and mocks.

Suggested reviewers

  • wes-mil
  • AD7ZJ
  • superlinkx

Poem

🐰 I hopped through code and made a patch,
Update here, Delete to match,
Tests now dance in CRUD delight,
Mocks reply through day and night,
Rabbit cheers — the schema springs to life!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: adding update/delete functions for schema node kinds with associated ticket reference.
Description check ✅ Passed The description covers main changes, motivation (resolves BED-6793), testing approach, and completes the checklist with documented follow-up pending architectural confirmation.
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.

coderabbitai[bot] avatar Dec 01 '25 22:12 coderabbitai[bot]

Despite approving this, I think we should wait to confirm with Dillon/Elijah about whether we want protections in the db methods versus in the api handlers

wes-mil avatar Dec 02 '25 19:12 wes-mil

Despite approving this, I think we should wait to get confirm with Dillon/Elijah about whether we want protections in the db methods versus in the api handlers

Agreed, will put this in draft until we hear back.

LawsonWillard avatar Dec 02 '25 19:12 LawsonWillard