Skip to content

Design: shared settings as test parameters, and one naming convention for parameters #2775

Open

Description

@merill

Summary

Some values are the same for every test that needs them: an organisation's emergency access (break glass) accounts, its parked domains (domains that never send email), and how it wants Defender for Endpoint policies evaluated. Today each test that needs one reads it in its own way. This proposal gives Maester 3.0 a single way to do it, so the value is set once by the admin, shows up in Get-MtTest and in the results, and can still be overridden for a single test.

It also sets one naming convention for test parameters, which a unit test and the attribute review enforce. Test parameters are new in 3.0, so if we agree on both now, we won't need breaking changes later.

There's a working implementation in #2758. Updated 11 November: sections 5, 6 and 8 and decisions 7 to 9 are new, added after a review of the first version. The Decisions below were settled on 11 November 2026.


The problem

In 2.x and the early 3.0 previews, a test that needs a shared value calls Get-MtSetting (or reads the config) inside its body:

function Test-MtCaEmergencyAccessExists {
    [MaesterTest(Id = 'MT.1005', ...)]
    param()
    $accounts = Get-MtSetting 'EmergencyAccessAccounts'   # hidden input
    ...
}

This has four problems:

Problem Effect
The input is hidden Get-MtTest doesn't list it, the results don't record it, and the report can't say "this test excluded these 2 accounts".
No per-test override A TestSettings row can't give one test a different value from the rest.
Every test does it differently Some tests read the setting; some take a parameter; some do both with a fallback (MT.1195). Helpers like Get-MtPrivilegedRoleUser -ExcludeEmergencyAccessAccount read the global value themselves.
Names drift The same idea already has five names across suites: InactiveDays, MaxInactiveDays, DormantThresholdDays, StaleThresholdDays, MaximumInactiveDays.

The proposal

1. A test declares a shared value as a parameter bound to a setting

param(
    # Emergency access (break glass) accounts and groups.
    [MaesterParameter(Setting = 'EmergencyAccessAccounts')]
    [object[]] $EmergencyAccessAccounts = @()
)

The test body only ever uses $EmergencyAccessAccounts. It never calls Get-MtSetting. The engine fills the parameter in.

flowchart LR
    subgraph Before["Before: test reads the setting itself"]
        direction TB
        C1[maester-config.json<br/>GlobalSettings] -.->|Get-MtSetting<br/>inside the body| T1[Test body]
        T1 --> R1[Result<br/><i>input not recorded</i>]
    end
    subgraph After["After: engine binds the parameter"]
        direction TB
        C2[maester-config.json<br/>GlobalSettings + TestSettings] --> E[Engine resolves<br/>the parameter]
        E -->|$EmergencyAccessAccounts| T2[Test body]
        E --> R2[Result<br/><i>Parameters: value,<br/>Source = Setting</i>]
        T2 --> R2
    end
Loading

2. The most specific value wins

flowchart TD
    A{"-Parameter on<br/>Invoke-Maester / Invoke-MtTest?"} -->|yes| V1[Use it<br/>Source = Parameter]
    A -->|no| B{"Test's TestSettings row<br/>sets it?"}
    B -->|yes| V2[Use it<br/>Source = Config]
    B -->|no| C{"GlobalSettings has the<br/>bound setting, not null?"}
    C -->|yes| V3[Use it<br/>Source = Setting]
    C -->|no| V4[Parameter default<br/>Source = Default]
Loading

An example config, where CIS 2.1.9 is told that no domains are parked even though the organisation lists one:

{
  "GlobalSettings": {
    "EmergencyAccessAccounts": [ { "Id": "1b2c...", "Type": "User" } ],
    "ParkedDomains": [ "contoso-old.com" ]
  },
  "TestSettings": [
    { "Id": "CIS.M365.2.1.9", "Parameters": { "ParkedDomains": [] } }
  ]
}

Every result row records each parameter's value and where it came from, so the report can show it.

3. Binding is explicit, never by name

Two tests can use the same parameter name for different things. MaximumLockoutThreshold exists in both the ASD and CIS suites, and each benchmark asks for a different number. If we filled parameters from GlobalSettings by matching names, a value meant for one benchmark would silently change the other. So a parameter takes a setting only when it says Setting = '...'.

4. A registry says what each setting is

Built-in settings are listed in powershell/assets/MaesterSettings.psd1 with a type, default, description and optionally a Kind (what a UI picker should offer):

Setting Type Used by
EmergencyAccessAccounts object[] MT.1005, MT.1024 family, MT.1111, MT.1191, CIS 5.3.1, ASD ISM-1175, ASD ISM-1648
ParkedDomains string[] (Kind Entra.Domain) CIS 2.1.8, 2.1.9, 2.1.10 (after #2673)
DefenderEndpointPolicyFiltering string 24 Defender for Endpoint tests
DefenderEndpointComplianceLogic string 24 Defender for Endpoint tests

The engine checks every binding when it reads a test:

flowchart TD
    P["[MaesterParameter(Setting = 'X')]"] --> Q{X in the registry?}
    Q -->|no, and X has no dot| ERR1[Error: unregistered setting]
    Q -->|"no, X is Namespace.Key<br/>(custom test or pack)"| OK1[Allowed]
    Q -->|yes| T{Parameter type =<br/>registry Type?}
    T -->|no| ERR2[Error: type mismatch]
    T -->|yes| K{Parameter Kind}
    K -->|none| OK2[Inherits registry Kind]
    K -->|same| OK3[OK]
    K -->|different| ERR3[Error: kind mismatch]
Loading

A registry entry also holds the setting's allowed values and, for a list of objects, the properties of an item (an emergency access account has Id or UserPrincipalName, and Type is User or Group). A bound parameter must have the same type, default and ValidateSet as its setting.

Custom tests can bind their own settings with a Namespace.Key name (e.g. Contoso.Regions) without registering them. A pack declares its settings in its manifest (section 6).

5. The config is checked once, before the run

Without this, a typo in a key is silently ignored, and a wrong value is reported once by every test that binds it (24 times for a Defender for Endpoint option).

flowchart TD
    G[Each key in GlobalSettings] --> R{Registered?<br/>built-in, or declared by<br/>a pack in the run}
    R -->|yes| V{Value fits the type,<br/>allowed values and<br/>item shape?}
    V -->|yes| OK[Used]
    V -->|no| STOP["Run stops, one message:<br/><i>GlobalSettings.DefenderEndpointPolicyFiltering:<br/>'Some' is not one of All, IncludeUnassigned, OnlyAssigned</i>"]
    R -->|no| D{Name has a dot?}
    D -->|"yes (Contoso.Regions)"| PASS[Passes through:<br/>a custom test's own setting]
    D -->|no| WARN["Warning:<br/><i>'ParkedDomain' is not a Maester setting.<br/>Did you mean 'ParkedDomains'?</i>"]
Loading

6. Packs declare their settings

A pack lists each setting it reads under Settings in maester-pack.json. While the pack is in a run, its settings are checked like built-in ones, Get-MtSetting returns their defaults, and a pack test can bind one.

"Settings": {
  "Contoso.Regions": { "Type": "string[]", "Default": ["eu"], "AllowedValues": ["eu", "us", "apac"], "Description": "Regions to check." },
  "Contoso.ApiKey":  { "Type": "string", "Sensitive": true, "Description": "Key for the Contoso API." }
}

The Zero Trust Assessment pack declares its twelve ZeroTrustAssessment.* settings this way.

7. What may be a setting, and what may not

flowchart TD
    S[A value a test needs] --> Q1{Does a benchmark<br/>mandate the value?<br/>e.g. lockout threshold ≤ 10}
    Q1 -->|yes| P1[Plain parameter of that test<br/>with the benchmark's default.<br/><b>Never bound.</b>]
    Q1 -->|no| Q2{Is it a fact about the tenant,<br/>or a choice the organisation<br/>makes once, meaning the same<br/>thing to every test?}
    Q2 -->|yes| P2[Setting + bound parameter<br/>e.g. ParkedDomains,<br/>EmergencyAccessAccounts]
    Q2 -->|no| P3[Plain parameter]
Loading

A setting is named after what it holds, never after a test or a suite (ParkedDomains, not CisParkedDomains).

8. No setting is read out of sight

Three kinds of code still call Get-MtSetting, and each is now visible:

Who reads Rule How it shows
A built-in test Never. It declares a bound parameter and passes the value to its helpers. Parameters on the result
A helper, for a setting tests bind Never. It takes the value as an argument, or it would ignore a per-test override. -
A connect command or data helper, for a connection or transport setting (GitHubOrganization, XspmExternalDataUris) Allowed, and the setting must be registered. SettingsRead on the result
A pack or a custom native test Allowed. A pack declares the setting in its manifest. SettingsRead on the result

SettingsRead is new: the engine records the name of every setting read with Get-MtSetting while a native test runs, on that test's result.

A shim (a benchmark test whose body returns another test's function) declares each bound parameter of the test it calls and passes it on. The engine binds the parameters of the test it runs, the shim, so without this the called test silently runs with its default. This rule found a real case: ASD.ISM-1649 was running CIS 5.3.1 without the tenant's emergency access accounts.

A setting marked Sensitive is recorded as [redacted] in a result's parameters and in the recorded config.

9. One naming convention for parameters

Kind of value Name Examples
Upper or lower limit Maximum/Minimum + what is measured + unit MaximumInactiveDays, MinimumPasswordLength
Other duration What it is + unit ExpiringWithinDays
List Role + plural noun ExcludedGroups, ParkedDomains
Switch What turning it on does (off by default) Strict, AllDomains
Choice Noun for what is chosen, with ValidateSet PolicyFiltering

Rules:

  • PascalCase.
  • Spell out Maximum/Minimum.
  • Units are a plain suffix (Days, not InDays).
  • Lists take plural names.
  • A name says what it measures (MaximumValidationAgeDays, not StaleThresholdDays).
  • Reuse an established name for the same idea.
  • Never use PowerShell common-parameter names (Force, WhatIf, …).

Applying this renames about 20 existing parameters. Some examples:

Before After
MaxInactiveDays, InactiveDays, DormantThresholdDays, StaleThresholdDays (computers) MaximumInactiveDays
StaleThresholdDays (AD trusts) MaximumValidationAgeDays
MaximumInstanceDurationInDays MaximumInstanceDurationDays
BroadIPv4MaskThreshold MinimumIPv4PrefixLength
Force (CISA EXO 4.3) AllDomains
RequiredLogCategory, RequiredPolicyType RequiredLogCategories, RequiredPolicyTypes
RequiredText (DISA) AcceptedBannerTexts

The full list is in #2758.

10. How it is enforced

flowchart LR
    Dev[Contributor adds or<br/>changes a parameter] --> U[Unit test<br/>TestParameterNames.Tests.ps1<br/><i>mechanical rules</i>]
    Dev --> AR[attribute-review workflow<br/><i>model judges names against<br/>the rubric + every name in use</i>]
    U --> Rev[Human reviewer<br/><i>last word</i>]
    AR --> Rev
Loading
  • Unit test, mechanical. It fails, naming the parameter and the suggested rename, on any of these:
    • a name that is not PascalCase, or uses Max/Min or an In<Unit> suffix;
    • a list with a singular name;
    • a reserved name;
    • one name with two types, or one name bound to two settings;
    • an unregistered setting;
    • a bound parameter whose default or allowed values differ from its setting;
    • a built-in test that calls Get-MtSetting;
    • a helper that reads a setting tests bind;
    • a setting the module or a shipped pack reads without declaring it;
    • a shim that does not pass on a bound parameter of the test it calls.
  • Attribute review, judgement. Parameters becomes a reviewed attribute. The reviewer model sees every parameter name already in use, so it can flag a synonym (DormantDays when we already say MaximumInactiveDays) or a vague name.
  • Docs. "Parameter names" and "Parameters bound to a setting" sections in website/docs/writing-tests/attribute-rubric.md.

Decisions

Decided by @merill on 11 November 2026. All nine are implemented in #2758 and #2787.

# Decision Outcome
1 Explicit binding. A parameter takes a setting only when it declares Setting = '...', never by matching names. Agreed
2 Precedence. -Parameter, then the test's TestSettings row, then GlobalSettings, then the default. Agreed
3 What qualifies as a setting. Only tenant facts and organisation-wide choices. A value a benchmark mandates is never bound. Agreed
4 The Defender for Endpoint options. PolicyFiltering and ComplianceLogic are settings. Agreed
5 Naming convention and renames. Adopt the convention and rename now, during the 3.0 previews. Agreed
6 The CISA EXO parked-domain logic. The tests use the ParkedDomains setting instead of inferring from SendingFromDomainDisabled (#2787). CISA.MS.EXO.3.1 keeps checking DKIM on every domain, parked or not, because SCuBA has no separate rule for a parked domain. Agreed
7 Packs. A pack declares its settings in its manifest. Custom tests use Namespace.Key without a declaration. Agreed
8 Invalid settings. A wrong value of a registered setting stops the run. Agreed
9 Unknown keys. A GlobalSettings key without a dot that Maester does not know gives a warning on every run, until it is renamed Namespace.Key. Agreed

Comments are still welcome, but the design is settled unless a review of #2758 finds a problem.

Status

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    status: needs decision
    status: accepted
    and removed
    status: needs decision
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementstatus: accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions