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/35-watch.js CHANGED
@@ -1,266 +1,266 @@
1
- // ---------- 0.23.0: drift, incidents, cleanup, and Non-employees (NERM) ----------
2
- function owState() {
3
- if (!state.wt) state.wt = {
4
- massch: { days: 30, factor: 3, min: 50 }, loops: { days: 7, min: 5 }, outside: { days: 0, sourceIds: [] }, syncdrift: { sourceIds: [] },
5
- groupappr: {}, mgrleft: { query: '' }, leavertimes: { days: 30, limitHours: 24 }, attrhist: { attributes: 'manager, department, title, cloudLifecycleState' },
6
- owners: {}, rules: { cloudRules: false }
7
- };
8
- return state.wt;
9
- }
10
- function owRunBar(w, H, path, label, desc, extras, body, rerender) {
11
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,
12
- el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, path, body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));
13
- if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }
14
- if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }
15
- if (!H.data) return false;
16
- (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
17
- return true;
18
- }
19
- /** Source picker (one or several), loaded once per page visit. */
20
- function sourcePick(H, multiple, rerender, label) {
21
- if (!H.sources) {
22
- H.sources = 'loading';
23
- api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(rerender);
24
- }
25
- var list = Array.isArray(H.sources) ? H.sources : [];
26
- var pick = el('select', { className: 'input', multiple: multiple, size: multiple ? 4 : null, style: 'min-width:220px;width:auto', 'aria-label': label }, (multiple ? [] : [el('option', { value: '', text: list.length ? 'Pick a source' : 'Loading sources...' })]).concat(list.map(function (s) {
27
- return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });
28
- })));
29
- pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected && o.value; }).map(function (o) { return o.value; }); });
30
- return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label + (multiple ? ' (Ctrl+click for more)' : '') }), pick);
31
- }
32
- function hrs(h) { return h === null || h === undefined ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; }
33
- function when16(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }
34
- function warnRerender() { if (state.page === 'warnings') renderWarnings(); }
35
-
36
- // Warnings > Mass changes
37
- function wnMassChange(w, _H, desc) {
38
- var H = owState().massch;
39
- var extras = el('div', { className: 'bar' },
40
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Usual level from the last' }), numSelect(H, 'days', [[14, '14 days'], [30, '30 days'], [60, '60 days']], 'Baseline period')),
41
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Spike at' }), numSelect(H, 'factor', [[2, '2× usual'], [3, '3× usual'], [5, '5× usual'], [10, '10× usual']], 'Spike factor')),
42
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'and at least' }), numSelect(H, 'min', [[20, '20 changes'], [50, '50 changes'], [200, '200 changes'], [1000, '1,000 changes']], 'Minimum changes')));
43
- if (!owRunBar(w, H, '/api/watch/mass-change/run', 'Check for spikes', desc, extras, function () { return { days: H.days, factor: H.factor, min: H.min }; }, renderWarnings)) return;
44
- var d = H.data;
45
- w.appendChild(el('div', { className: 'bigstats' }, d.series.map(function (x) {
46
- return el('div', { className: 'bigstat' + (x.spike ? ' lose' : '') }, el('b', { text: fmtNum(x.latest) }), el('span', { text: x.label + ' on ' + x.latestDay + ' (usual ' + fmtNum(Math.round(x.usual)) + ')' + (x.spike ? ': spike' : '') }));
47
- })));
48
- d.series.filter(function (x) { return x.spike; }).forEach(function (x) {
49
- w.appendChild(section('Spike: ' + x.label.toLowerCase() + ' on ' + x.latestDay, x.latest, simpleTable(['Source', 'Changes'], x.bySource.map(function (s) { return [s.source, fmtNum(s.count)]; }), 'Spike by source: ' + x.label)));
50
- });
51
- var all = d.series[0];
52
- var maxv = Math.max.apply(null, all.daily.map(function (p) { return p.count; }).concat([1]));
53
- var bars = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:90px;margin:8px 0', role: 'img', 'aria-label': 'Provisioning per day: ' + all.daily.map(function (p) { return p.day + ' ' + p.count; }).join(', ') }, all.daily.map(function (p) {
54
- return el('div', { title: p.day + ': ' + p.count, style: 'flex:1;min-width:3px;background:' + (p.day === all.latestDay && all.spike ? 'var(--danger)' : 'var(--accent)') + ';height:' + Math.max(2, Math.round(p.count / maxv * 88)) + 'px;border-radius:2px 2px 0 0' });
55
- }));
56
- w.appendChild(section('All provisioning per day', null, el('div', {}, bars, el('div', { className: 'bar', style: 'justify-content:flex-end' }, downloads(H.job)))));
57
- }
58
-
59
- // Warnings > Provisioning loops
60
- function wnLoops(w, _H, desc) {
61
- var H = owState().loops;
62
- var extras = el('div', { className: 'bar' },
63
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),
64
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sent at least' }), numSelect(H, 'min', [[3, '3 times'], [5, '5 times'], [10, '10 times'], [20, '20 times']], 'Minimum repeats')));
65
- if (!owRunBar(w, H, '/api/watch/loops/run', 'Find loops', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;
66
- var d = H.data;
67
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.read, 'activities read'), stat(d.rows.length + (d.more || 0), 'changes sent again and again', 'lose')));
68
- if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No change was sent that often.' })); return; }
69
- w.appendChild(section('Loops', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Source', 'Operation', 'Change', 'Times', 'First', 'Last', 'Last result'], function (r) {
70
- return [r.person, r.source, r.op, el('span', { className: 'small', text: r.change }), pill(String(r.times), 'lose'), when16(r.first), when16(r.last), r.lastStatus];
71
- }, 'Provisioning loops')));
72
- }
73
-
74
- // Warnings > Changed outside ISC
75
- function wnOutside(w, _H, desc) {
76
- var H = owState().outside;
77
- var extras = el('div', { className: 'bar' }, sourcePick(H, true, warnRerender, 'Sources'),
78
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compare with what ISC sent in' }), numSelect(H, 'days', [[0, 'All history'], [30, 'the last 30 days'], [90, 'the last 90 days'], [180, 'the last 180 days'], [365, 'the last 365 days']], 'Period')));
79
- if (!owRunBar(w, H, '/api/watch/outside/run', 'Find changes made outside ISC', desc, extras, function () { return { days: H.days, sourceIds: H.sourceIds }; }, renderWarnings)) return;
80
- var d = H.data, T = d.totals;
81
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.disabledOutside, 'disabled outside ISC', 'lose'), stat(T.enabledOutside, 'enabled again outside ISC', 'lose')));
82
- if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every account state matches what ISC sent.' })); return; }
83
- w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Person state', 'Account', 'Source', 'Finding', 'Last disable or enable ISC sent'], function (r) { return [r.person, r.personState, r.account, r.source, r.finding, r.lastIsc]; }, 'Changes made outside ISC')));
84
- }
85
-
86
- // Warnings > Attribute sync drift
87
- function wnSyncDrift(w, _H, desc) {
88
- var H = owState().syncdrift;
89
- var extras = el('div', { className: 'bar' }, sourcePick(H, false, warnRerender, 'Source'));
90
- if (!owRunBar(w, H, '/api/watch/sync-drift/run', 'Compare values', desc, extras, function () { return { sourceIds: H.sourceIds.slice(0, 1) }; }, renderWarnings)) return;
91
- var d = H.data, T = d.totals;
92
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.mappings.length, 'attributes synced'), stat(T.accounts, 'accounts'), stat(T.compared, 'values compared'), stat(T.drifted, 'values that differ', 'lose'), stat(T.failedSyncs, 'failed syncs (14 days)', 'lose')));
93
- if (d.mappings.length) w.appendChild(el('p', { className: 'muted small', text: 'Synced: ' + d.mappings.map(function (m) { return m.identityAttribute + ' → ' + m.accountAttribute; }).join(', ') }));
94
- if (d.rows.length) w.appendChild(section('Values that differ', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Account', 'Attribute', 'Value in ISC', 'Value on the account'], function (r) { return [r.person, r.account, r.identityAttribute + ' → ' + r.accountAttribute, r.inIsc, r.onAccount]; }, 'Attribute sync drift')));
95
- else if (d.mappings.length) w.appendChild(el('p', { className: 'muted', text: 'Every synced value matches.' }));
96
- if (d.failedSyncs.length) w.appendChild(section('Failed attribute syncs', d.failedSyncs.length, simpleTable(['When', 'Person', 'Detail'], d.failedSyncs.slice(0, 500).map(function (f) { return [when16(f.when), f.person, f.detail]; }), 'Failed attribute syncs')));
97
- }
98
-
99
- // Warnings > Group approvals
100
- function wnGroupApprovals(w, _H, desc) {
101
- var H = owState().groupappr;
102
- if (!owRunBar(w, H, '/api/watch/group-approvals/run', 'Check group approvers', desc, null, null, renderWarnings)) return;
103
- var d = H.data, T = d.totals;
104
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.pending, 'approvals waiting on a group'), stat(T.groups, 'groups'), stat(T.noActiveMember, 'with no active member left', 'lose')));
105
- if (!d.rows.length) return;
106
- w.appendChild(section('Approvals', d.rows.length, filteredTable(H, d.rows, ['Group', 'Access', 'Requested for', 'Waiting', 'Members', 'Members who left'], function (r) {
107
- return [r.group, r.request, r.requestedFor, r.waitingDays === null ? '—' : r.waitingDays + ' days', el('span', {}, r.activeMembers + ' of ' + r.members + ' active ', r.activeMembers === 0 ? pill('nobody can approve', 'lose') : null), r.leftMembers.join(', ')];
108
- }, 'Approvals waiting on governance groups')));
109
- }
110
-
111
- // Warnings > Manager left
112
- function wnManagerLeft(w, _H, desc) {
113
- var H = owState().mgrleft;
114
- var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.employeeType:contractor', style: 'max-width:300px', 'aria-label': 'Only people matching (search query, optional)' });
115
- q.addEventListener('input', function () { H.query = q.value; });
116
- var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only people matching (optional)' }), q);
117
- if (!owRunBar(w, H, '/api/watch/manager-left/run', 'Find people', desc, extras, function () { return { query: H.query || undefined }; }, renderWarnings)) return;
118
- var d = H.data;
119
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'active people'), stat(d.totals.managerLeft, 'whose manager left', 'lose')));
120
- if (!d.rows.length) return;
121
- w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Identity profile', 'Manager', 'Manager state'], function (r) { return [r.person, r.lifecycle, r.profile, r.manager, pill(r.managerState, 'lose')]; }, 'People whose manager left')));
122
- }
123
-
124
- // Audit > Leaver removal times
125
- function renderLeaverTimes(w) {
126
- var H = owState().leavertimes;
127
- var extras = el('div', { className: 'bar' },
128
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Leavers of the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period')),
129
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Limit' }), numSelect(H, 'limitHours', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '72 hours'], [168, '7 days']], 'Removal limit')));
130
- if (!owRunBar(w, H, '/api/watch/leaver-times/run', 'Time the leavers', 'For each leaver: when leaving started (lifecycle change), when each account was disabled, and which accounts are still enabled. The per-person figure auditors ask for.', extras, function () { return { days: H.days, limitHours: H.limitHours }; }, renderAudit)) return;
131
- var d = H.data, T = d.totals;
132
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.leavers, 'leavers'), stat(T.late, 'over ' + d.limitHours + ' h or not done', 'lose'), stat(T.stillEnabled, 'with an account still enabled', 'lose'), el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHours) }), el('span', { text: 'median removal time' }))));
133
- if (!d.rows.length) return;
134
- w.appendChild(section('Leavers', d.rows.length, filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Started', 'Accounts', 'Slowest removal', 'Still enabled on', 'Result'], function (r) {
135
- return [r.person, r.lifecycle, el('span', {}, when16(r.started) || '—', el('div', { className: 'small muted', text: r.startedBy })), r.accounts, hrs(r.slowestHours), r.stillEnabled.join(', '), pill(r.late ? 'late' : 'on time', r.late ? 'lose' : 'win')];
136
- }, 'Leaver removal times')));
137
- }
138
-
139
- // Audit > Attribute changes
140
- function renderAttrHistory(w) {
141
- var H = owState().attrhist;
142
- var i = el('input', { className: 'input', value: H.attributes, style: 'max-width:380px', 'aria-label': 'Attributes to follow (comma-separated)' });
143
- i.addEventListener('input', function () { H.attributes = i.value; });
144
- var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Attributes to follow (comma-separated)' }), i);
145
- if (!owRunBar(w, H, '/api/watch/attr-history/run', 'Look now', 'Who changed manager, department, title or lifecycle state, from what to what. IdentityScope remembers the values at each look and lists the changes between looks.', extras,
146
- function () { return { attributes: H.attributes.split(',').map(function (x) { return x.trim(); }).filter(Boolean) }; }, renderAudit)) return;
147
- var d = H.data;
148
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.people, 'people looked at'), stat(d.newChanges, 'changes since the last look'), stat(d.changes.length + (d.more || 0), 'changes on record')));
149
- if (d.previousLook) w.appendChild(el('p', { className: 'muted small', text: 'Previous look: ' + when16(d.previousLook) }));
150
- if (!d.changes.length) return;
151
- w.appendChild(section('Changes', d.changes.length + (d.more || 0), filteredTable(H, d.changes, ['Seen at', 'Person', 'Attribute', 'From', 'To'], function (r) { return [when16(r.at), r.person, r.attribute, r.from || '(empty)', r.to || '(empty)']; }, 'Attribute changes')));
152
- }
153
-
154
- // Audit > Entitlement owners
155
- function renderOwners(w) {
156
- var H = owState().owners;
157
- if (!owRunBar(w, H, '/api/watch/owners/run', 'Read owners', 'Every entitlement owner with what they own and how many people hold each item, so each owner can review their own access. Owners who left are listed first.', null, null, renderAudit)) return;
158
- var d = H.data;
159
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.owners.length, 'owners'), stat(d.owners.filter(function (o) { return o.ownerState !== 'active'; }).length, 'owners who left or are not found', 'lose'), stat(d.rows.length + (d.more || 0), 'owned entitlements')));
160
- w.appendChild(section('Owners', d.owners.length, simpleTable(['Owner', 'State', 'Entitlements', 'Holders'], d.owners.map(function (o) {
161
- return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.entitlements), fmtNum(o.holders)];
162
- }), 'Entitlement owners')));
163
- w.appendChild(section('Entitlements', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Owner', 'Entitlement', 'Source', 'Privileged', 'Holders'], function (r) { return [r.owner, r.entitlement, r.source, r.privileged ? 'Yes' : '', r.holders === null ? '—' : fmtNum(r.holders)]; }, 'Entitlements by owner')));
164
- }
165
-
166
- // Tenant > Rule usage
167
- function renderRuleUsage(w) {
168
- var H = owState().rules;
169
- var cb = el('input', { type: 'checkbox', checked: H.cloudRules });
170
- cb.addEventListener('change', function () { H.cloudRules = cb.checked; });
171
- var extras = el('label', { className: 'check', title: 'Starts an SP-Config export job in the tenant (it reads only, but the job shows in ISC).' }, cb, 'Also list cloud rules (SP-Config export)');
172
- if (!owRunBar(w, H, '/api/watch/rules/run', 'Find where rules are used', 'Every connector rule and cloud rule with the sources, policies, transforms and identity attributes that use it. Unused rules are cleanup candidates; rules used but missing break at run time.', extras,
173
- function () { return { cloudRules: H.cloudRules }; }, renderTenant)) return;
174
- var d = H.data, T = d.totals;
175
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.rules, 'rules'), stat(T.unused, 'not used anywhere', 'lose'), stat(T.missing, 'used but missing', 'lose')));
176
- w.appendChild(section('Rules', d.rows.length, filteredTable(H, d.rows, ['Rule', 'Kind', 'Used by', 'Finding'], function (r) {
177
- return [r.rule, r.kind, r.usedBy.length ? el('div', {}, r.usedBy.map(function (u) { return el('div', { className: 'small', text: u }); })) : '', r.finding ? pill(r.finding, 'lose') : ''];
178
- }, 'Rule usage')));
179
- }
180
-
181
- // ---------- Non-employees (NERM) page ----------
182
- function nmState() {
183
- if (!state.nm) state.nm = { tab: 'overview', settings: null, overview: { days: 30, endAttribute: '' }, sync: {}, sessions: { minDays: 0 }, risk: {}, users: {} };
184
- return state.nm;
185
- }
186
- var NM_TABS = [
187
- ['overview', 'End dates and sponsors', 'clock', 'Active non-employees past their end date or ending soon, and non-employees without a sponsor or whose sponsor has left.'],
188
- ['sync', 'NERM vs ISC', 'cols', 'Profiles whose status in NERM does not match their identity in ISC: terminated in NERM but still active in ISC, and the reverse.'],
189
- ['sessions', 'Waiting workflows', 'lifecycle', 'NERM workflow sessions still waiting for an approval, review, fulfilment or another step.'],
190
- ['risk', 'High risk', 'shield', 'Non-employees with the highest NERM risk level, active ones first.'],
191
- ['users', 'Portal users who left', 'people', 'Sponsors, managers and admins who can still sign in to NERM although their identity in ISC has left.']
192
- ];
193
- function renderNerm() {
194
- var N = nmState();
195
- var outer = $('nerm');
196
- outer.textContent = '';
197
- var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
198
- outer.appendChild(w);
199
- w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#ccfbf1' }, icon('people')),
200
- el('div', {}, el('h2', { text: 'Non-employees' }), el('p', { className: 'desc', text: 'Contractors, vendors and other non-employees in Non-Employee Risk Management (NERM), checked against ISC. Read-only: GET requests on seven NERM read endpoints only.' }))));
201
- if (!N.settings) {
202
- N.settings = 'loading';
203
- api('/api/nerm/settings').then(function (s) { N.settings = s; }, function () { N.settings = {}; }).then(function () { if (state.page === 'nerm') renderNerm(); });
204
- }
205
- var S = N.settings && N.settings !== 'loading' ? N.settings : {};
206
- var addr = el('input', { className: 'input', value: N.addrDraft !== undefined ? N.addrDraft : (S.address || ''), placeholder: 'acme or https://acme.nonemployee.com', style: 'max-width:320px', 'aria-label': 'NERM address' });
207
- addr.addEventListener('input', function () { N.addrDraft = addr.value; });
208
- w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' }, el('div', { className: 'bar' },
209
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'NERM address' }), addr),
210
- el('button', { className: 'btn', onclick: function () {
211
- api('/api/nerm/settings', 'PUT', { address: addr.value }).then(function (s) { N.settings = s; N.addrDraft = undefined; toast(s.address ? 'Saved' : 'Cleared'); renderNerm(); }, function (e) { toast(errorText(e)); });
212
- } }, 'Save'),
213
- el('span', { className: 'muted small', style: 'flex:1;min-width:260px', text: S.base ? 'Reads ' + S.base + ' with the same sign-in as ISC. The API client or token needs a NERM scope (nerm:api:read-only is enough).' : 'Uses the same sign-in as ISC: no second secret. The API client or token needs a NERM scope (nerm:api:read-only is enough).' }))));
214
- var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });
215
- NM_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (N.tab === t[0] ? ' active' : ''), onclick: function () { N.tab = t[0]; renderNerm(); } }, icon(t[2]), t[1])); });
216
- w.appendChild(tabs);
217
- var spec = NM_TABS.filter(function (t) { return t[0] === N.tab; })[0];
218
- ({ overview: nmOverview, sync: nmSync, sessions: nmSessions, risk: nmRisk, users: nmUsers })[N.tab](w, N[N.tab], spec[3]);
219
- }
220
- function nmBar(w, H, kind, label, desc, extras, body) { return owRunBar(w, H, '/api/nerm/' + kind + '/run', label, desc, extras, body, renderNerm); }
221
- function nmProfileTable(H, rows, label, withEnd) {
222
- return filteredTable(H, rows, withEnd ? ['Profile', 'Type', 'End date', 'When', 'Sponsor'] : ['Profile', 'Type', 'Sponsor', 'Problem'], function (r) {
223
- return withEnd ? [r.name, r.type, r.endDate, pill(daysText(r.daysLeft), r.daysLeft < 0 || r.daysLeft <= 7 ? 'lose' : 'off'), r.sponsors] : [r.name, r.type, r.sponsors || '—', pill(r.sponsorProblem, 'lose')];
224
- }, label);
225
- }
226
- function nmOverview(w, H, desc) {
227
- var extras = el('div', { className: 'bar' },
228
- el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Ending within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Ending within')),
229
- attrInput(H, 'endAttribute', 'End-date attribute (optional)', 'found automatically'));
230
- if (!nmBar(w, H, 'overview', 'Check non-employees', desc, extras, function () { return { days: H.days, endAttribute: H.endAttribute || undefined }; })) return;
231
- var d = H.data, T = d.totals;
232
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'profiles'), stat(T.active, 'active'), stat(T.pastEnd, 'active past their end date', 'lose'), stat(T.ending, 'ending in ' + H.days + ' days'), stat(T.noSponsor, 'without a sponsor', 'lose'), stat(T.sponsorLeft, 'whose sponsor left', 'lose')));
233
- if (d.endAttribute || d.sponsorAttributes.length) w.appendChild(el('p', { className: 'muted small', text: [d.endAttribute ? 'End date from: ' + d.endAttribute : '', d.sponsorAttributes.length ? 'Sponsor from: ' + d.sponsorAttributes.join(', ') : ''].filter(Boolean).join(' · ') }));
234
- w.appendChild(section('By profile type', d.byType.length, simpleTable(['Profile type', 'Category', 'Active', 'On leave', 'Inactive', 'Terminated'], d.byType.map(function (b) { return [b.type, b.category, fmtNum(b.active), fmtNum(b.onLeave), fmtNum(b.inactive), fmtNum(b.terminated)]; }), 'Profiles by type')));
235
- if (d.pastEnd.length) w.appendChild(section('Active past their end date', d.pastEnd.length, nmProfileTable(H.past || (H.past = { data: d, job: H.job }), d.pastEnd, 'Active past end date', true)));
236
- if (d.ending.length) w.appendChild(section('Ending soon', d.ending.length, nmProfileTable(H.soon || (H.soon = { data: d, job: H.job }), d.ending, 'Ending soon', true)));
237
- if (d.sponsorIssues.length) w.appendChild(section('Sponsor problems', d.sponsorIssues.length, nmProfileTable(H.sp || (H.sp = { data: d, job: H.job }), d.sponsorIssues, 'Sponsor problems', false)));
238
- }
239
- function nmSync(w, H, desc) {
240
- if (!nmBar(w, H, 'sync', 'Compare with ISC', desc)) return;
241
- var d = H.data, T = d.totals;
242
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.synced, 'profiles of synced types'), stat(T.checked, 'matched to an identity'), stat(T.leftInNermActiveInIsc, 'left in NERM, active in ISC', 'lose'), stat(T.activeInNermLeftInIsc, 'active in NERM, inactive in ISC', 'lose'), stat(T.notInIsc, 'active but not in ISC', 'lose')));
243
- if (d.sources.length) w.appendChild(el('p', { className: 'muted small', text: 'Matched through the ISC source' + (d.sources.length > 1 ? 's ' : ' ') + d.sources.join(', ') + '.' }));
244
- if (!d.rows.length) return;
245
- w.appendChild(section('Out of step', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status in NERM', 'Identity in ISC', 'State in ISC', 'Problem'], function (r) { return [r.profile, r.type, r.nermStatus, r.iscPerson, r.iscState, pill(r.problem, 'lose')]; }, 'NERM and ISC out of step')));
246
- }
247
- function nmSessions(w, H, desc) {
248
- var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Waiting at least' }), numSelect(H, 'minDays', [[0, 'any time'], [3, '3 days'], [7, '7 days'], [30, '30 days']], 'Minimum age'));
249
- if (!nmBar(w, H, 'sessions', 'Find waiting sessions', desc, extras, function () { return { minDays: H.minDays }; })) return;
250
- var d = H.data;
251
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.sessions, 'sessions'), stat(d.totals.waiting, 'waiting', 'lose')));
252
- w.appendChild(section('By status', d.byStatus.length, simpleTable(['Status', 'Sessions'], d.byStatus.map(function (b) { return [b.status.replace(/_/g, ' '), fmtNum(b.sessions)]; }), 'Sessions by status')));
253
- if (d.waiting.length) w.appendChild(section('Waiting', d.waiting.length, filteredTable(H, d.waiting, ['Workflow', 'Status', 'Profile', 'Age'], function (r) { return [r.workflow, r.status.replace(/_/g, ' '), r.profile, r.age === undefined || r.age === null ? '—' : r.age + ' days']; }, 'Waiting workflow sessions')));
254
- }
255
- function nmRisk(w, H, desc) {
256
- if (!nmBar(w, H, 'risk', 'Read risk', desc)) return;
257
- var d = H.data, T = d.totals;
258
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.scored, 'profiles with a risk score'), stat(T.high, 'at the highest level'), stat(T.highActive, 'of them active', 'lose')));
259
- if (d.rows.length) w.appendChild(section('Highest risk', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status', 'Risk level', 'Score'], function (r) { return [r.profile, r.type, r.status, pill(r.level, 'lose'), r.score]; }, 'High-risk non-employees')));
260
- }
261
- function nmUsers(w, H, desc) {
262
- if (!nmBar(w, H, 'users', 'Check portal users', desc)) return;
263
- var d = H.data, T = d.totals;
264
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.users, 'NERM users'), stat(T.active, 'active'), stat(T.leftInIsc, 'active in NERM but left in ISC', 'lose'), stat(T.neverLoggedIn, 'active, never signed in')));
265
- if (d.rows.length) w.appendChild(section('Users who left', d.rows.length, filteredTable(H, d.rows, ['User', 'Email', 'Type', 'Last sign-in', 'State in ISC'], function (r) { return [r.user, r.email, r.type, r.lastLogin ? String(r.lastLogin).slice(0, 10) : 'never', pill(r.iscState, 'lose')]; }, 'NERM users who left')));
266
- }
1
+ // ---------- 0.23.0: drift, incidents, cleanup, and Non-employees (NERM) ----------
2
+ function owState() {
3
+ if (!state.wt) state.wt = {
4
+ massch: { days: 30, factor: 3, min: 50 }, loops: { days: 7, min: 5 }, outside: { days: 0, sourceIds: [] }, syncdrift: { sourceIds: [] },
5
+ groupappr: {}, mgrleft: { query: '' }, leavertimes: { days: 30, limitHours: 24 }, attrhist: { attributes: 'manager, department, title, cloudLifecycleState' },
6
+ owners: {}, rules: { cloudRules: false }
7
+ };
8
+ return state.wt;
9
+ }
10
+ function owRunBar(w, H, path, label, desc, extras, body, rerender) {
11
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: desc }), extras || null,
12
+ el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, path, body ? body() : {}, rerender); } }, icon('play'), H.data ? 'Read again' : label)));
13
+ if (H.busy) { w.appendChild(busyBox(H.busy)); return false; }
14
+ if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return false; }
15
+ if (!H.data) return false;
16
+ (H.data.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
17
+ return true;
18
+ }
19
+ /** Source picker (one or several), loaded once per page visit. */
20
+ function sourcePick(H, multiple, rerender, label) {
21
+ if (!H.sources) {
22
+ H.sources = 'loading';
23
+ api('/api/sources').then(function (r) { H.sources = (r.sources || []).slice().sort(function (a, b) { return String(a.name).localeCompare(String(b.name)); }); }, function () { H.sources = []; }).then(rerender);
24
+ }
25
+ var list = Array.isArray(H.sources) ? H.sources : [];
26
+ var pick = el('select', { className: 'input', multiple: multiple, size: multiple ? 4 : null, style: 'min-width:220px;width:auto', 'aria-label': label }, (multiple ? [] : [el('option', { value: '', text: list.length ? 'Pick a source' : 'Loading sources...' })]).concat(list.map(function (s) {
27
+ return el('option', { value: s.id, text: s.name, selected: H.sourceIds.indexOf(s.id) >= 0 });
28
+ })));
29
+ pick.addEventListener('change', function () { H.sourceIds = Array.prototype.filter.call(pick.options, function (o) { return o.selected && o.value; }).map(function (o) { return o.value; }); });
30
+ return el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: label + (multiple ? ' (Ctrl+click for more)' : '') }), pick);
31
+ }
32
+ function hrs(h) { return h === null || h === undefined ? '—' : h < 48 ? h + ' h' : Math.round(h / 24 * 10) / 10 + ' days'; }
33
+ function when16(s) { return s ? String(s).slice(0, 16).replace('T', ' ') : ''; }
34
+ function warnRerender() { if (state.page === 'warnings') renderWarnings(); }
35
+
36
+ // Warnings > Mass changes
37
+ function wnMassChange(w, _H, desc) {
38
+ var H = owState().massch;
39
+ var extras = el('div', { className: 'bar' },
40
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Usual level from the last' }), numSelect(H, 'days', [[14, '14 days'], [30, '30 days'], [60, '60 days']], 'Baseline period')),
41
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Spike at' }), numSelect(H, 'factor', [[2, '2× usual'], [3, '3× usual'], [5, '5× usual'], [10, '10× usual']], 'Spike factor')),
42
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'and at least' }), numSelect(H, 'min', [[20, '20 changes'], [50, '50 changes'], [200, '200 changes'], [1000, '1,000 changes']], 'Minimum changes')));
43
+ if (!owRunBar(w, H, '/api/watch/mass-change/run', 'Check for spikes', desc, extras, function () { return { days: H.days, factor: H.factor, min: H.min }; }, renderWarnings)) return;
44
+ var d = H.data;
45
+ w.appendChild(el('div', { className: 'bigstats' }, d.series.map(function (x) {
46
+ return el('div', { className: 'bigstat' + (x.spike ? ' lose' : '') }, el('b', { text: fmtNum(x.latest) }), el('span', { text: x.label + ' on ' + x.latestDay + ' (usual ' + fmtNum(Math.round(x.usual)) + ')' + (x.spike ? ': spike' : '') }));
47
+ })));
48
+ d.series.filter(function (x) { return x.spike; }).forEach(function (x) {
49
+ w.appendChild(section('Spike: ' + x.label.toLowerCase() + ' on ' + x.latestDay, x.latest, simpleTable(['Source', 'Changes'], x.bySource.map(function (s) { return [s.source, fmtNum(s.count)]; }), 'Spike by source: ' + x.label)));
50
+ });
51
+ var all = d.series[0];
52
+ var maxv = Math.max.apply(null, all.daily.map(function (p) { return p.count; }).concat([1]));
53
+ var bars = el('div', { style: 'display:flex;align-items:flex-end;gap:2px;height:90px;margin:8px 0', role: 'img', 'aria-label': 'Provisioning per day: ' + all.daily.map(function (p) { return p.day + ' ' + p.count; }).join(', ') }, all.daily.map(function (p) {
54
+ return el('div', { title: p.day + ': ' + p.count, style: 'flex:1;min-width:3px;background:' + (p.day === all.latestDay && all.spike ? 'var(--danger)' : 'var(--accent)') + ';height:' + Math.max(2, Math.round(p.count / maxv * 88)) + 'px;border-radius:2px 2px 0 0' });
55
+ }));
56
+ w.appendChild(section('All provisioning per day', null, el('div', {}, bars, el('div', { className: 'bar', style: 'justify-content:flex-end' }, downloads(H.job)))));
57
+ }
58
+
59
+ // Warnings > Provisioning loops
60
+ function wnLoops(w, _H, desc) {
61
+ var H = owState().loops;
62
+ var extras = el('div', { className: 'bar' },
63
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'In the last' }), numSelect(H, 'days', [[3, '3 days'], [7, '7 days'], [14, '14 days'], [30, '30 days']], 'Period')),
64
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Sent at least' }), numSelect(H, 'min', [[3, '3 times'], [5, '5 times'], [10, '10 times'], [20, '20 times']], 'Minimum repeats')));
65
+ if (!owRunBar(w, H, '/api/watch/loops/run', 'Find loops', desc, extras, function () { return { days: H.days, min: H.min }; }, renderWarnings)) return;
66
+ var d = H.data;
67
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.read, 'activities read'), stat(d.rows.length + (d.more || 0), 'changes sent again and again', 'lose')));
68
+ if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'No change was sent that often.' })); return; }
69
+ w.appendChild(section('Loops', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Source', 'Operation', 'Change', 'Times', 'First', 'Last', 'Last result'], function (r) {
70
+ return [r.person, r.source, r.op, el('span', { className: 'small', text: r.change }), pill(String(r.times), 'lose'), when16(r.first), when16(r.last), r.lastStatus];
71
+ }, 'Provisioning loops')));
72
+ }
73
+
74
+ // Warnings > Changed outside ISC
75
+ function wnOutside(w, _H, desc) {
76
+ var H = owState().outside;
77
+ var extras = el('div', { className: 'bar' }, sourcePick(H, true, warnRerender, 'Sources'),
78
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Compare with what ISC sent in' }), numSelect(H, 'days', [[0, 'All history'], [30, 'the last 30 days'], [90, 'the last 90 days'], [180, 'the last 180 days'], [365, 'the last 365 days']], 'Period')));
79
+ if (!owRunBar(w, H, '/api/watch/outside/run', 'Find changes made outside ISC', desc, extras, function () { return { days: H.days, sourceIds: H.sourceIds }; }, renderWarnings)) return;
80
+ var d = H.data, T = d.totals;
81
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.accounts, 'accounts read'), stat(T.disabledOutside, 'disabled outside ISC', 'lose'), stat(T.enabledOutside, 'enabled again outside ISC', 'lose')));
82
+ if (!d.rows.length) { w.appendChild(el('p', { className: 'muted', text: 'Every account state matches what ISC sent.' })); return; }
83
+ w.appendChild(section('Accounts', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Person state', 'Account', 'Source', 'Finding', 'Last disable or enable ISC sent'], function (r) { return [r.person, r.personState, r.account, r.source, r.finding, r.lastIsc]; }, 'Changes made outside ISC')));
84
+ }
85
+
86
+ // Warnings > Attribute sync drift
87
+ function wnSyncDrift(w, _H, desc) {
88
+ var H = owState().syncdrift;
89
+ var extras = el('div', { className: 'bar' }, sourcePick(H, false, warnRerender, 'Source'));
90
+ if (!owRunBar(w, H, '/api/watch/sync-drift/run', 'Compare values', desc, extras, function () { return { sourceIds: H.sourceIds.slice(0, 1) }; }, renderWarnings)) return;
91
+ var d = H.data, T = d.totals;
92
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.mappings.length, 'attributes synced'), stat(T.accounts, 'accounts'), stat(T.compared, 'values compared'), stat(T.drifted, 'values that differ', 'lose'), stat(T.failedSyncs, 'failed syncs (14 days)', 'lose')));
93
+ if (d.mappings.length) w.appendChild(el('p', { className: 'muted small', text: 'Synced: ' + d.mappings.map(function (m) { return m.identityAttribute + ' → ' + m.accountAttribute; }).join(', ') }));
94
+ if (d.rows.length) w.appendChild(section('Values that differ', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Account', 'Attribute', 'Value in ISC', 'Value on the account'], function (r) { return [r.person, r.account, r.identityAttribute + ' → ' + r.accountAttribute, r.inIsc, r.onAccount]; }, 'Attribute sync drift')));
95
+ else if (d.mappings.length) w.appendChild(el('p', { className: 'muted', text: 'Every synced value matches.' }));
96
+ if (d.failedSyncs.length) w.appendChild(section('Failed attribute syncs', d.failedSyncs.length, simpleTable(['When', 'Person', 'Detail'], d.failedSyncs.slice(0, 500).map(function (f) { return [when16(f.when), f.person, f.detail]; }), 'Failed attribute syncs')));
97
+ }
98
+
99
+ // Warnings > Group approvals
100
+ function wnGroupApprovals(w, _H, desc) {
101
+ var H = owState().groupappr;
102
+ if (!owRunBar(w, H, '/api/watch/group-approvals/run', 'Check group approvers', desc, null, null, renderWarnings)) return;
103
+ var d = H.data, T = d.totals;
104
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.pending, 'approvals waiting on a group'), stat(T.groups, 'groups'), stat(T.noActiveMember, 'with no active member left', 'lose')));
105
+ if (!d.rows.length) return;
106
+ w.appendChild(section('Approvals', d.rows.length, filteredTable(H, d.rows, ['Group', 'Access', 'Requested for', 'Waiting', 'Members', 'Members who left'], function (r) {
107
+ return [r.group, r.request, r.requestedFor, r.waitingDays === null ? '—' : r.waitingDays + ' days', el('span', {}, r.activeMembers + ' of ' + r.members + ' active ', r.activeMembers === 0 ? pill('nobody can approve', 'lose') : null), r.leftMembers.join(', ')];
108
+ }, 'Approvals waiting on governance groups')));
109
+ }
110
+
111
+ // Warnings > Manager left
112
+ function wnManagerLeft(w, _H, desc) {
113
+ var H = owState().mgrleft;
114
+ var q = el('input', { className: 'input', value: H.query || '', placeholder: 'e.g. attributes.employeeType:contractor', style: 'max-width:300px', 'aria-label': 'Only people matching (search query, optional)' });
115
+ q.addEventListener('input', function () { H.query = q.value; });
116
+ var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Only people matching (optional)' }), q);
117
+ if (!owRunBar(w, H, '/api/watch/manager-left/run', 'Find people', desc, extras, function () { return { query: H.query || undefined }; }, renderWarnings)) return;
118
+ var d = H.data;
119
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.people, 'active people'), stat(d.totals.managerLeft, 'whose manager left', 'lose')));
120
+ if (!d.rows.length) return;
121
+ w.appendChild(section('People', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Identity profile', 'Manager', 'Manager state'], function (r) { return [r.person, r.lifecycle, r.profile, r.manager, pill(r.managerState, 'lose')]; }, 'People whose manager left')));
122
+ }
123
+
124
+ // Audit > Leaver removal times
125
+ function renderLeaverTimes(w) {
126
+ var H = owState().leavertimes;
127
+ var extras = el('div', { className: 'bar' },
128
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Leavers of the last' }), numSelect(H, 'days', [[7, '7 days'], [30, '30 days'], [90, '90 days']], 'Period')),
129
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Limit' }), numSelect(H, 'limitHours', [[4, '4 hours'], [24, '24 hours'], [48, '48 hours'], [72, '72 hours'], [168, '7 days']], 'Removal limit')));
130
+ if (!owRunBar(w, H, '/api/watch/leaver-times/run', 'Time the leavers', 'For each leaver: when leaving started (lifecycle change), when each account was disabled, and which accounts are still enabled. The per-person figure auditors ask for.', extras, function () { return { days: H.days, limitHours: H.limitHours }; }, renderAudit)) return;
131
+ var d = H.data, T = d.totals;
132
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.leavers, 'leavers'), stat(T.late, 'over ' + d.limitHours + ' h or not done', 'lose'), stat(T.stillEnabled, 'with an account still enabled', 'lose'), el('div', { className: 'bigstat' }, el('b', { text: hrs(T.medianHours) }), el('span', { text: 'median removal time' }))));
133
+ if (!d.rows.length) return;
134
+ w.appendChild(section('Leavers', d.rows.length, filteredTable(H, d.rows, ['Person', 'Lifecycle state', 'Started', 'Accounts', 'Slowest removal', 'Still enabled on', 'Result'], function (r) {
135
+ return [r.person, r.lifecycle, el('span', {}, when16(r.started) || '—', el('div', { className: 'small muted', text: r.startedBy })), r.accounts, hrs(r.slowestHours), r.stillEnabled.join(', '), pill(r.late ? 'late' : 'on time', r.late ? 'lose' : 'win')];
136
+ }, 'Leaver removal times')));
137
+ }
138
+
139
+ // Audit > Attribute changes
140
+ function renderAttrHistory(w) {
141
+ var H = owState().attrhist;
142
+ var i = el('input', { className: 'input', value: H.attributes, style: 'max-width:380px', 'aria-label': 'Attributes to follow (comma-separated)' });
143
+ i.addEventListener('input', function () { H.attributes = i.value; });
144
+ var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Attributes to follow (comma-separated)' }), i);
145
+ if (!owRunBar(w, H, '/api/watch/attr-history/run', 'Look now', 'Who changed manager, department, title or lifecycle state, from what to what. IdentityScope remembers the values at each look and lists the changes between looks.', extras,
146
+ function () { return { attributes: H.attributes.split(',').map(function (x) { return x.trim(); }).filter(Boolean) }; }, renderAudit)) return;
147
+ var d = H.data;
148
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.people, 'people looked at'), stat(d.newChanges, 'changes since the last look'), stat(d.changes.length + (d.more || 0), 'changes on record')));
149
+ if (d.previousLook) w.appendChild(el('p', { className: 'muted small', text: 'Previous look: ' + when16(d.previousLook) }));
150
+ if (!d.changes.length) return;
151
+ w.appendChild(section('Changes', d.changes.length + (d.more || 0), filteredTable(H, d.changes, ['Seen at', 'Person', 'Attribute', 'From', 'To'], function (r) { return [when16(r.at), r.person, r.attribute, r.from || '(empty)', r.to || '(empty)']; }, 'Attribute changes')));
152
+ }
153
+
154
+ // Audit > Entitlement owners
155
+ function renderOwners(w) {
156
+ var H = owState().owners;
157
+ if (!owRunBar(w, H, '/api/watch/owners/run', 'Read owners', 'Every entitlement owner with what they own and how many people hold each item, so each owner can review their own access. Owners who left are listed first.', null, null, renderAudit)) return;
158
+ var d = H.data;
159
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.owners.length, 'owners'), stat(d.owners.filter(function (o) { return o.ownerState !== 'active'; }).length, 'owners who left or are not found', 'lose'), stat(d.rows.length + (d.more || 0), 'owned entitlements')));
160
+ w.appendChild(section('Owners', d.owners.length, simpleTable(['Owner', 'State', 'Entitlements', 'Holders'], d.owners.map(function (o) {
161
+ return [o.owner, o.ownerState === 'active' ? 'active' : pill(o.ownerState, 'lose'), fmtNum(o.entitlements), fmtNum(o.holders)];
162
+ }), 'Entitlement owners')));
163
+ w.appendChild(section('Entitlements', d.rows.length + (d.more || 0), filteredTable(H, d.rows, ['Owner', 'Entitlement', 'Source', 'Privileged', 'Holders'], function (r) { return [r.owner, r.entitlement, r.source, r.privileged ? 'Yes' : '', r.holders === null ? '—' : fmtNum(r.holders)]; }, 'Entitlements by owner')));
164
+ }
165
+
166
+ // Tenant > Rule usage
167
+ function renderRuleUsage(w) {
168
+ var H = owState().rules;
169
+ var cb = el('input', { type: 'checkbox', checked: H.cloudRules });
170
+ cb.addEventListener('change', function () { H.cloudRules = cb.checked; });
171
+ var extras = el('label', { className: 'check', title: 'Starts an SP-Config export job in the tenant (it reads only, but the job shows in ISC).' }, cb, 'Also list cloud rules (SP-Config export)');
172
+ if (!owRunBar(w, H, '/api/watch/rules/run', 'Find where rules are used', 'Every connector rule and cloud rule with the sources, policies, transforms and identity attributes that use it. Unused rules are cleanup candidates; rules used but missing break at run time.', extras,
173
+ function () { return { cloudRules: H.cloudRules }; }, renderTenant)) return;
174
+ var d = H.data, T = d.totals;
175
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.rules, 'rules'), stat(T.unused, 'not used anywhere', 'lose'), stat(T.missing, 'used but missing', 'lose')));
176
+ w.appendChild(section('Rules', d.rows.length, filteredTable(H, d.rows, ['Rule', 'Kind', 'Used by', 'Finding'], function (r) {
177
+ return [r.rule, r.kind, r.usedBy.length ? el('div', {}, r.usedBy.map(function (u) { return el('div', { className: 'small', text: u }); })) : '', r.finding ? pill(r.finding, 'lose') : ''];
178
+ }, 'Rule usage')));
179
+ }
180
+
181
+ // ---------- Non-employees (NERM) page ----------
182
+ function nmState() {
183
+ if (!state.nm) state.nm = { tab: 'overview', settings: null, overview: { days: 30, endAttribute: '' }, sync: {}, sessions: { minDays: 0 }, risk: {}, users: {} };
184
+ return state.nm;
185
+ }
186
+ var NM_TABS = [
187
+ ['overview', 'End dates and sponsors', 'clock', 'Active non-employees past their end date or ending soon, and non-employees without a sponsor or whose sponsor has left.'],
188
+ ['sync', 'NERM vs ISC', 'cols', 'Profiles whose status in NERM does not match their identity in ISC: terminated in NERM but still active in ISC, and the reverse.'],
189
+ ['sessions', 'Waiting workflows', 'lifecycle', 'NERM workflow sessions still waiting for an approval, review, fulfilment or another step.'],
190
+ ['risk', 'High risk', 'shield', 'Non-employees with the highest NERM risk level, active ones first.'],
191
+ ['users', 'Portal users who left', 'people', 'Sponsors, managers and admins who can still sign in to NERM although their identity in ISC has left.']
192
+ ];
193
+ function renderNerm() {
194
+ var N = nmState();
195
+ var outer = $('nerm');
196
+ outer.textContent = '';
197
+ var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
198
+ outer.appendChild(w);
199
+ w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#0f766e;background:#ccfbf1' }, icon('people')),
200
+ el('div', {}, el('h2', { text: 'Non-employees' }), el('p', { className: 'desc', text: 'Contractors, vendors and other non-employees in Non-Employee Risk Management (NERM), checked against ISC. Read-only: GET requests on seven NERM read endpoints only.' }))));
201
+ if (!N.settings) {
202
+ N.settings = 'loading';
203
+ api('/api/nerm/settings').then(function (s) { N.settings = s; }, function () { N.settings = {}; }).then(function () { if (state.page === 'nerm') renderNerm(); });
204
+ }
205
+ var S = N.settings && N.settings !== 'loading' ? N.settings : {};
206
+ var addr = el('input', { className: 'input', value: N.addrDraft !== undefined ? N.addrDraft : (S.address || ''), placeholder: 'acme or https://acme.nonemployee.com', style: 'max-width:320px', 'aria-label': 'NERM address' });
207
+ addr.addEventListener('input', function () { N.addrDraft = addr.value; });
208
+ w.appendChild(el('div', { className: 'card', style: 'padding:12px 16px' }, el('div', { className: 'bar' },
209
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'NERM address' }), addr),
210
+ el('button', { className: 'btn', onclick: function () {
211
+ api('/api/nerm/settings', 'PUT', { address: addr.value }).then(function (s) { N.settings = s; N.addrDraft = undefined; toast(s.address ? 'Saved' : 'Cleared'); renderNerm(); }, function (e) { toast(errorText(e)); });
212
+ } }, 'Save'),
213
+ el('span', { className: 'muted small', style: 'flex:1;min-width:260px', text: S.base ? 'Reads ' + S.base + ' with the same sign-in as ISC. The API client or token needs a NERM scope (nerm:api:read-only is enough).' : 'Uses the same sign-in as ISC: no second secret. The API client or token needs a NERM scope (nerm:api:read-only is enough).' }))));
214
+ var tabs = el('div', { className: 'tabs', style: 'flex-wrap:wrap' });
215
+ NM_TABS.forEach(function (t) { tabs.appendChild(el('button', { className: 'tab' + (N.tab === t[0] ? ' active' : ''), onclick: function () { N.tab = t[0]; renderNerm(); } }, icon(t[2]), t[1])); });
216
+ w.appendChild(tabs);
217
+ var spec = NM_TABS.filter(function (t) { return t[0] === N.tab; })[0];
218
+ ({ overview: nmOverview, sync: nmSync, sessions: nmSessions, risk: nmRisk, users: nmUsers })[N.tab](w, N[N.tab], spec[3]);
219
+ }
220
+ function nmBar(w, H, kind, label, desc, extras, body) { return owRunBar(w, H, '/api/nerm/' + kind + '/run', label, desc, extras, body, renderNerm); }
221
+ function nmProfileTable(H, rows, label, withEnd) {
222
+ return filteredTable(H, rows, withEnd ? ['Profile', 'Type', 'End date', 'When', 'Sponsor'] : ['Profile', 'Type', 'Sponsor', 'Problem'], function (r) {
223
+ return withEnd ? [r.name, r.type, r.endDate, pill(daysText(r.daysLeft), r.daysLeft < 0 || r.daysLeft <= 7 ? 'lose' : 'off'), r.sponsors] : [r.name, r.type, r.sponsors || '—', pill(r.sponsorProblem, 'lose')];
224
+ }, label);
225
+ }
226
+ function nmOverview(w, H, desc) {
227
+ var extras = el('div', { className: 'bar' },
228
+ el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Ending within' }), numSelect(H, 'days', [[7, '7 days'], [14, '14 days'], [30, '30 days'], [60, '60 days'], [90, '90 days']], 'Ending within')),
229
+ attrInput(H, 'endAttribute', 'End-date attribute (optional)', 'found automatically'));
230
+ if (!nmBar(w, H, 'overview', 'Check non-employees', desc, extras, function () { return { days: H.days, endAttribute: H.endAttribute || undefined }; })) return;
231
+ var d = H.data, T = d.totals;
232
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.profiles, 'profiles'), stat(T.active, 'active'), stat(T.pastEnd, 'active past their end date', 'lose'), stat(T.ending, 'ending in ' + H.days + ' days'), stat(T.noSponsor, 'without a sponsor', 'lose'), stat(T.sponsorLeft, 'whose sponsor left', 'lose')));
233
+ if (d.endAttribute || d.sponsorAttributes.length) w.appendChild(el('p', { className: 'muted small', text: [d.endAttribute ? 'End date from: ' + d.endAttribute : '', d.sponsorAttributes.length ? 'Sponsor from: ' + d.sponsorAttributes.join(', ') : ''].filter(Boolean).join(' · ') }));
234
+ w.appendChild(section('By profile type', d.byType.length, simpleTable(['Profile type', 'Category', 'Active', 'On leave', 'Inactive', 'Terminated'], d.byType.map(function (b) { return [b.type, b.category, fmtNum(b.active), fmtNum(b.onLeave), fmtNum(b.inactive), fmtNum(b.terminated)]; }), 'Profiles by type')));
235
+ if (d.pastEnd.length) w.appendChild(section('Active past their end date', d.pastEnd.length, nmProfileTable(H.past || (H.past = { data: d, job: H.job }), d.pastEnd, 'Active past end date', true)));
236
+ if (d.ending.length) w.appendChild(section('Ending soon', d.ending.length, nmProfileTable(H.soon || (H.soon = { data: d, job: H.job }), d.ending, 'Ending soon', true)));
237
+ if (d.sponsorIssues.length) w.appendChild(section('Sponsor problems', d.sponsorIssues.length, nmProfileTable(H.sp || (H.sp = { data: d, job: H.job }), d.sponsorIssues, 'Sponsor problems', false)));
238
+ }
239
+ function nmSync(w, H, desc) {
240
+ if (!nmBar(w, H, 'sync', 'Compare with ISC', desc)) return;
241
+ var d = H.data, T = d.totals;
242
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.synced, 'profiles of synced types'), stat(T.checked, 'matched to an identity'), stat(T.leftInNermActiveInIsc, 'left in NERM, active in ISC', 'lose'), stat(T.activeInNermLeftInIsc, 'active in NERM, inactive in ISC', 'lose'), stat(T.notInIsc, 'active but not in ISC', 'lose')));
243
+ if (d.sources.length) w.appendChild(el('p', { className: 'muted small', text: 'Matched through the ISC source' + (d.sources.length > 1 ? 's ' : ' ') + d.sources.join(', ') + '.' }));
244
+ if (!d.rows.length) return;
245
+ w.appendChild(section('Out of step', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status in NERM', 'Identity in ISC', 'State in ISC', 'Problem'], function (r) { return [r.profile, r.type, r.nermStatus, r.iscPerson, r.iscState, pill(r.problem, 'lose')]; }, 'NERM and ISC out of step')));
246
+ }
247
+ function nmSessions(w, H, desc) {
248
+ var extras = el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'Waiting at least' }), numSelect(H, 'minDays', [[0, 'any time'], [3, '3 days'], [7, '7 days'], [30, '30 days']], 'Minimum age'));
249
+ if (!nmBar(w, H, 'sessions', 'Find waiting sessions', desc, extras, function () { return { minDays: H.minDays }; })) return;
250
+ var d = H.data;
251
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.totals.sessions, 'sessions'), stat(d.totals.waiting, 'waiting', 'lose')));
252
+ w.appendChild(section('By status', d.byStatus.length, simpleTable(['Status', 'Sessions'], d.byStatus.map(function (b) { return [b.status.replace(/_/g, ' '), fmtNum(b.sessions)]; }), 'Sessions by status')));
253
+ if (d.waiting.length) w.appendChild(section('Waiting', d.waiting.length, filteredTable(H, d.waiting, ['Workflow', 'Status', 'Profile', 'Age'], function (r) { return [r.workflow, r.status.replace(/_/g, ' '), r.profile, r.age === undefined || r.age === null ? '—' : r.age + ' days']; }, 'Waiting workflow sessions')));
254
+ }
255
+ function nmRisk(w, H, desc) {
256
+ if (!nmBar(w, H, 'risk', 'Read risk', desc)) return;
257
+ var d = H.data, T = d.totals;
258
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.scored, 'profiles with a risk score'), stat(T.high, 'at the highest level'), stat(T.highActive, 'of them active', 'lose')));
259
+ if (d.rows.length) w.appendChild(section('Highest risk', d.rows.length, filteredTable(H, d.rows, ['Profile', 'Type', 'Status', 'Risk level', 'Score'], function (r) { return [r.profile, r.type, r.status, pill(r.level, 'lose'), r.score]; }, 'High-risk non-employees')));
260
+ }
261
+ function nmUsers(w, H, desc) {
262
+ if (!nmBar(w, H, 'users', 'Check portal users', desc)) return;
263
+ var d = H.data, T = d.totals;
264
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.users, 'NERM users'), stat(T.active, 'active'), stat(T.leftInIsc, 'active in NERM but left in ISC', 'lose'), stat(T.neverLoggedIn, 'active, never signed in')));
265
+ if (d.rows.length) w.appendChild(section('Users who left', d.rows.length, filteredTable(H, d.rows, ['User', 'Email', 'Type', 'Last sign-in', 'State in ISC'], function (r) { return [r.user, r.email, r.type, r.lastLogin ? String(r.lastLogin).slice(0, 10) : 'never', pill(r.iscState, 'lose')]; }, 'NERM users who left')));
266
+ }