Skip to content

Commit

Permalink
Only add the base key if it's not an expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
kpom-specter committed Dec 20, 2024
1 parent b9f0d5a commit ae4156f
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions packages/go/cypher/frontend/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,31 @@ func (s *RelationshipPatternVisitor) EnterOC_RelTypeName(ctx *parser.OC_RelTypeN
}

func (s *RelationshipPatternVisitor) ExitOC_RelTypeName(ctx *parser.OC_RelTypeNameContext) {
rel_type := ctx.GetText()
if rel_type == "AZ_ATTACK_PATHS" || rel_type == "ALL_ATTACK_PATHS" {
for _, kind := range azure.PathfindingRelationships() {
s.RelationshipPattern.Kinds = s.RelationshipPattern.Kinds.Add(kind)
}
}
relationshipType := ctx.GetText()

if rel_type == "AD_ATTACK_PATHS" || rel_type == "ALL_ATTACK_PATHS" {
for _, kind := range ad.PathfindingRelationships() {
// Helper function to add kinds from relationships
addKindsFromRelationships := func(kinds []graph.Kind) {
for _, kind := range kinds {
s.RelationshipPattern.Kinds = s.RelationshipPattern.Kinds.Add(kind)
}
}

kind := graph.StringKind(s.ctx.Exit().(*SymbolicNameOrReservedWordVisitor).Name)
s.RelationshipPattern.Kinds = append(s.RelationshipPattern.Kinds, kind)
// Handle Azure and AD attack paths
switch relationshipType {
case "ALL_ATTACK_PATHS":
addKindsFromRelationships(azure.PathfindingRelationships())
addKindsFromRelationships(ad.PathfindingRelationships())

case "AZ_ATTACK_PATHS":
addKindsFromRelationships(azure.PathfindingRelationships())

case "AD_ATTACK_PATHS":
addKindsFromRelationships(ad.PathfindingRelationships())

default:
kind := graph.StringKind(s.ctx.Exit().(*SymbolicNameOrReservedWordVisitor).Name)
addKindsFromRelationships([]graph.Kind{kind})
}
}

func (s *RelationshipPatternVisitor) EnterOC_Variable(ctx *parser.OC_VariableContext) {
Expand Down

0 comments on commit ae4156f

Please sign in to comment.