Skip to content

Commit

Permalink
BED-3845 - Improve and fix Azure saved queries (#169)
Browse files Browse the repository at this point in the history
* Update default queries for accuracy

* Update saved searches for accuracy

* fix: remove NOT from pre-defined query

---------

Co-authored-by: jknudsen <[email protected]>
  • Loading branch information
StephenHinck and JonasBK authored Oct 27, 2023
1 parent 4d66647 commit a4ea6f1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/javascript/bh-shared-ui/src/commonSearches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const azureTransitEdgeTypes = AzurePathfindingEdges().slice(0, -1).join('|') + A
const adTransitEdgeTypes =
ActiveDirectoryPathfindingEdges().slice(0, -1).join('|') + '|' + ActiveDirectoryPathfindingEdges().slice(-1);

const highPrivilegedRoleDisplayNames =
'Global Administrator|User Administrator|Cloud Application Administrator|Authentication Policy Administrator|Exchange Administrator|Helpdesk Administrator|PRIVILEGED AUTHENTICATION ADMINISTRATOR';
const highPrivilegedRoleDisplayNameRegex =
'Global Administrator.*|User Administrator.*|Cloud Application Administrator.*|Authentication Policy Administrator.*|Exchange Administrator.*|Helpdesk Administrator.*|Privileged Authentication Administrator.*';

export type CommonSearchType = {
subheader: string;
Expand Down Expand Up @@ -168,7 +168,7 @@ export const CommonSearches: CommonSearchType[] = [
},
{
description: 'All members of high privileged roles',
cypher: `MATCH p=(n)-[:AZHasRole|AZMemberOf*1..2]->(r:AZRole)\nWHERE r.name =~ '(?i)${highPrivilegedRoleDisplayNames}'\nRETURN p`,
cypher: `MATCH p=(n)-[:AZHasRole|AZMemberOf*1..2]->(r:AZRole)\nWHERE r.name =~ '(?i)${highPrivilegedRoleDisplayNameRegex}'\nRETURN p`,
},
],
},
Expand All @@ -178,19 +178,19 @@ export const CommonSearches: CommonSearchType[] = [
queries: [
{
description: 'Shortest paths to high value/Tier Zero targets',
cypher: `MATCH p=shortestPath((m:AZUser)-[r:${azureTransitEdgeTypes}*1..]->(n))\nWHERE n.system_tags = "admin_tier_0" AND n.name =~ '(?i)${highPrivilegedRoleDisplayNames}' AND NOT m=n\nRETURN p`,
cypher: `MATCH p=shortestPath((m:AZUser)-[r:${azureTransitEdgeTypes}*1..]->(n))\nWHERE n.system_tags = "admin_tier_0" AND n.name =~ '(?i)${highPrivilegedRoleDisplayNameRegex}' AND m<>n\nRETURN p`,
},
{
description: 'Shortest paths to privileged roles',
cypher: `MATCH p=shortestPath((m)-[r:${azureTransitEdgeTypes}*1..]->(n:AZRole))\nWHERE n.name =~ '(?i)${highPrivilegedRoleDisplayNames}' AND NOT m=n\nRETURN p`,
cypher: `MATCH p=shortestPath((m)-[r:${azureTransitEdgeTypes}*1..]->(n:AZRole))\nWHERE n.name =~ '(?i)${highPrivilegedRoleDisplayNameRegex}' AND m<>n\nRETURN p`,
},
{
description: 'Shortest paths from Azure Applications to high value/Tier Zero targets',
cypher: `MATCH p=shortestPath((m:AZApp)-[r:${azureTransitEdgeTypes}*1..]->(n))\nWHERE n.system_tags = "admin_tier_0" AND m<>n\nRETURN p`,
},
{
description: 'Shortest paths to Azure Subscriptions',
cypher: `MATCH p=shortestPath((m)-[r:${azureTransitEdgeTypes}*1..]->(n:AZSubscription))\nWHERE NOT m<>>n\nRETURN p`,
cypher: `MATCH p=shortestPath((m)-[r:${azureTransitEdgeTypes}*1..]->(n:AZSubscription))\nWHERE m<>n\nRETURN p`,
},
],
},
Expand Down

0 comments on commit a4ea6f1

Please sign in to comment.