Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f44e09
feat(report): prepare scoped redacted result exports
thetechgy Oct 31, 2026
517fec2
Merge branch 'feat/github-evidence-transport' into feat/github-deleti…
thetechgy Oct 31, 2026
b354ff1
Merge branch 'feat/scoped-redacted-result-exports' into feat/github-d…
thetechgy Oct 31, 2026
ce0ce80
feat(github): assess deletion access with configured approvals
thetechgy Oct 31, 2026
82eab44
test(github): distinguish imported and in-memory redaction
thetechgy Oct 31, 2026
88f9231
test(github): retire replaced deletion rendering assertions
thetechgy Oct 31, 2026
39aca19
test(report): cover CSV XML and XLSX redaction exports
thetechgy Nov 1, 2026
b9eabfd
Merge branch 'main' into feat/scoped-redacted-result-exports
thetechgy Nov 2, 2026
35ce359
fix(report): preserve release versions in redacted Markdown
thetechgy Nov 2, 2026
80f3d44
Merge branch 'main' into feat/github-deletion-approvals
thetechgy Nov 2, 2026
a04e6ba
fix(report): retain failure messages in redacted Markdown
thetechgy Nov 2, 2026
d3d3d21
Merge remote-tracking branch 'refs/remotes/review/pr2633' into fix/pr…
thetechgy Nov 2, 2026
43ba097
Merge remote-tracking branch 'refs/remotes/review/pr2634' into fix/pr…
thetechgy Nov 2, 2026
4da091b
fix(github): retain partial inventory on deletion errors
thetechgy Nov 2, 2026
6890e96
docs(github): clarify fresh evidence after deletion remediation
thetechgy Nov 2, 2026
d364ce0
fix(github): reconcile deletion approvals with upstream main
thetechgy Nov 8, 2026
2001ffc
Merge branch 'main' into feat/github-deletion-approvals
SamErde Nov 8, 2026
4ad095d
Merge branch 'main' into feat/github-deletion-approvals
SamErde Nov 8, 2026
c7233a1
Merge branch 'main' into feat/github-deletion-approvals
thetechgy Nov 10, 2026
773bf5f
test(github): match escaped URL scheme in deletion fixture
thetechgy Nov 10, 2026
0c976ca
fix(github): reconcile deletion reporting with upstream settings
thetechgy Nov 18, 2026
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
1 change: 1 addition & 0 deletions powershell/assets/MaesterSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
AzureDevOpsOrganization = @{ Type = 'string'; Role = 'Connection'; Default = ''; Sensitive = $false; Description = 'Azure DevOps organization that Connect-Maester -Service AzureDevOps connects to.' }
GitHubOrganization = @{ Type = 'string'; Role = 'Connection'; Default = ''; Sensitive = $false; Description = 'GitHub organization that the GitHub checks read.' }
GitHubApiBaseUri = @{ Type = 'string'; Role = 'Connection'; Default = 'https://api.github.com'; Sensitive = $false; Description = 'Base URI of the GitHub REST API.' }
GitHubDeletionPolicy = @{ Type = 'object'; Default = @{}; Sensitive = $true; Description = 'Host and organization-bound approved owner and repository administrator IDs for GitHub deletion assessments.' }
GitHubApiVersion = @{ Type = 'string'; Role = 'Connection'; Default = '2022-11-28'; Sensitive = $false; Description = 'GitHub REST API version.' }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function Get-MtCisGitHubDeletionPolicyGap {
<#
.SYNOPSIS
Internal: Checks for restrictive repository policies before failing an administrator baseline.
#>
[CmdletBinding()]
[OutputType([string])]
param(
[Parameter(Mandatory)] [string] $Organization,
[Parameter(Mandatory)] [string] $Repository,
[Parameter(Mandatory)] [string] $RepositoryId
)
$query = @'
query DeletionPolicies($org:String!,$repo:String!,$after:String){
repository(owner:$org,name:$repo){databaseId rulesets(first:100,after:$after,includeParents:true,targets:[REPOSITORY]){
totalCount pageInfo{hasNextPage endCursor} nodes{
id target enforcement
}
}}
}
'@
$cursor = $null
$seenCursors = [System.Collections.Generic.HashSet[string]]::new()
$count = 0
$seenPolicies = [System.Collections.Generic.HashSet[string]]::new()
$expected = $null
for ($page = 0; $page -lt 100; $page++) {
try {
$response = Invoke-MtGitHubGraphQLRequest -Query $query -OperationName DeletionPolicies -Variables @{ org = $Organization; repo = $Repository; after = $cursor }
} catch {
if ($_.Exception.Data['GitHubRateLimit']) { throw }
if ((Get-MtGitHubErrorStatusCode -ErrorRecord $_) -in 403, 404) { return 'Applicable repository-policy evidence is not visible; a restrictive alternative cannot be ruled out.' }
throw
}
$connection = $response.Data.repository.rulesets
$databaseId = $response.Data.repository.databaseId
if ($response.Errors.Count -gt 0 -or ($databaseId -isnot [int] -and $databaseId -isnot [long] -and $databaseId -isnot [bigint]) -or $databaseId -le 0 -or [string]$databaseId -cne $RepositoryId -or $null -eq $connection -or $connection.nodes -isnot [array] -or $connection.pageInfo.hasNextPage -isnot [bool] -or ($connection.totalCount -isnot [int] -and $connection.totalCount -isnot [long]) -or $connection.totalCount -lt 0) { return 'Applicable repository-policy evidence is unavailable or incomplete; a restrictive alternative cannot be ruled out.' }
if ($null -eq $expected) { $expected = $connection.totalCount }
if ($expected -ne $connection.totalCount) { return 'Applicable repository-policy population changed during collection.' }
foreach ($policy in $connection.nodes) {
if ($policy.id -isnot [string] -or [string]::IsNullOrWhiteSpace($policy.id) -or -not $seenPolicies.Add($policy.id) -or $policy.target -cne 'REPOSITORY') { return 'Applicable repository-policy identity or target is unusable.' }
if ($policy.enforcement -cnotin 'ACTIVE', 'DISABLED', 'EVALUATE') { return 'Applicable repository-policy enforcement is unavailable or unknown.' }
if ($policy.enforcement -cne 'ACTIVE') { continue }
return 'An active repository-target policy may restrict deletion; its effective restrictions, bypass membership and stronger-policy equivalence need review.'
}
$count += $connection.nodes.Count
if (-not $connection.pageInfo.hasNextPage) {
if ($count -ne $expected) { return 'Applicable repository-policy total does not match collected items.' }
return $null
}
$cursor = $connection.pageInfo.endCursor
if ($cursor -isnot [string] -or [string]::IsNullOrWhiteSpace($cursor) -or -not $seenCursors.Add($cursor)) { return 'Applicable repository-policy pagination cursor is unusable.' }
}
return 'Applicable repository-policy pagination reached the page cap.'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function Get-MtCisGitHubDeletionResult {
<#
.SYNOPSIS
Internal: Renders raw or pseudonymized deletion results from the same evidence.
#>
[CmdletBinding()]
[OutputType([string])]
param(
[Parameter(Mandatory)] [System.Collections.IDictionary] $Evidence,
[switch] $RedactUserIdentity
)

$userId = {
param($Id)
if ($RedactUserIdentity) {
# User database IDs are host-scoped. Normalize the API authority, including a
# non-default port, without adding numeric IDs to the global replacement map.
$authority = ([uri]$Evidence.ApiAuthority).GetLeftPart([UriPartial]::Authority).ToLowerInvariant()
Get-MtAffectedObjectUniqueId -System 'GitHub' -Type 'User' -Id "$authority/users/$Id"
} else { [string]$Id }
}
$result = $Evidence.Message + "`n`nOrganization setting ``$($Evidence.Field)``: ``$($Evidence.Setting)``.`n`n"
if ($Evidence.OwnerBranch) {
$rows = [System.Collections.Generic.List[string]]::new()
$unapproved = 0
foreach ($owner in $Evidence.Owners) {
$id = & $userId $owner.id
$login = if ($RedactUserIdentity) { $id } elseif ($owner.login -is [string] -and -not [string]::IsNullOrWhiteSpace($owner.login)) { Get-MtSafeMarkdown $owner.login } else { 'Unavailable' }
$approval = if (-not $Evidence.ApprovalsConfigured) { 'Not configured' } elseif ([string]$owner.id -cin $Evidence.ApprovedOwnerIds) { 'Approved' } else { 'Not approved' }
if ($approval -eq 'Not approved') { $unapproved++ }
$rows.Add("| $login | $id | $approval |")
}
$coverage = if ($Evidence.OwnerComplete) { 'Complete' } else { 'Incomplete / partial; total owner count unknown; observed count is a lower bound' }
$unapprovedCount = if ($Evidence.ApprovalsConfigured) { [string]$unapproved } else { 'Not configured' }
$result += "Organization ID: ``$($Evidence.OrganizationId)``.`n`n| Observed owners | Maximum | Unapproved owners | Evidence |`n| --- | --- | --- | --- |`n| $($rows.Count) | $($Evidence.MaximumOrganizationOwners) | $unapprovedCount | $coverage |`n`n| Owner login | User ID | Approval |`n| --- | --- | --- |`n" + ($rows -join "`n")
if ($rows.Count -eq 0) { $result += "`nNo validated owner rows were available. This does not establish that the organization has no owners." }
$result += "`n`nThe maximum is a Maester policy choice (default 3, configurable as a positive integer); CIS does not define a numeric value for 'few'. Unassigned approval entries do not affect the live count."
} else {
$rows = foreach ($repository in $Evidence.Repositories) {
$ids = @($repository.UnapprovedIds | ForEach-Object { & $userId $_ }) -join ', '
$notAssessed = $repository.Assessment -eq 'Not assessed'
$unapprovedCount = if (-not $repository.ApprovalsConfigured) { 'Not configured' } elseif ($notAssessed) { 'Not assessed' } else { [string]@($repository.UnapprovedIds).Count }
$administratorCount = if ($notAssessed) { 'Not assessed' } else { [string]$repository.AdministratorCount }
$coverage = if ($notAssessed) { 'Not collected' } elseif ($repository.Complete) { 'Complete' } else { 'Incomplete / partial; observed count is a lower bound' }
"| $(Get-MtSafeMarkdown $repository.Name) | $administratorCount | $unapprovedCount | $ids | $($repository.Assessment) | $coverage |"
}
$result += "| Repository | Effective administrators | Unapproved | Unapproved observed user IDs | Assessment | Evidence |`n| --- | --- | --- | --- | --- | --- |`n" + ($rows -join "`n")
$result += "`n`nEffective administrator permissions include inherited grants. This assessment uses the configured approvals; it does not independently determine a person's trust or qualifications. No issue was deleted or sampled."
}
if ($Evidence.Gaps.Count) { $result += "`n`n" + ($Evidence.Gaps -join "`n`n") }
return $result
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function Get-MtCisGitHubDeletionRoleGap {
<#
.SYNOPSIS
Internal: Qualifies whether custom role definitions extend issue deletion beyond administrators.
#>
[CmdletBinding()]
[OutputType([string])]
param([Parameter(Mandatory)] [string] $Organization)

$encoded = [uri]::EscapeDataString($Organization)
foreach ($catalog in @(@{ Path = 'custom-repository-roles'; Key = 'custom_roles' }, @{ Path = 'organization-roles'; Key = 'roles' })) {
try {
$evidence = Invoke-MtGitHubRequest -RelativeUri "/orgs/$encoded/$($catalog.Path)" -IncludeMetadata -ApiVersion '2026-03-10'
} catch {
if ($_.Exception.Data['GitHubRateLimit']) { throw }
if ((Get-MtGitHubErrorStatusCode -ErrorRecord $_) -in 403, 404) { return 'Issue-deletion custom-role catalog is not visible to the connected account.' }
throw
}
$data = $evidence.Data
$roles = $data.($catalog.Key)
if (-not $evidence.CollectionIntegrityValid -or $evidence.ContentKind -ne 'Object' -or $roles -isnot [array] -or ($data.total_count -isnot [int] -and $data.total_count -isnot [long]) -or $data.total_count -ne $roles.Count) {
return 'Issue-deletion custom-role catalog is incomplete or has an unexpected API shape.'
}
$seen = [System.Collections.Generic.HashSet[string]]::new()
foreach ($role in $roles) {
if ($role -isnot [pscustomobject] -or ($role.id -isnot [int] -and $role.id -isnot [long] -and $role.id -isnot [bigint]) -or $role.id -le 0 -or -not $seen.Add([string]$role.id) -or $role.permissions -isnot [array] -or @($role.permissions | Where-Object { $_ -isnot [string] -or [string]::IsNullOrWhiteSpace($_) }).Count) { return 'Issue-deletion custom-role permissions or identities are unavailable or malformed.' }
if ($catalog.Key -eq 'custom_roles') {
if ($role.base_role -isnot [string] -or $role.base_role -cnotin 'read', 'triage', 'write', 'maintain') { return 'Issue-deletion custom repository role has an unavailable or unknown base role.' }
} elseif ($null -ne $role.base_role -and ($role.base_role -isnot [string] -or $role.base_role -cnotin 'none', 'read', 'triage', 'write', 'maintain', 'admin')) {
return 'Issue-deletion organization role has an unknown base role.'
}
# Additional issue-deletion grants require assignment evidence beyond the administrator population.
if (@($role.permissions | Where-Object { $_ -match '(?i)(delete.*issue|issue.*delete)' }).Count) { return 'A custom role can grant issue deletion; its effective assignments and policy restrictions need review.' }
}
}
return $null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function Resolve-MtGitHubDeletionPolicy {
<#
.SYNOPSIS
Internal: Validates the assessor's GitHub deletion approval configuration and target binding.
#>
[CmdletBinding()]
param([Parameter(Mandatory)] [object] $Organization)

$policy = Get-MtSetting -Name GitHubDeletionPolicy -Verbose:$false
if ($null -eq $policy -or ($policy -is [System.Collections.IDictionary] -and $policy.Count -eq 0) -or ($policy -is [pscustomobject] -and @($policy.PSObject.Properties).Count -eq 0)) { return $null }
if ($policy -isnot [pscustomobject]) { throw 'GitHubDeletionPolicy must be a JSON object.' }
$allowed = 'ApiBaseUri', 'OrganizationId', 'ApprovedOwnerIds', 'CompleteRepositoryInventory', 'Repositories'
foreach ($property in $policy.PSObject.Properties.Name) {
if ($property -notin $allowed) { throw 'GitHubDeletionPolicy contains an unknown property.' }
}
$base = $__MtSession.GitHubConnection.ApiBaseUri.TrimEnd('/')
if ($policy.ApiBaseUri -isnot [string] -or $policy.ApiBaseUri.TrimEnd('/') -cne $base) { throw 'GitHubDeletionPolicy.ApiBaseUri must match the connected API base URI.' }
$idPattern = '^[1-9][0-9]*$'
if ($policy.OrganizationId -isnot [string] -or $policy.OrganizationId -cnotmatch $idPattern) { throw 'GitHubDeletionPolicy.OrganizationId must be a positive decimal ID string.' }
if (($Organization.id -isnot [int] -and $Organization.id -isnot [long] -and $Organization.id -isnot [bigint]) -or $Organization.id -le 0) { throw 'GitHub organization identity is unavailable or unusable.' }
if ($policy.OrganizationId -cne [string]$Organization.id) { throw 'GitHubDeletionPolicy.OrganizationId does not match the connected organization.' }
foreach ($name in 'ApprovedOwnerIds') {
if (-not $policy.PSObject.Properties[$name]) { continue }
if ($policy.$name -isnot [array]) { throw "GitHubDeletionPolicy.$name must be an array of positive decimal ID strings." }
$seen = [System.Collections.Generic.HashSet[string]]::new()
foreach ($id in $policy.$name) {
if ($id -isnot [string] -or $id -cnotmatch $idPattern -or -not $seen.Add($id)) { throw "GitHubDeletionPolicy.$name contains an invalid or duplicate ID." }
}
}
if ($policy.PSObject.Properties['CompleteRepositoryInventory'] -and $policy.CompleteRepositoryInventory -isnot [bool]) { throw 'GitHubDeletionPolicy.CompleteRepositoryInventory must be Boolean.' }
if ($policy.PSObject.Properties['Repositories']) {
if ($policy.Repositories -isnot [array]) { throw 'GitHubDeletionPolicy.Repositories must be an array.' }
$seenRepositories = [System.Collections.Generic.HashSet[string]]::new()
foreach ($repository in $policy.Repositories) {
if ($repository -isnot [pscustomobject] -or $repository.Id -isnot [string] -or $repository.Id -cnotmatch $idPattern -or -not $seenRepositories.Add($repository.Id)) { throw 'GitHubDeletionPolicy.Repositories contains an invalid or duplicate repository ID.' }
if (@($repository.PSObject.Properties.Name | Where-Object { $_ -notin 'Id', 'ApprovedAdministratorIds' }).Count) { throw 'A GitHubDeletionPolicy repository contains an unknown property.' }
if ($repository.ApprovedAdministratorIds -isnot [array]) { throw 'Each GitHubDeletionPolicy repository needs ApprovedAdministratorIds as an array.' }
$seenUsers = [System.Collections.Generic.HashSet[string]]::new()
foreach ($id in $repository.ApprovedAdministratorIds) {
if ($id -isnot [string] -or $id -cnotmatch $idPattern -or -not $seenUsers.Add($id)) { throw 'ApprovedAdministratorIds contains an invalid or duplicate ID.' }
}
}
}
return $policy
}
Loading
Loading