feat(datagen): add GroupIdentity with built-in AD groups and membership#149
Conversation
e955ee9 to
6c1cf6d
Compare
67cf1db to
822f438
Compare
6c1cf6d to
9a3b684
Compare
822f438 to
f7b19a4
Compare
|
|
||
| // GenerateGroups produces groups including built-in AD groups and department-based groups. | ||
| // Users are assigned to groups based on department. At least 1-2 admin users go to Domain Admins. | ||
| func GenerateGroups(seed int64, count int, domain *DomainIdentity, users []*UserIdentity) []*GroupIdentity { |
There was a problem hiding this comment.
I guess, GenerateGroups does not honor count when count is smaller than the built-in catalog. It always appends all built-in groups first, so GenerateGroups(seed, 5, ...) still returns 9 groups. The test even codifies this with “at least 10 groups"
There was a problem hiding this comment.
Renamed the parameter to targetTotal and rewrote the docstring: built-in AD groups (n=9) are always included; department groups append until total reaches targetTotal or the catalog is exhausted (cap at 18). Built-ins shouldn't be truncated since an AD environment without Domain Admins / Domain Users would be incoherent. Test added that exercises targetTotal < 9.
| if domainAdmins != nil && len(users) > 0 { | ||
| adminCount := 1 | ||
| if len(users) > 10 { | ||
| adminCount = 2 | ||
| } | ||
| for i := 0; i < adminCount && i < len(users); i++ { | ||
| idx := r.Intn(len(users)) // #nosec G404 | ||
| domainAdmins.MemberSIDs = append(domainAdmins.MemberSIDs, users[idx].SID) | ||
| users[idx].GroupSIDs = append(users[idx].GroupSIDs, domainAdmins.SID) |
There was a problem hiding this comment.
Can the Domain Admins assignment pick the same user more than once because it samples with replacement? With adminCount = 2, the same SID can be appended twice to domainAdmins.MemberSIDs, and that same group SID can be appended twice to users[idx].GroupSIDs. Correct me if I'm wrong
There was a problem hiding this comment.
adminCount is now a parameter and the picker uses a Fisher-Yates partial shuffle so duplicate user SIDs can't enter MemberSIDs and a single user can't appear twice in GroupSIDs. The previous "1 if users≤10, else 2" heuristic was unrealistic — Microsoft's published guidance is qualitative ("minimize Domain Admins membership") rather than a sizing table; the new step function (2/3/5/8/15/25/35 across user-count buckets up to 10000+) tracks what audited environments commonly observe rather than best-practice. Exposed via EnvironmentOpts.DomainAdminsCount (zero = use heuristic).
9a3b684 to
411dc81
Compare
f7b19a4 to
25932c1
Compare
411dc81 to
c2d0a07
Compare
25932c1 to
deb45b1
Compare
c2d0a07 to
d4d1bd6
Compare
deb45b1 to
8de7833
Compare
d4d1bd6 to
e969cc4
Compare
8de7833 to
4868206
Compare

Proposed Change
Adds
GroupIdentitywith a built-in AD group catalog and membership semantics.Part of PIPE-927 common data generation package stack. Foundation for PIPE-785, PIPE-928, PIPE-943, and the rest of the simulator stack.
Checklist