Skip to content
Open
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
67 changes: 32 additions & 35 deletions githound.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ function Git-HoundTeam
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

foreach($team in (Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Session.OrganizationName)/teams"))
{
Expand All @@ -450,8 +450,8 @@ function Git-HoundTeam
}

$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -469,8 +469,7 @@ function Git-HoundUser
$Organization
)

$nodes = New-Object System.Collections.ArrayList

$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Organization.Properties.login)/members" | ForEach-Object -Parallel {

Expand Down Expand Up @@ -509,8 +508,7 @@ function Git-HoundUser

$null = $nodes.Add((New-GitHoundNode -Id $user.node_id -Kind 'GHUser' -Properties $properties))
} -ThrottleLimit 25

Write-Output $nodes
Write-Output ([System.Collections.ArrayList]$nodes.ToArray())
}

function Git-HoundRepository
Expand All @@ -525,9 +523,8 @@ function Git-HoundRepository
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList

$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
foreach($repo in (Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Organization.Properties.login)/repos"))
{
$properties = @{
Expand Down Expand Up @@ -563,8 +560,8 @@ function Git-HoundRepository
}

$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -585,8 +582,8 @@ function Git-HoundBranch

begin
{
$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

}

Expand Down Expand Up @@ -741,8 +738,8 @@ function Git-HoundBranch
end
{
$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -762,8 +759,8 @@ function Git-HoundOrganizationRole
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

$orgAllRepoReadId = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Organization.id)_all_repo_read"))
$orgAllRepoTriageId = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Organization.id)_all_repo_triage"))
Expand Down Expand Up @@ -910,8 +907,8 @@ function Git-HoundOrganizationRole
} -ThrottleLimit 25

$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -930,8 +927,8 @@ function Git-HoundTeamRole
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Organization.Properties.login)/teams" | ForEach-Object -Parallel {

Expand Down Expand Up @@ -982,8 +979,8 @@ function Git-HoundTeamRole
} -ThrottleLimit 25

$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -1003,8 +1000,8 @@ function Git-HoundRepositoryRole
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

$orgAllRepoReadId = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Organization.id)_all_repo_read"))
$orgAllRepoTriageId = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Organization.id)_all_repo_triage"))
Expand Down Expand Up @@ -1199,8 +1196,8 @@ function Git-HoundRepositoryRole
} -ThrottleLimit 25

$output = [PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
}

Write-Output $output
Expand All @@ -1223,8 +1220,8 @@ function Git-HoundSecretScanningAlert
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

foreach($alert in (Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Organization.Properties.login)/secret-scanning/alerts"))
{
Expand Down Expand Up @@ -1269,8 +1266,8 @@ function Git-HoundAppInstallation
$Organization
)

$nodes = New-Object System.Collections.ArrayList
$edges = New-Object System.Collections.ArrayList
$nodes = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()
$edges = [System.Collections.Concurrent.ConcurrentBag[PSObject]]::new()

foreach($app in (Invoke-GithubRestMethod -Session $Session -Path "orgs/$($Organization.Properties.login)/installations").installations)
{
Expand All @@ -1295,8 +1292,8 @@ function Git-HoundAppInstallation
}

Write-Output ([PSCustomObject]@{
Nodes = $nodes
Edges = $edges
Nodes = [System.Collections.ArrayList]$nodes.ToArray()
Edges = [System.Collections.ArrayList]$edges.ToArray()
})
}

Expand Down