From 92421d01b599f74c6511a71528b1f3cb273933ba Mon Sep 17 00:00:00 2001 From: John Hopper Date: Wed, 18 Dec 2024 09:26:17 -0800 Subject: [PATCH] chore: BED-5168 - prepare for review --- cmd/api/src/api/v2/integration/ingest.go | 3 ++- .../cypher/models/pgsql/test/translation_cases/nodes.sql | 8 ++++++++ .../go/cypher/models/pgsql/translate/translator_test.go | 3 ++- .../cypher/models/pgsql/visualization/visualizer_test.go | 3 ++- packages/go/dawgs/drivers/pg/manager.go | 4 ---- packages/go/dawgs/drivers/pg/node_test.go | 3 ++- packages/go/dawgs/drivers/pg/pgutil/kindmapper.go | 1 + 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd/api/src/api/v2/integration/ingest.go b/cmd/api/src/api/v2/integration/ingest.go index 240d3a3dc..ec03c20e0 100644 --- a/cmd/api/src/api/v2/integration/ingest.go +++ b/cmd/api/src/api/v2/integration/ingest.go @@ -18,10 +18,11 @@ package integration import ( "encoding/json" - "github.com/specterops/bloodhound/graphschema" "strings" "time" + "github.com/specterops/bloodhound/graphschema" + "github.com/specterops/bloodhound/dawgs/graph" "github.com/specterops/bloodhound/src/model" "github.com/specterops/bloodhound/src/model/appcfg" diff --git a/packages/go/cypher/models/pgsql/test/translation_cases/nodes.sql b/packages/go/cypher/models/pgsql/test/translation_cases/nodes.sql index 31ec138a2..02181bfc8 100644 --- a/packages/go/cypher/models/pgsql/test/translation_cases/nodes.sql +++ b/packages/go/cypher/models/pgsql/test/translation_cases/nodes.sql @@ -585,3 +585,11 @@ with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 and coalesce(n0.properties -> 'a', n0.properties -> 'b')::int8 = 1) select s0.n0 as n from s0; + +-- case: match (n:NodeKind1) where 1 = coalesce(n.a, n.b) return n +with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite as n0 + from node n0 + where n0.kind_ids operator (pg_catalog.&&) array [1]::int2[] + and 1 = coalesce(n0.properties -> 'a', n0.properties -> 'b')::int8) +select s0.n0 as n +from s0; diff --git a/packages/go/cypher/models/pgsql/translate/translator_test.go b/packages/go/cypher/models/pgsql/translate/translator_test.go index c14053985..724211293 100644 --- a/packages/go/cypher/models/pgsql/translate/translator_test.go +++ b/packages/go/cypher/models/pgsql/translate/translator_test.go @@ -18,9 +18,10 @@ package translate_test import ( "fmt" - "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" "testing" + "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" + "github.com/specterops/bloodhound/cypher/models/pgsql" "github.com/specterops/bloodhound/cypher/models/pgsql/test" "github.com/specterops/bloodhound/dawgs/graph" diff --git a/packages/go/cypher/models/pgsql/visualization/visualizer_test.go b/packages/go/cypher/models/pgsql/visualization/visualizer_test.go index fd50b3964..5ee79d401 100644 --- a/packages/go/cypher/models/pgsql/visualization/visualizer_test.go +++ b/packages/go/cypher/models/pgsql/visualization/visualizer_test.go @@ -19,9 +19,10 @@ package visualization import ( "bytes" "context" - "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" "testing" + "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" + "github.com/specterops/bloodhound/cypher/frontend" "github.com/specterops/bloodhound/cypher/models/pgsql/translate" "github.com/stretchr/testify/require" diff --git a/packages/go/dawgs/drivers/pg/manager.go b/packages/go/dawgs/drivers/pg/manager.go index 1ed79715c..759167013 100644 --- a/packages/go/dawgs/drivers/pg/manager.go +++ b/packages/go/dawgs/drivers/pg/manager.go @@ -23,8 +23,6 @@ import ( "strings" "sync" - "github.com/specterops/bloodhound/log" - "github.com/jackc/pgx/v5" "github.com/specterops/bloodhound/dawgs/drivers/pg/model" "github.com/specterops/bloodhound/dawgs/drivers/pg/query" @@ -61,8 +59,6 @@ func NewSchemaManager(database graph.Database) *SchemaManager { } func (s *SchemaManager) fetch(tx graph.Transaction) error { - log.Infof("fetching kinds from database") - if kinds, err := query.On(tx).SelectKinds(); err != nil { return err } else { diff --git a/packages/go/dawgs/drivers/pg/node_test.go b/packages/go/dawgs/drivers/pg/node_test.go index 0275953af..e3d2b21ca 100644 --- a/packages/go/dawgs/drivers/pg/node_test.go +++ b/packages/go/dawgs/drivers/pg/node_test.go @@ -18,9 +18,10 @@ package pg import ( "context" - "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" "testing" + "github.com/specterops/bloodhound/dawgs/drivers/pg/pgutil" + "github.com/specterops/bloodhound/dawgs/graph" graph_mocks "github.com/specterops/bloodhound/dawgs/graph/mocks" "github.com/specterops/bloodhound/dawgs/query" diff --git a/packages/go/dawgs/drivers/pg/pgutil/kindmapper.go b/packages/go/dawgs/drivers/pg/pgutil/kindmapper.go index b82d8da2c..66a2eb5c1 100644 --- a/packages/go/dawgs/drivers/pg/pgutil/kindmapper.go +++ b/packages/go/dawgs/drivers/pg/pgutil/kindmapper.go @@ -19,6 +19,7 @@ package pgutil import ( "context" "fmt" + "github.com/specterops/bloodhound/dawgs/graph" )