From 8bd823959bacd59036cc9e4facd9228949fdba2b Mon Sep 17 00:00:00 2001 From: jknudsen Date: Tue, 13 Aug 2024 21:19:56 +0200 Subject: [PATCH] feat: LoginURL Az property --- cmd/ui/src/utils.ts | 2 +- packages/cue/bh/azure/azure.cue | 7 +++++++ .../go/cypher/models/pgsql/identifiers_test.go | 16 ++++++++++++++++ packages/go/cypher/models/pgsql/test/testcase.go | 16 ++++++++++++++++ .../go/cypher/models/pgsql/translate/format.go | 16 ++++++++++++++++ packages/go/dawgs/drivers/pg/util.go | 16 ++++++++++++++++ packages/go/ein/azure.go | 1 + packages/go/graphschema/ad/ad.go | 1 - packages/go/graphschema/azure/azure.go | 10 ++++++++-- packages/go/graphschema/common/common.go | 1 - packages/go/openapi/doc/openapi.json | 7 +++++++ .../javascript/bh-shared-ui/src/graphSchema.ts | 3 +++ 12 files changed, 91 insertions(+), 5 deletions(-) diff --git a/cmd/ui/src/utils.ts b/cmd/ui/src/utils.ts index fdb6579f39..6c93c0caeb 100644 --- a/cmd/ui/src/utils.ts +++ b/cmd/ui/src/utils.ts @@ -25,7 +25,7 @@ import { isLink, isNode } from 'src/ducks/graph/utils'; import { Glyph } from 'src/rendering/programs/node.glyphs'; import { store } from 'src/store'; -const IGNORE_401_LOGOUT = ['/api/v2/login', '/api/v2/logout', '/api/v2/features'] +const IGNORE_401_LOGOUT = ['/api/v2/login', '/api/v2/logout', '/api/v2/features']; export const getDatesInRange = (startDate: Date, endDate: Date) => { const date = new Date(startDate.getTime()); diff --git a/packages/cue/bh/azure/azure.cue b/packages/cue/bh/azure/azure.cue index edf511bd1d..e7201cd879 100644 --- a/packages/cue/bh/azure/azure.cue +++ b/packages/cue/bh/azure/azure.cue @@ -50,6 +50,13 @@ AppDisplayName: types.#StringEnum & { representation: "appdisplayname" } +LoginURL: types.#StringEnum & { + symbol: "LoginURL" + schema: "azure" + name: "Login URL" + representation: "loginurl" +} + ServicePrincipalType: types.#StringEnum & { symbol: "ServicePrincipalType" schema: "azure" diff --git a/packages/go/cypher/models/pgsql/identifiers_test.go b/packages/go/cypher/models/pgsql/identifiers_test.go index 6f5488eeda..d4589d05c7 100644 --- a/packages/go/cypher/models/pgsql/identifiers_test.go +++ b/packages/go/cypher/models/pgsql/identifiers_test.go @@ -1,3 +1,19 @@ +// Copyright 2024 Specter Ops, Inc. +// +// Licensed under the Apache License, Version 2.0 +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + package pgsql import ( diff --git a/packages/go/cypher/models/pgsql/test/testcase.go b/packages/go/cypher/models/pgsql/test/testcase.go index 6ea8a0546f..4c369d567c 100644 --- a/packages/go/cypher/models/pgsql/test/testcase.go +++ b/packages/go/cypher/models/pgsql/test/testcase.go @@ -1,3 +1,19 @@ +// Copyright 2024 Specter Ops, Inc. +// +// Licensed under the Apache License, Version 2.0 +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/packages/go/cypher/models/pgsql/translate/format.go b/packages/go/cypher/models/pgsql/translate/format.go index 48cadc775c..fa7b511797 100644 --- a/packages/go/cypher/models/pgsql/translate/format.go +++ b/packages/go/cypher/models/pgsql/translate/format.go @@ -1,3 +1,19 @@ +// Copyright 2024 Specter Ops, Inc. +// +// Licensed under the Apache License, Version 2.0 +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + package translate import ( diff --git a/packages/go/dawgs/drivers/pg/util.go b/packages/go/dawgs/drivers/pg/util.go index 77dd10a34e..e3e75581ad 100644 --- a/packages/go/dawgs/drivers/pg/util.go +++ b/packages/go/dawgs/drivers/pg/util.go @@ -1,3 +1,19 @@ +// Copyright 2024 Specter Ops, Inc. +// +// Licensed under the Apache License, Version 2.0 +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + package pg import "github.com/specterops/bloodhound/dawgs/graph" diff --git a/packages/go/ein/azure.go b/packages/go/ein/azure.go index dd1ad8e07d..05d5247fdc 100644 --- a/packages/go/ein/azure.go +++ b/packages/go/ein/azure.go @@ -911,6 +911,7 @@ func ConvertAzureServicePrincipal(data models.ServicePrincipal) ([]IngestibleNod azure.AppOwnerOrganizationID.String(): data.AppOwnerOrganizationId, azure.AppDescription.String(): data.AppDescription, azure.AppDisplayName.String(): data.AppDisplayName, + azure.LoginURL.String(): data.LoginUrl, azure.ServicePrincipalType.String(): data.ServicePrincipalType, azure.TenantID.String(): strings.ToUpper(data.TenantId), }, diff --git a/packages/go/graphschema/ad/ad.go b/packages/go/graphschema/ad/ad.go index e9c41d6712..050017e9a7 100644 --- a/packages/go/graphschema/ad/ad.go +++ b/packages/go/graphschema/ad/ad.go @@ -21,7 +21,6 @@ package ad import ( "errors" - graph "github.com/specterops/bloodhound/dawgs/graph" ) diff --git a/packages/go/graphschema/azure/azure.go b/packages/go/graphschema/azure/azure.go index 3b35354d37..385746a18c 100644 --- a/packages/go/graphschema/azure/azure.go +++ b/packages/go/graphschema/azure/azure.go @@ -21,7 +21,6 @@ package azure import ( "errors" - graph "github.com/specterops/bloodhound/dawgs/graph" ) @@ -101,6 +100,7 @@ const ( AppOwnerOrganizationID Property = "appownerorganizationid" AppDescription Property = "appdescription" AppDisplayName Property = "appdisplayname" + LoginURL Property = "loginurl" ServicePrincipalType Property = "serviceprincipaltype" UserType Property = "usertype" TenantID Property = "tenantid" @@ -132,7 +132,7 @@ const ( ) func AllProperties() []Property { - return []Property{AppOwnerOrganizationID, AppDescription, AppDisplayName, ServicePrincipalType, UserType, TenantID, ServicePrincipalID, ServicePrincipalNames, OperatingSystemVersion, TrustType, IsBuiltIn, AppID, AppRoleID, DeviceID, NodeResourceGroupID, OnPremID, OnPremSyncEnabled, SecurityEnabled, SecurityIdentifier, EnableRBACAuthorization, Scope, Offer, MFAEnabled, License, Licenses, MFAEnforced, UserPrincipalName, IsAssignableToRole, PublisherDomain, SignInAudience, RoleTemplateID} + return []Property{AppOwnerOrganizationID, AppDescription, AppDisplayName, LoginURL, ServicePrincipalType, UserType, TenantID, ServicePrincipalID, ServicePrincipalNames, OperatingSystemVersion, TrustType, IsBuiltIn, AppID, AppRoleID, DeviceID, NodeResourceGroupID, OnPremID, OnPremSyncEnabled, SecurityEnabled, SecurityIdentifier, EnableRBACAuthorization, Scope, Offer, MFAEnabled, License, Licenses, MFAEnforced, UserPrincipalName, IsAssignableToRole, PublisherDomain, SignInAudience, RoleTemplateID} } func ParseProperty(source string) (Property, error) { switch source { @@ -142,6 +142,8 @@ func ParseProperty(source string) (Property, error) { return AppDescription, nil case "appdisplayname": return AppDisplayName, nil + case "loginurl": + return LoginURL, nil case "serviceprincipaltype": return ServicePrincipalType, nil case "usertype": @@ -210,6 +212,8 @@ func (s Property) String() string { return string(AppDescription) case AppDisplayName: return string(AppDisplayName) + case LoginURL: + return string(LoginURL) case ServicePrincipalType: return string(ServicePrincipalType) case UserType: @@ -278,6 +282,8 @@ func (s Property) Name() string { return "App Description" case AppDisplayName: return "App Display Name" + case LoginURL: + return "Login URL" case ServicePrincipalType: return "Service Principal Type" case UserType: diff --git a/packages/go/graphschema/common/common.go b/packages/go/graphschema/common/common.go index 9320bb8d29..6fd161585e 100644 --- a/packages/go/graphschema/common/common.go +++ b/packages/go/graphschema/common/common.go @@ -21,7 +21,6 @@ package common import ( "errors" - graph "github.com/specterops/bloodhound/dawgs/graph" ) diff --git a/packages/go/openapi/doc/openapi.json b/packages/go/openapi/doc/openapi.json index a5972a6c2d..8f9b8b787f 100644 --- a/packages/go/openapi/doc/openapi.json +++ b/packages/go/openapi/doc/openapi.json @@ -4225,6 +4225,13 @@ "schema": { "$ref": "#/components/schemas/api.params.predicate.filter.string" } + }, + { + "name": "scope", + "in": "query", + "schema": { + "$ref": "#/components/schemas/api.params.predicate.filter.contains" + } } ], "responses": { diff --git a/packages/javascript/bh-shared-ui/src/graphSchema.ts b/packages/javascript/bh-shared-ui/src/graphSchema.ts index 1a1f7a2724..9b0a5b5350 100644 --- a/packages/javascript/bh-shared-ui/src/graphSchema.ts +++ b/packages/javascript/bh-shared-ui/src/graphSchema.ts @@ -816,6 +816,7 @@ export enum AzureKindProperties { AppOwnerOrganizationID = 'appownerorganizationid', AppDescription = 'appdescription', AppDisplayName = 'appdisplayname', + LoginURL = 'loginurl', ServicePrincipalType = 'serviceprincipaltype', UserType = 'usertype', TenantID = 'tenantid', @@ -853,6 +854,8 @@ export function AzureKindPropertiesToDisplay(value: AzureKindProperties): string return 'App Description'; case AzureKindProperties.AppDisplayName: return 'App Display Name'; + case AzureKindProperties.LoginURL: + return 'Login URL'; case AzureKindProperties.ServicePrincipalType: return 'Service Principal Type'; case AzureKindProperties.UserType: