identityscope 0.28.3 → 0.28.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +917 -917
  3. package/SECURITY.md +56 -56
  4. package/dist/node/cli.js +26 -26
  5. package/dist/node/monthly.js +17 -17
  6. package/package.json +2 -2
  7. package/reports/access-profile-members.yaml +29 -29
  8. package/reports/access-profile-membership-counts.yaml +17 -17
  9. package/reports/access-profiles-without-owner.yaml +16 -16
  10. package/reports/access-request-audit-trail.yaml +36 -36
  11. package/reports/accounts-by-source.yaml +19 -19
  12. package/reports/active-identities-without-manager.yaml +22 -22
  13. package/reports/aggregation-failures.yaml +29 -29
  14. package/reports/aggregation-history.yaml +27 -27
  15. package/reports/all-sources.yaml +16 -16
  16. package/reports/application-accounts.yaml +32 -32
  17. package/reports/application-entitlements.yaml +31 -31
  18. package/reports/campaign-progress.yaml +23 -23
  19. package/reports/certification-decisions.yaml +31 -31
  20. package/reports/direct-reports-per-manager.yaml +20 -20
  21. package/reports/disabled-accounts-of-active-people.yaml +33 -33
  22. package/reports/duplicate-emails.yaml +16 -16
  23. package/reports/entitlement-holders.yaml +35 -35
  24. package/reports/entitlements-held-by-inactive-identities.yaml +31 -31
  25. package/reports/entitlements-without-owner.yaml +28 -28
  26. package/reports/identities-by-lifecycle-state.yaml +15 -15
  27. package/reports/identities-missing-key-attributes.yaml +27 -27
  28. package/reports/identities-with-processing-errors.yaml +19 -19
  29. package/reports/identity-attribute-mappings.yaml +27 -27
  30. package/reports/machine-accounts.yaml +28 -28
  31. package/reports/managers-and-direct-reports.yaml +23 -23
  32. package/reports/most-access.yaml +18 -18
  33. package/reports/new-identities.yaml +24 -24
  34. package/reports/old-passwords.yaml +35 -35
  35. package/reports/pending-reviews-by-reviewer.yaml +20 -20
  36. package/reports/person-access.yaml +31 -31
  37. package/reports/privileged-access.yaml +29 -29
  38. package/reports/provisioning-error-causes.yaml +27 -27
  39. package/reports/provisioning-errors.yaml +32 -32
  40. package/reports/provisioning-failures.yaml +28 -28
  41. package/reports/recent-access-requests.yaml +22 -22
  42. package/reports/recent-activity.yaml +32 -32
  43. package/reports/recent-leavers.yaml +34 -34
  44. package/reports/role-members.yaml +29 -29
  45. package/reports/role-membership-counts.yaml +18 -18
  46. package/reports/roles-without-owner.yaml +17 -17
  47. package/reports/sources-needing-attention.yaml +23 -23
  48. package/reports/stuck-access-requests.yaml +29 -29
  49. package/reports/team-access.yaml +30 -30
  50. package/reports/terminated-users-with-active-accounts.yaml +46 -46
  51. package/reports/uncorrelated-accounts.yaml +38 -38
  52. package/ui/js/00-setup.js +6 -6
  53. package/ui/js/01-small-helpers.js +143 -143
  54. package/ui/js/02-connection.js +150 -150
  55. package/ui/js/03-health-check.js +17 -17
  56. package/ui/js/04-library.js +135 -135
  57. package/ui/js/05-pickers.js +163 -163
  58. package/ui/js/06-report-view.js +157 -157
  59. package/ui/js/07-fields.js +85 -85
  60. package/ui/js/08-designer.js +360 -360
  61. package/ui/js/09-yaml.js +22 -22
  62. package/ui/js/10-instant-check.js +171 -171
  63. package/ui/js/11-lookup.js +161 -161
  64. package/ui/js/12-tenant.js +115 -115
  65. package/ui/js/13-source-configuration-and-diagnostics.js +64 -64
  66. package/ui/js/14-certifications.js +68 -68
  67. package/ui/js/15-monthly-report.js +24 -24
  68. package/ui/js/16-ownership.js +39 -39
  69. package/ui/js/17-compare-tenants.js +102 -102
  70. package/ui/js/18-audit.js +181 -181
  71. package/ui/js/19-insights.js +108 -108
  72. package/ui/js/20-role-mining.js +35 -35
  73. package/ui/js/21-share-reports.js +45 -45
  74. package/ui/js/22-partner-overview-all-customer-tenants.js +228 -228
  75. package/ui/js/23-in-app-guidance.js +217 -217
  76. package/ui/js/24-role-tools.js +220 -220
  77. package/ui/js/25-schedules.js +264 -264
  78. package/ui/js/26-start.js +7 -7
  79. package/ui/js/27-warnings.js +224 -224
  80. package/ui/js/28-audit-readiness.js +99 -99
  81. package/ui/js/29-lifecycle.js +182 -182
  82. package/ui/js/30-labs.js +265 -265
  83. package/ui/js/31-build.js +203 -203
  84. package/ui/js/32-lab-examples.js +148 -148
  85. package/ui/js/33-finder.js +89 -89
  86. package/ui/js/34-governance.js +129 -129
  87. package/ui/js/35-watch.js +266 -266
  88. package/ui/js/36-model.js +247 -247
  89. package/ui/js/37-logs-and-watch.js +224 -224
  90. package/ui/shell.html +112 -112
  91. package/ui/style.css +350 -350
package/ui/js/18-audit.js CHANGED
@@ -1,181 +1,181 @@
1
- // ---------- Audit (Certifications, Separation of duties, Review coverage, Access outliers, Provisioning speed, Change history, Evidence pack) ----------
2
- state.au = { tab: 'certs' };
3
- function renderAudit() {
4
- var outer = $('certs');
5
- outer.textContent = '';
6
- var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
7
- outer.appendChild(w);
8
- w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#be185d;background:#fce8f1' }, icon('cert')),
9
- el('div', {}, el('h2', { text: 'Audit' }), el('p', { className: 'desc', text: 'Certifications, separation of duties, review coverage, access outliers, provisioning speed, configuration changes and a ready-made evidence pack for auditors. Read-only.' }))));
10
- groupedTabs(w, 'au', AU_GROUPS, AU_TABS, state.au.tab, function (id) { state.au.tab = id; renderAudit(); });
11
- if (state.au.tab === 'sod') renderSod(w);
12
- else if (state.au.tab === 'changes') renderChanges(w);
13
- else if (state.au.tab === 'evidence') renderEvidence(w);
14
- else if (state.au.tab === 'coverage') renderCoverage(w);
15
- else if (state.au.tab === 'outliers') renderOutliers(w);
16
- else if (state.au.tab === 'speed') renderSpeed(w);
17
- else if (state.au.tab === 'adminaccts') renderAdminAccounts(w);
18
- else if (state.au.tab === 'exceptions') renderExceptions(w);
19
- else if (state.au.tab === 'trail') renderRequestTrail(w);
20
- else if (state.au.tab === 'chain') renderApproverChain(w);
21
- else if (state.au.tab === 'leavertimes') renderLeaverTimes(w);
22
- else if (state.au.tab === 'attrhist') renderAttrHistory(w);
23
- else if (state.au.tab === 'owners') renderOwners(w);
24
- else if (state.au.tab === 'outmodel') renderOutsideModel(w);
25
- else if (state.au.tab === 'composition') renderComposition(w);
26
- else if (state.au.tab === 'reassigned') renderReassigned(w);
27
- else certsTab(w);
28
- }
29
- function moneyText(n, cur) { return n === null || n === undefined ? '—' : (cur ? cur + ' ' : '') + Number(n).toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 2 }); }
30
- function loadInsightSettings(then) {
31
- api('/api/insights/settings').then(function (s) { state.ins = s; then(); }).catch(function (e) { toast(errorText(e)); });
32
- }
33
-
34
- // separation of duties
35
- state.sd = {};
36
- function renderSod(w) {
37
- var S = state.sd;
38
- if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderAudit); return; }
39
- if (!S.rules) S.rules = clone(state.ins.sod || []);
40
- var msg = el('div');
41
- var list = el('div');
42
- var draw = function () {
43
- list.textContent = '';
44
- if (!S.rules.length) list.appendChild(el('div', { className: 'muted', style: 'margin-bottom:10px', text: 'No rules yet. Example: "Create vendor" and "Approve payment" should not be held by the same person.' }));
45
- S.rules.forEach(function (r, i) {
46
- var name = el('input', { className: 'input', value: r.name || '', placeholder: 'Rule name, e.g. Create and approve payments' });
47
- name.addEventListener('input', function () { r.name = name.value; });
48
- var desc = el('input', { className: 'input', value: r.description || '', placeholder: 'Why (optional), e.g. SOX control FIN-07' });
49
- desc.addEventListener('input', function () { r.description = desc.value; });
50
- list.appendChild(el('div', { className: 'card', style: 'margin-bottom:10px;padding:14px' },
51
- el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr auto;align-items:end' },
52
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Rule' }), name),
53
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Reason' }), desc),
54
- el('button', { className: 'btn ghost sm', title: 'Remove rule', onclick: function () { S.rules.splice(i, 1); draw(); } }, icon('trash'))),
55
- el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr;margin-top:10px' },
56
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side A: any of' }), tokenInput({ value: r.sideA || [], placeholder: 'Access name, e.g. SF Admin (Salesforce)', onChange: function (v) { r.sideA = v; } })),
57
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side B: any of' }), tokenInput({ value: r.sideB || [], placeholder: 'Access name, e.g. Approve Payments', onChange: function (v) { r.sideB = v; } })))));
58
- });
59
- };
60
- draw();
61
- w.appendChild(section('Rules', S.rules.length, el('div', {},
62
- el('p', { className: 'muted small', style: 'margin-top:0', text: 'A person breaks a rule when they hold at least one item of side A and one of side B. Use the name of an entitlement, access profile or role as ISC shows it; add the source in brackets to be exact: "Domain Admins (Active Directory)". Matching ignores case.' }),
63
- list,
64
- el('div', { className: 'bar' },
65
- el('button', { className: 'btn', onclick: function () { S.rules.push({ name: '', sideA: [], sideB: [] }); draw(); } }, icon('plus'), 'Add rule'),
66
- el('button', { className: 'btn', onclick: function () {
67
- msg.textContent = '';
68
- api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); toast('Rules saved'); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
69
- } }, icon('save'), 'Save rules'),
70
- el('span', { style: 'flex:1' }),
71
- el('button', { className: 'btn primary', disabled: !!S.busy, onclick: function () {
72
- msg.textContent = '';
73
- api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); runJobInto(S, '/api/sod/run', {}, renderAudit); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
74
- } }, icon('play'), S.data ? 'Check again' : 'Save and check')),
75
- msg)));
76
- if (S.busy) { w.appendChild(busyBox(S.busy)); return; }
77
- if (S.error) { w.appendChild(el('div', { className: 'error', text: S.error })); return; }
78
- var d = S.data;
79
- if (!d) return;
80
- d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
81
- w.appendChild(el('div', { className: 'banner ' + (d.violations.length ? 'bad' : 'ok') }, el('b', { text: d.violations.length ? fmtNum(d.violations.length) + ' violation' + (d.violations.length > 1 ? 's' : '') : 'No violations' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' people checked' }), el('span', { style: 'flex:1' }), downloads(S.job)));
82
- w.appendChild(section('Per rule', null, simpleTable(['Rule', 'Reason', 'People'], d.rules.map(function (r) { return [r.name, r.description, r.violations ? el('span', { className: 'chg lose', text: String(r.violations) }) : 0]; }))));
83
- if (d.violations.length) w.appendChild(section('People who break a rule', d.violations.length, simpleTable(['Rule', 'Person', 'Username', 'Lifecycle state', 'Holds (side A)', 'Holds (side B)'], d.violations.slice(0, 2000).map(function (v) {
84
- return [v.rule, el('button', { className: 'btn link', style: 'padding:0', text: v.person, onclick: function () { openPerson(v.personId); } }), v.username, v.lifecycleState, v.heldA.join(', '), v.heldB.join(', ')];
85
- }))));
86
- }
87
-
88
- // configuration change history
89
- state.ch = {};
90
- function changeTable(d, labels) {
91
- var box = el('div');
92
- box.appendChild(simpleTable(['Type', labels[1], labels[0], 'Changed', 'Unchanged'], d.kinds.map(function (k) {
93
- return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : (k.onlyB.length ? el('span', { className: 'chg gain', text: String(k.onlyB.length) }) : 0), k.error ? null : (k.onlyA.length ? el('span', { className: 'chg lose', text: String(k.onlyA.length) }) : 0), k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];
94
- })));
95
- d.kinds.forEach(function (k) {
96
- if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;
97
- var body = el('div');
98
- if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: labels[1] + ': ' }), k.onlyB.join(', ')));
99
- if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: labels[0] + ': ' }), k.onlyA.join(', ')));
100
- k.different.forEach(function (x) {
101
- body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' change' + (x.differences.length > 1 ? 's' : '') + ')' }),
102
- simpleTable(['Setting', labels[2], labels[3]], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));
103
- });
104
- box.appendChild(section(k.label, null, body));
105
- });
106
- return box;
107
- }
108
- function renderChanges(w) {
109
- // What changed between two snapshots, then drift from the approved baseline (the release that went live).
110
- var top = el('div');
111
- w.appendChild(top);
112
- renderChangesBetween(top);
113
- var drift = el('div', { style: 'margin-top:26px' }, el('h3', { style: 'margin:0 0 8px', text: 'Drift from an approved baseline' }));
114
- w.appendChild(drift);
115
- renderDrift(drift);
116
- }
117
- function renderChangesBetween(w) {
118
- var H = state.ch;
119
- if (!H.days) {
120
- w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));
121
- api('/api/changes').then(function (r) { H.days = r.days; H.from = r.days[1] || r.days[0] || ''; H.to = r.days[0] || ''; renderAudit(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });
122
- return;
123
- }
124
- var snapBtn = el('button', { className: 'btn' + (H.days.length ? '' : ' primary'), disabled: !!H.busy, onclick: function () {
125
- runJobInto(H, '/api/changes/snapshot', {}, function () { if (!H.busy && !H.error) { H.days = null; H.diff = null; } renderAudit(); });
126
- } }, icon('save'), 'Take a snapshot now');
127
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'A snapshot keeps the settings of sources, transforms, identity profiles, roles, access profiles and workflows on this computer (secrets hidden). Scheduled instant checks save one every day by themselves. Compare two days to see what changed.' }), snapBtn));
128
- if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
129
- if (H.error) w.appendChild(el('div', { className: 'error', text: H.error }));
130
- if (H.days.length < 2) {
131
- w.appendChild(el('div', { className: 'empty' }, el('b', { text: H.days.length ? 'One snapshot so far (' + H.days[0] + ')' : 'No snapshots yet' }), 'Take a snapshot now and another one later (or schedule the instant check daily); then pick two days to compare.'));
132
- return;
133
- }
134
- var mk = function (v, set, label) { var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, H.days.map(function (d) { return el('option', { value: d, text: d }); })); s.value = v; s.addEventListener('change', function () { set(s.value); }); return s; };
135
- w.appendChild(el('section', { className: 'card' }, el('div', { className: 'bar' }, el('span', { text: 'What changed from' }), mk(H.from, function (v) { H.from = v; }, 'From snapshot'), el('span', { text: 'to' }), mk(H.to, function (v) { H.to = v; }, 'To snapshot'),
136
- el('button', { className: 'btn primary', onclick: function () {
137
- H.diff = 'loading'; renderAudit();
138
- api('/api/changes/diff?from=' + H.from + '&to=' + H.to).then(function (r) { H.diff = r; renderAudit(); }).catch(function (e) { H.diff = null; H.error = errorText(e); renderAudit(); });
139
- } }, icon('cols'), 'Show changes'),
140
- el('span', { className: 'muted small', text: H.days.length + ' snapshots kept' }))));
141
- if (H.diff === 'loading') { w.appendChild(busyBox('Comparing...')); return; }
142
- if (H.diff) {
143
- var n = H.diff.kinds.reduce(function (s, k) { return s + k.onlyA.length + k.onlyB.length + k.different.length; }, 0);
144
- w.appendChild(el('div', { className: 'banner ' + (n ? 'warn' : 'ok') }, el('b', { text: n ? fmtNum(n) + ' change' + (n > 1 ? 's' : '') + ' from ' + H.diff.from + ' to ' + H.diff.to : 'Nothing changed from ' + H.diff.from + ' to ' + H.diff.to })));
145
- w.appendChild(changeTable(H.diff, ['Removed', 'Added', H.diff.from, H.diff.to]));
146
- }
147
- }
148
-
149
- // evidence pack
150
- state.ev = { days: 365 };
151
- function renderEvidence(w) {
152
- var E = state.ev;
153
- if (!E.sections) {
154
- w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));
155
- api('/api/evidence').then(function (r) { E.sections = r.sections; E.chosen = r.sections.map(function (s) { return s.id; }); renderAudit(); });
156
- return;
157
- }
158
- var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year'], [730, 'Last 2 years']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
159
- period.value = String(E.days);
160
- period.addEventListener('change', function () { E.days = Number(period.value); });
161
- w.appendChild(section('What goes into the pack', null, el('div', {},
162
- el('p', { className: 'muted small', style: 'margin-top:0', text: 'One zip for your auditors: an Excel file per part, a README saying when, by whom and from which tenant it was produced, and SHA-256 fingerprints (SHA256SUMS.txt) so they can check nothing was changed afterwards. Nothing is sent anywhere; you download it.' }),
163
- el('div', { className: 'checklist' }, E.sections.map(function (s) {
164
- var c = el('input', { type: 'checkbox', checked: E.chosen.indexOf(s.id) >= 0 });
165
- c.addEventListener('change', function () { E.chosen = E.chosen.filter(function (x) { return x !== s.id; }); if (c.checked) E.chosen.push(s.id); });
166
- return el('label', { className: 'cl-item' }, c, el('span', {}, el('b', { text: s.label }), el('span', { className: 'muted small', text: ' — ' + s.description })));
167
- })),
168
- el('div', { className: 'bar', style: 'margin-top:12px' }, el('span', { text: 'Period for leavers and requests' }), period, el('span', { style: 'flex:1' }),
169
- el('button', { className: 'btn primary', disabled: !!E.busy, onclick: function () { runJobInto(E, '/api/evidence/run', { sections: E.chosen, days: E.days }, renderAudit); } }, icon('play'), 'Build the pack')))));
170
- if (E.busy) { w.appendChild(busyBox(E.busy)); return; }
171
- if (E.error) { w.appendChild(el('div', { className: 'error', text: E.error })); return; }
172
- var d = E.data;
173
- if (!d) return;
174
- var bad = d.files.filter(function (f) { return f.error; }).length;
175
- w.appendChild(el('div', { className: 'banner ' + (bad ? 'warn' : 'ok') }, el('b', { text: (d.files.length - bad) + ' of ' + d.files.length + ' parts ready' }), el('span', { className: 'muted', text: d.fileName }), el('span', { style: 'flex:1' }),
176
- el('a', { className: 'btn primary sm', href: '/api/evidence/' + E.job + '/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download zip')));
177
- w.appendChild(section('Contents', d.files.length, simpleTable(['Part', 'File', 'Rows', 'SHA-256 fingerprint'], d.files.map(function (f) {
178
- return [f.section, f.error ? el('span', { className: 'chg lose', text: 'not included' }) : f.name, f.rows === null ? null : fmtNum(f.rows), f.error ? f.error : el('code', { className: 'small', text: f.sha256.slice(0, 16) + '…' })];
179
- }))));
180
- }
181
-
1
+ // ---------- Audit (Certifications, Separation of duties, Review coverage, Access outliers, Provisioning speed, Change history, Evidence pack) ----------
2
+ state.au = { tab: 'certs' };
3
+ function renderAudit() {
4
+ var outer = $('certs');
5
+ outer.textContent = '';
6
+ var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
7
+ outer.appendChild(w);
8
+ w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#be185d;background:#fce8f1' }, icon('cert')),
9
+ el('div', {}, el('h2', { text: 'Audit' }), el('p', { className: 'desc', text: 'Certifications, separation of duties, review coverage, access outliers, provisioning speed, configuration changes and a ready-made evidence pack for auditors. Read-only.' }))));
10
+ groupedTabs(w, 'au', AU_GROUPS, AU_TABS, state.au.tab, function (id) { state.au.tab = id; renderAudit(); });
11
+ if (state.au.tab === 'sod') renderSod(w);
12
+ else if (state.au.tab === 'changes') renderChanges(w);
13
+ else if (state.au.tab === 'evidence') renderEvidence(w);
14
+ else if (state.au.tab === 'coverage') renderCoverage(w);
15
+ else if (state.au.tab === 'outliers') renderOutliers(w);
16
+ else if (state.au.tab === 'speed') renderSpeed(w);
17
+ else if (state.au.tab === 'adminaccts') renderAdminAccounts(w);
18
+ else if (state.au.tab === 'exceptions') renderExceptions(w);
19
+ else if (state.au.tab === 'trail') renderRequestTrail(w);
20
+ else if (state.au.tab === 'chain') renderApproverChain(w);
21
+ else if (state.au.tab === 'leavertimes') renderLeaverTimes(w);
22
+ else if (state.au.tab === 'attrhist') renderAttrHistory(w);
23
+ else if (state.au.tab === 'owners') renderOwners(w);
24
+ else if (state.au.tab === 'outmodel') renderOutsideModel(w);
25
+ else if (state.au.tab === 'composition') renderComposition(w);
26
+ else if (state.au.tab === 'reassigned') renderReassigned(w);
27
+ else certsTab(w);
28
+ }
29
+ function moneyText(n, cur) { return n === null || n === undefined ? '—' : (cur ? cur + ' ' : '') + Number(n).toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 2 }); }
30
+ function loadInsightSettings(then) {
31
+ api('/api/insights/settings').then(function (s) { state.ins = s; then(); }).catch(function (e) { toast(errorText(e)); });
32
+ }
33
+
34
+ // separation of duties
35
+ state.sd = {};
36
+ function renderSod(w) {
37
+ var S = state.sd;
38
+ if (!state.ins) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadInsightSettings(renderAudit); return; }
39
+ if (!S.rules) S.rules = clone(state.ins.sod || []);
40
+ var msg = el('div');
41
+ var list = el('div');
42
+ var draw = function () {
43
+ list.textContent = '';
44
+ if (!S.rules.length) list.appendChild(el('div', { className: 'muted', style: 'margin-bottom:10px', text: 'No rules yet. Example: "Create vendor" and "Approve payment" should not be held by the same person.' }));
45
+ S.rules.forEach(function (r, i) {
46
+ var name = el('input', { className: 'input', value: r.name || '', placeholder: 'Rule name, e.g. Create and approve payments' });
47
+ name.addEventListener('input', function () { r.name = name.value; });
48
+ var desc = el('input', { className: 'input', value: r.description || '', placeholder: 'Why (optional), e.g. SOX control FIN-07' });
49
+ desc.addEventListener('input', function () { r.description = desc.value; });
50
+ list.appendChild(el('div', { className: 'card', style: 'margin-bottom:10px;padding:14px' },
51
+ el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr auto;align-items:end' },
52
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Rule' }), name),
53
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Reason' }), desc),
54
+ el('button', { className: 'btn ghost sm', title: 'Remove rule', onclick: function () { S.rules.splice(i, 1); draw(); } }, icon('trash'))),
55
+ el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr;margin-top:10px' },
56
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side A: any of' }), tokenInput({ value: r.sideA || [], placeholder: 'Access name, e.g. SF Admin (Salesforce)', onChange: function (v) { r.sideA = v; } })),
57
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Side B: any of' }), tokenInput({ value: r.sideB || [], placeholder: 'Access name, e.g. Approve Payments', onChange: function (v) { r.sideB = v; } })))));
58
+ });
59
+ };
60
+ draw();
61
+ w.appendChild(section('Rules', S.rules.length, el('div', {},
62
+ el('p', { className: 'muted small', style: 'margin-top:0', text: 'A person breaks a rule when they hold at least one item of side A and one of side B. Use the name of an entitlement, access profile or role as ISC shows it; add the source in brackets to be exact: "Domain Admins (Active Directory)". Matching ignores case.' }),
63
+ list,
64
+ el('div', { className: 'bar' },
65
+ el('button', { className: 'btn', onclick: function () { S.rules.push({ name: '', sideA: [], sideB: [] }); draw(); } }, icon('plus'), 'Add rule'),
66
+ el('button', { className: 'btn', onclick: function () {
67
+ msg.textContent = '';
68
+ api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); toast('Rules saved'); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
69
+ } }, icon('save'), 'Save rules'),
70
+ el('span', { style: 'flex:1' }),
71
+ el('button', { className: 'btn primary', disabled: !!S.busy, onclick: function () {
72
+ msg.textContent = '';
73
+ api('/api/sod/rules', 'PUT', { rules: S.rules }).then(function () { state.ins.sod = clone(S.rules); runJobInto(S, '/api/sod/run', {}, renderAudit); }).catch(function (e) { msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
74
+ } }, icon('play'), S.data ? 'Check again' : 'Save and check')),
75
+ msg)));
76
+ if (S.busy) { w.appendChild(busyBox(S.busy)); return; }
77
+ if (S.error) { w.appendChild(el('div', { className: 'error', text: S.error })); return; }
78
+ var d = S.data;
79
+ if (!d) return;
80
+ d.notes.forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
81
+ w.appendChild(el('div', { className: 'banner ' + (d.violations.length ? 'bad' : 'ok') }, el('b', { text: d.violations.length ? fmtNum(d.violations.length) + ' violation' + (d.violations.length > 1 ? 's' : '') : 'No violations' }), el('span', { className: 'muted', text: fmtNum(d.peopleChecked) + ' people checked' }), el('span', { style: 'flex:1' }), downloads(S.job)));
82
+ w.appendChild(section('Per rule', null, simpleTable(['Rule', 'Reason', 'People'], d.rules.map(function (r) { return [r.name, r.description, r.violations ? el('span', { className: 'chg lose', text: String(r.violations) }) : 0]; }))));
83
+ if (d.violations.length) w.appendChild(section('People who break a rule', d.violations.length, simpleTable(['Rule', 'Person', 'Username', 'Lifecycle state', 'Holds (side A)', 'Holds (side B)'], d.violations.slice(0, 2000).map(function (v) {
84
+ return [v.rule, el('button', { className: 'btn link', style: 'padding:0', text: v.person, onclick: function () { openPerson(v.personId); } }), v.username, v.lifecycleState, v.heldA.join(', '), v.heldB.join(', ')];
85
+ }))));
86
+ }
87
+
88
+ // configuration change history
89
+ state.ch = {};
90
+ function changeTable(d, labels) {
91
+ var box = el('div');
92
+ box.appendChild(simpleTable(['Type', labels[1], labels[0], 'Changed', 'Unchanged'], d.kinds.map(function (k) {
93
+ return [k.label, k.error ? el('span', { className: 'chg lose', text: k.error }) : (k.onlyB.length ? el('span', { className: 'chg gain', text: String(k.onlyB.length) }) : 0), k.error ? null : (k.onlyA.length ? el('span', { className: 'chg lose', text: String(k.onlyA.length) }) : 0), k.error ? null : (k.different.length ? el('span', { className: 'chg lose', text: String(k.different.length) }) : 0), k.error ? null : k.same];
94
+ })));
95
+ d.kinds.forEach(function (k) {
96
+ if (k.error || (!k.onlyA.length && !k.onlyB.length && !k.different.length)) return;
97
+ var body = el('div');
98
+ if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: labels[1] + ': ' }), k.onlyB.join(', ')));
99
+ if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: labels[0] + ': ' }), k.onlyA.join(', ')));
100
+ k.different.forEach(function (x) {
101
+ body.appendChild(el('details', { className: 'adv', style: 'margin:8px 0' }, el('summary', { text: x.name + ' (' + x.differences.length + ' change' + (x.differences.length > 1 ? 's' : '') + ')' }),
102
+ simpleTable(['Setting', labels[2], labels[3]], x.differences.map(function (y) { return [y.path, y.a, y.b]; }))));
103
+ });
104
+ box.appendChild(section(k.label, null, body));
105
+ });
106
+ return box;
107
+ }
108
+ function renderChanges(w) {
109
+ // What changed between two snapshots, then drift from the approved baseline (the release that went live).
110
+ var top = el('div');
111
+ w.appendChild(top);
112
+ renderChangesBetween(top);
113
+ var drift = el('div', { style: 'margin-top:26px' }, el('h3', { style: 'margin:0 0 8px', text: 'Drift from an approved baseline' }));
114
+ w.appendChild(drift);
115
+ renderDrift(drift);
116
+ }
117
+ function renderChangesBetween(w) {
118
+ var H = state.ch;
119
+ if (!H.days) {
120
+ w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));
121
+ api('/api/changes').then(function (r) { H.days = r.days; H.from = r.days[1] || r.days[0] || ''; H.to = r.days[0] || ''; renderAudit(); }).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); });
122
+ return;
123
+ }
124
+ var snapBtn = el('button', { className: 'btn' + (H.days.length ? '' : ' primary'), disabled: !!H.busy, onclick: function () {
125
+ runJobInto(H, '/api/changes/snapshot', {}, function () { if (!H.busy && !H.error) { H.days = null; H.diff = null; } renderAudit(); });
126
+ } }, icon('save'), 'Take a snapshot now');
127
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1', text: 'A snapshot keeps the settings of sources, transforms, identity profiles, roles, access profiles and workflows on this computer (secrets hidden). Scheduled instant checks save one every day by themselves. Compare two days to see what changed.' }), snapBtn));
128
+ if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
129
+ if (H.error) w.appendChild(el('div', { className: 'error', text: H.error }));
130
+ if (H.days.length < 2) {
131
+ w.appendChild(el('div', { className: 'empty' }, el('b', { text: H.days.length ? 'One snapshot so far (' + H.days[0] + ')' : 'No snapshots yet' }), 'Take a snapshot now and another one later (or schedule the instant check daily); then pick two days to compare.'));
132
+ return;
133
+ }
134
+ var mk = function (v, set, label) { var s = el('select', { className: 'input', style: 'width:auto', 'aria-label': label }, H.days.map(function (d) { return el('option', { value: d, text: d }); })); s.value = v; s.addEventListener('change', function () { set(s.value); }); return s; };
135
+ w.appendChild(el('section', { className: 'card' }, el('div', { className: 'bar' }, el('span', { text: 'What changed from' }), mk(H.from, function (v) { H.from = v; }, 'From snapshot'), el('span', { text: 'to' }), mk(H.to, function (v) { H.to = v; }, 'To snapshot'),
136
+ el('button', { className: 'btn primary', onclick: function () {
137
+ H.diff = 'loading'; renderAudit();
138
+ api('/api/changes/diff?from=' + H.from + '&to=' + H.to).then(function (r) { H.diff = r; renderAudit(); }).catch(function (e) { H.diff = null; H.error = errorText(e); renderAudit(); });
139
+ } }, icon('cols'), 'Show changes'),
140
+ el('span', { className: 'muted small', text: H.days.length + ' snapshots kept' }))));
141
+ if (H.diff === 'loading') { w.appendChild(busyBox('Comparing...')); return; }
142
+ if (H.diff) {
143
+ var n = H.diff.kinds.reduce(function (s, k) { return s + k.onlyA.length + k.onlyB.length + k.different.length; }, 0);
144
+ w.appendChild(el('div', { className: 'banner ' + (n ? 'warn' : 'ok') }, el('b', { text: n ? fmtNum(n) + ' change' + (n > 1 ? 's' : '') + ' from ' + H.diff.from + ' to ' + H.diff.to : 'Nothing changed from ' + H.diff.from + ' to ' + H.diff.to })));
145
+ w.appendChild(changeTable(H.diff, ['Removed', 'Added', H.diff.from, H.diff.to]));
146
+ }
147
+ }
148
+
149
+ // evidence pack
150
+ state.ev = { days: 365 };
151
+ function renderEvidence(w) {
152
+ var E = state.ev;
153
+ if (!E.sections) {
154
+ w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...'));
155
+ api('/api/evidence').then(function (r) { E.sections = r.sections; E.chosen = r.sections.map(function (s) { return s.id; }); renderAudit(); });
156
+ return;
157
+ }
158
+ var period = el('select', { className: 'input', style: 'width:auto', 'aria-label': 'Period' }, [[90, 'Last 90 days'], [180, 'Last 180 days'], [365, 'Last year'], [730, 'Last 2 years']].map(function (o) { return el('option', { value: String(o[0]), text: o[1] }); }));
159
+ period.value = String(E.days);
160
+ period.addEventListener('change', function () { E.days = Number(period.value); });
161
+ w.appendChild(section('What goes into the pack', null, el('div', {},
162
+ el('p', { className: 'muted small', style: 'margin-top:0', text: 'One zip for your auditors: an Excel file per part, a README saying when, by whom and from which tenant it was produced, and SHA-256 fingerprints (SHA256SUMS.txt) so they can check nothing was changed afterwards. Nothing is sent anywhere; you download it.' }),
163
+ el('div', { className: 'checklist' }, E.sections.map(function (s) {
164
+ var c = el('input', { type: 'checkbox', checked: E.chosen.indexOf(s.id) >= 0 });
165
+ c.addEventListener('change', function () { E.chosen = E.chosen.filter(function (x) { return x !== s.id; }); if (c.checked) E.chosen.push(s.id); });
166
+ return el('label', { className: 'cl-item' }, c, el('span', {}, el('b', { text: s.label }), el('span', { className: 'muted small', text: ' — ' + s.description })));
167
+ })),
168
+ el('div', { className: 'bar', style: 'margin-top:12px' }, el('span', { text: 'Period for leavers and requests' }), period, el('span', { style: 'flex:1' }),
169
+ el('button', { className: 'btn primary', disabled: !!E.busy, onclick: function () { runJobInto(E, '/api/evidence/run', { sections: E.chosen, days: E.days }, renderAudit); } }, icon('play'), 'Build the pack')))));
170
+ if (E.busy) { w.appendChild(busyBox(E.busy)); return; }
171
+ if (E.error) { w.appendChild(el('div', { className: 'error', text: E.error })); return; }
172
+ var d = E.data;
173
+ if (!d) return;
174
+ var bad = d.files.filter(function (f) { return f.error; }).length;
175
+ w.appendChild(el('div', { className: 'banner ' + (bad ? 'warn' : 'ok') }, el('b', { text: (d.files.length - bad) + ' of ' + d.files.length + ' parts ready' }), el('span', { className: 'muted', text: d.fileName }), el('span', { style: 'flex:1' }),
176
+ el('a', { className: 'btn primary sm', href: '/api/evidence/' + E.job + '/download?k=' + encodeURIComponent(KEY), download: '' }, icon('download'), 'Download zip')));
177
+ w.appendChild(section('Contents', d.files.length, simpleTable(['Part', 'File', 'Rows', 'SHA-256 fingerprint'], d.files.map(function (f) {
178
+ return [f.section, f.error ? el('span', { className: 'chg lose', text: 'not included' }) : f.name, f.rows === null ? null : fmtNum(f.rows), f.error ? f.error : el('code', { className: 'small', text: f.sha256.slice(0, 16) + '…' })];
179
+ }))));
180
+ }
181
+