Repository navigation
fix(cli): parse the minimum password length for CIS 5.2.2 - #35
Open
victor-sys-admin wants to merge 1 commit into
Open
victor-sys-admin wants to merge 1 commit into
victor-sys-admin wants to merge 1 commit into
Conversation
The CLI passed 5.2.2 whenever "minChars" appeared in pwpolicy output.
That string is part of the com.apple.policy.legacy.minChars
identifier, so a 4-character minimum passed too.
Parse the value with the same rules as PasswordMinLengthCheck.swift:
the largest `.{N,}` predicate, else the minimumLength / minChars
parameters, and require N >= 15.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The CLI passed CIS 5.2.2 (minimum password length ≥ 15) as soon as the text
minCharsappeared inpwpolicy -getaccountpolicies.pwpolicy -setglobalpolicy minChars=Nalways creates the identifiercom.apple.policy.legacy.minChars, whatever N is, so a 4-character minimum passed. The app was fixed in #25; the CLI was not.Changes
mergen-cli/internal/checks/password_policy.gonow uses the same rules asPasswordMinLengthCheck.swift:policyAttributePassword matches '.{N,}'predicate, with an optional?or+quantifier;minimumLength(the parameter the CIS audit reads) orminCharsvalue;Messages now include the value, e.g.
Minimum password length is 8 (should be ≥ 15). The remediation and fix are unchanged (pwpolicy -n /Local/Default -setglobalpolicy minChars=15, the CIS terminal method).password_policy_test.go(new) covers the three quantifier forms, a 4-character policy, stacked predicates, a parameter-only output, an unparsable predicate and no policy at all.How it was tested
On an Intel Mac, macOS 15.8.1 (Sequoia), Go 1.27.3:
go build,go vet ./...,go test ./internal/checks/(9 cases), golangci-lint v2.14.0 (no new issues);xcodebuildDebug build (no Swift change)mergen scan --section 5on a Mac with a 15-character policy →✓ 5.2.2Not tested
minLength)Test plan
sudo pwpolicy -n /Local/Default -setglobalpolicy minChars=8→mergen scan --section 5→ 5.2.2 FAIL,Minimum password length is 8 (should be ≥ 15)… minChars=15→ PASSReferences
cis_apple_macOS_26.x.yml(v4.14.9), check 41051 — CIS 5.2.2 audit readsminimumLengthtahoe_rev3, rulepwpolicy_minimum_length_enforce(CC BY 4.0) — takes the largest.{N,predicate