Repository navigation
fix(ad): AD-FOR-03 no longer substitutes a default tombstone lifetime #2699
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
Open
earbona23
wants to merge
8
commits into
maester365:main
Choose a base branch
from
earbona23:fix/2468-remaining-false-passes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
26bc096
fix(cis,ad): the last two checks of #2468 no longer pass on an absent…
earbona23 be569aa
fix(cis): the lockbox row stops reading Fail on a passing tenant
earbona23 34a833f
Merge remote-tracking branch 'origin/main' into resolver/2699
earbona23 c60a3c9
fix: drop the customer lockbox change, main already decided that case
earbona23 dc67c3d
fix(ad): a tombstone lifetime that is not set is 60 days, not unreadable
earbona23 a22b47d
fix(ad): never infer a tombstone lifetime the check did not read
earbona23 4b59a15
docs(ad): trim the comments to what the code does
earbona23 217cf6c
Merge branch 'main' into fix/2468-remaining-false-passes
earbona23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
powershell/tests/functions/FalsePassOnEmptySource.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| Describe 'Checks that must not pass when their data source returns nothing' { | ||
| BeforeAll { | ||
| Import-Module $PSScriptRoot/../../Maester.psd1 -Force | ||
| . "$PSScriptRoot/../helpers/Use-MtModuleFunction.ps1" | ||
| # A native test, so the function is not exported. | ||
| Use-MtModuleFunction -Name Test-MtAdTombstoneLifetime | ||
| } | ||
|
|
||
| BeforeEach { | ||
| $script:TestResult = $null | ||
| $script:SkippedBecause = $null | ||
|
|
||
| Mock -ModuleName Maester Get-MtLicenseInformation { return $true } | ||
| Mock -ModuleName Maester Add-MtTestResultDetail { | ||
| param($Result, $SkippedBecause) | ||
|
|
||
| $script:TestResult = $Result | ||
| $script:SkippedBecause = $SkippedBecause | ||
| } | ||
| } | ||
|
|
||
| Context 'AD-FOR-03 tombstone lifetime' { | ||
| It 'fails with the unable-to-retrieve message when the lifetime cannot be read' { | ||
| # An unreadable lifetime must not be substituted with a default: the comparison would | ||
| # then be impossible to fail and the result would report an invented number. | ||
| Mock -ModuleName Maester Get-MtADDomainState { | ||
| [pscustomobject]@{ | ||
| Configuration = [pscustomobject]@{ TombstoneLifetime = $null } | ||
| Forest = [pscustomobject]@{ Name = 'contoso.com' } | ||
| } | ||
| } | ||
|
|
||
| Test-MtAdTombstoneLifetime | Should -BeFalse | ||
| $script:TestResult | Should -Match 'Unable to retrieve tombstone lifetime' | ||
| } | ||
|
|
||
| It 'does not invent a lifetime of 180 days when the value is missing' { | ||
| # DirectoryServiceRead false: the Directory Service object was not read at all, so | ||
| # there is no effective lifetime to report. This is the genuine retrieval failure. | ||
| Mock -ModuleName Maester Get-MtADDomainState { | ||
| [pscustomobject]@{ | ||
| Configuration = [pscustomobject]@{ TombstoneLifetime = $null; DirectoryServiceRead = $false } | ||
| Forest = [pscustomobject]@{ Name = 'contoso.com' } | ||
| } | ||
| } | ||
|
|
||
| $null = Test-MtAdTombstoneLifetime | ||
| $script:TestResult | Should -Not -Match '180 days' | ||
| $script:TestResult | Should -Not -Match 'Meets recommendation' | ||
| } | ||
|
|
||
| It 'does not pass on an inferred 60 days when the attribute is absent' { | ||
| # Seeing the Directory Service object is not proof the attribute was readable, so an | ||
| # absent attribute must not be read as 'not set' and passed on the 60-day default. | ||
| Mock -ModuleName Maester Get-MtADDomainState { | ||
| [pscustomobject]@{ | ||
| Configuration = [pscustomobject]@{ TombstoneLifetime = $null; DirectoryServiceRead = $true } | ||
| Forest = [pscustomobject]@{ Name = 'contoso.com' } | ||
| } | ||
| } | ||
|
|
||
| Test-MtAdTombstoneLifetime | Should -BeFalse | ||
| $script:TestResult | Should -Match '60 days' | ||
| $script:TestResult | Should -Match 'cannot read the attribute' | ||
| $script:TestResult | Should -Not -Match 'Meets recommendation' | ||
| } | ||
|
|
||
| It 'passes and reports the value when the lifetime is readable' { | ||
| Mock -ModuleName Maester Get-MtADDomainState { | ||
| [pscustomobject]@{ | ||
| Configuration = [pscustomobject]@{ TombstoneLifetime = 365 } | ||
| Forest = [pscustomobject]@{ Name = 'contoso.com' } | ||
| } | ||
| } | ||
|
|
||
| Test-MtAdTombstoneLifetime | Should -BeTrue | ||
| $script:TestResult | Should -Match '365 days' | ||
| $script:TestResult | Should -Match 'Meets recommendation' | ||
| } | ||
|
|
||
| It 'reports below the recommendation for a forest on the older default of 60 days' { | ||
| # The substituted 180 could also claim the recommendation was met on an older forest, | ||
| # whose default is 60. | ||
| Mock -ModuleName Maester Get-MtADDomainState { | ||
| [pscustomobject]@{ | ||
| Configuration = [pscustomobject]@{ TombstoneLifetime = 60 } | ||
| Forest = [pscustomobject]@{ Name = 'contoso.com' } | ||
| } | ||
| } | ||
|
|
||
| $null = Test-MtAdTombstoneLifetime | ||
| $script:TestResult | Should -Match 'Below recommendation' | ||
| } | ||
|
|
||
| It 'skips when Active Directory is not reachable at all' { | ||
| Mock -ModuleName Maester Get-MtADDomainState { return $null } | ||
|
|
||
| $null -eq (Test-MtAdTombstoneLifetime) | Should -BeTrue | ||
| $script:SkippedBecause | Should -Be 'NotConnectedActiveDirectory' | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.