Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilizing the Neo4j transactional HTTP endpoint #22

Merged
merged 2 commits into from Aug 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions PowerShell/BloodHound.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13737,7 +13737,7 @@ function Export-BloodHoundData {
}

$Authorized = $True
$ObjectBuffer = New-Object System.Collections.ArrayList
$Statements = New-Object System.Collections.ArrayList

$UserDomainMappings = @{}
if(-not $SkipGCDeconfliction) {
Expand Down Expand Up @@ -14088,20 +14088,14 @@ function Export-BloodHoundData {
Write-Verbose "No matching type name"
}

# built the batch object submission object for each query
ForEach($Query in $Queries) {
$BatchObject = @{
"method" = "POST";
"to" = "/cypher";
"body" = @{"query"=$Query};
}
$Null = $ObjectBuffer.Add($BatchObject)
$Null = $Statements.Add( @{ "statement"=$Query } )
}

if ($ObjectBuffer.Count -ge $Throttle) {
$JsonRequest = ConvertTo-Json20 $ObjectBuffer
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/batch", $JsonRequest)
$ObjectBuffer.Clear()
if ($Statements.Count -ge $Throttle) {
$Json = @{ "statements"=[System.Collections.Hashtable[]]$Statements }
$JsonRequest = ConvertTo-Json20 $Json
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/transaction/commit", $JsonRequest)
$Statements.Clear()
}
}
else {
Expand All @@ -14110,9 +14104,10 @@ function Export-BloodHoundData {
}
end {
if($Authorized) {
$JsonRequest = ConvertTo-Json20 $ObjectBuffer
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/batch", $JsonRequest)
$ObjectBuffer.Clear()
$Json = @{ "statements"=[System.Collections.Hashtable[]]$Statements }
$JsonRequest = ConvertTo-Json20 $Json
$Null = $WebClient.UploadString($URI.AbsoluteUri + "db/data/transaction/commit", $JsonRequest)
$Statements.Clear()
}
}
}
Expand Down