ownerlens 0.1.7 → 0.1.9-preview.0

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 (77) hide show
  1. package/README.md +27 -99
  2. package/bin/ownerlens.js +6 -6
  3. package/contracts/entra/snapshot.v0.4.schema.json +4 -1
  4. package/dist/assets/index-CpgQimUK.js +12 -0
  5. package/dist/assets/index-CzOsq9Ac.css +1 -0
  6. package/dist/index.html +2 -2
  7. package/package.json +2 -1
  8. package/powershell/OwnerLens/OwnerLens.psd1 +30 -0
  9. package/powershell/OwnerLens/OwnerLens.psm1 +23 -0
  10. package/{tools/utils.ps1 → powershell/OwnerLens/Private/ConvertTo-EntraSnapshotObjects.ps1} +8 -0
  11. package/{tools/azure-activity-check.ps1 → powershell/OwnerLens/Private/Get-AzureMonitorActivityLogs.ps1} +8 -0
  12. package/powershell/OwnerLens/Private/Get-OwnerLensFreePort.ps1 +20 -0
  13. package/powershell/OwnerLens/Private/Get-OwnerLensPaths.ps1 +22 -0
  14. package/powershell/OwnerLens/Private/Get-OwnerLensRuntime.ps1 +62 -0
  15. package/{tools/prepare-entra-snapshot.ps1 → powershell/OwnerLens/Private/Invoke-OwnerLensPrepareEntraSnapshot.ps1} +12 -9
  16. package/{tools/prepare-resource-snapshot.ps1 → powershell/OwnerLens/Private/Invoke-OwnerLensPrepareResourceSnapshot.ps1} +13 -4
  17. package/powershell/OwnerLens/Private/New-OwnerLensRuntimeToken.ps1 +16 -0
  18. package/powershell/OwnerLens/Private/New-OwnerLensStatusObject.ps1 +26 -0
  19. package/powershell/OwnerLens/Private/Read-OwnerLensState.ps1 +23 -0
  20. package/powershell/OwnerLens/Private/Remove-OwnerLensState.ps1 +17 -0
  21. package/powershell/OwnerLens/Private/Test-OwnerLensTrackedProcess.ps1 +39 -0
  22. package/powershell/OwnerLens/Private/Wait-OwnerLensServer.ps1 +35 -0
  23. package/powershell/OwnerLens/Private/Write-OwnerLensState.ps1 +19 -0
  24. package/powershell/OwnerLens/Public/Get-OwnerLensStatus.ps1 +31 -0
  25. package/powershell/OwnerLens/Public/Install-OwnerLensRuntime.ps1 +41 -0
  26. package/powershell/OwnerLens/Public/Invoke-OwnerLensCollectAzure.ps1 +132 -0
  27. package/powershell/OwnerLens/Public/Invoke-OwnerLensCollectEntra.ps1 +127 -0
  28. package/powershell/OwnerLens/Public/Open-OwnerLens.ps1 +35 -0
  29. package/powershell/OwnerLens/Public/Start-OwnerLens.ps1 +82 -0
  30. package/powershell/OwnerLens/Public/Stop-OwnerLens.ps1 +37 -0
  31. package/powershell/OwnerLens/README.md +52 -0
  32. package/src/components/azure/AzureComponent.test.tsx +286 -0
  33. package/src/components/azure/AzureComponent.tsx +5 -5
  34. package/src/components/azure/EntraUserGroupsDropdown.tsx +153 -0
  35. package/src/components/azure/ManagedIdentityComponent.test.tsx +28 -2
  36. package/src/components/azure/ManagedIdentityComponent.tsx +6 -3
  37. package/src/components/azure/OwnershipEvidenceComponent.tsx +65 -158
  38. package/src/components/azure/ResourceGroupComponent.tsx +6 -3
  39. package/src/components/azure/ServicePrincipalComponent.test.tsx +27 -4
  40. package/src/components/azure/ServicePrincipalComponent.tsx +5 -2
  41. package/src/components/azure/ServicePrincipalFieldRenderers.tsx +5 -1
  42. package/src/components/azure/TagBadges.test.tsx +19 -0
  43. package/src/components/azure/TagBadges.tsx +56 -0
  44. package/src/components/azure/api.ts +75 -13
  45. package/src/components/azure/ownershipEvidenceFields.ts +92 -0
  46. package/src/components/azure/ownershipEvidenceFormatters.ts +64 -0
  47. package/src/core/azure/entra/managedIdentity.ts +1 -0
  48. package/src/core/azure/entra/types.ts +9 -1
  49. package/src/core/azure/resources.ts +5 -6
  50. package/src/core/azure/tags.ts +22 -0
  51. package/src/core/runtime/rest.ts +30 -0
  52. package/src/core/runtime/snapshotContractValidator.test.ts +12 -0
  53. package/src/providers/azure/inputTransferObject/generated/EntraSnapshot.ts +1 -1
  54. package/src/providers/azure/ownership/principalOwnerProjection.test.ts +58 -1
  55. package/src/providers/azure/ownership/principalOwnerProjection.ts +92 -3
  56. package/src/providers/azure/ownership/resolveAzureOwner.ts +3 -2
  57. package/src/providers/azure/runtime/LocalReportRuntime.duckdb.test.ts +100 -0
  58. package/src/providers/azure/runtime/LocalReportRuntime.test.ts +113 -0
  59. package/src/providers/azure/runtime/LocalReportRuntime.ts +6 -0
  60. package/src/providers/azure/runtime/entra/EntraCollectionQueryService.ts +6 -1
  61. package/src/providers/azure/runtime/entra/LocalEntraReportRuntime.ts +11 -1
  62. package/src/providers/azure/runtime/entra/entraServicePrincipalMapper.ts +2 -1
  63. package/src/providers/azure/runtime/entra/groupMembersTable.ts +32 -2
  64. package/src/providers/azure/runtime/entra/localReportRuntimeRest.ts +4 -0
  65. package/src/providers/azure/runtime/localReportRuntimeRest.ts +1 -0
  66. package/src/providers/azure/runtime/ownership/OwnershipEvidenceQueryService.test.ts +76 -3
  67. package/src/providers/azure/runtime/resources/AzureResourcesCollectionQueryService.ts +2 -1
  68. package/src/providers/azure/runtime/resources/resourceGroupOwnership.test.ts +1 -1
  69. package/src/{components/azure/ClosableAzureTab.tsx → report/components/ClosableTab.tsx} +4 -4
  70. package/tools/README.md +25 -35
  71. package/dist/assets/index-BGYxOSO4.css +0 -1
  72. package/dist/assets/index-D7COTwVU.js +0 -11
  73. package/tools/collect-azure.ps1 +0 -54
  74. package/tools/collect-entra.ps1 +0 -52
  75. package/tools/collect-scripts.test.ts +0 -33
  76. package/tools/prepare-entra-snapshot.Tests.ps1 +0 -125
  77. package/tools/prepare-entra-snapshot.test.ts +0 -51
package/README.md CHANGED
@@ -48,8 +48,6 @@ flowchart TD
48
48
 
49
49
  ## Requirements
50
50
 
51
- - Node.js 20 or newer
52
- - npm
53
51
  - PowerShell 7 or Windows PowerShell for snapshot export scripts
54
52
  - Azure PowerShell and Microsoft Graph PowerShell modules when exporting data
55
53
 
@@ -84,121 +82,51 @@ Sign in to Microsoft Graph:
84
82
  Connect-MgGraph -TenantId "<tenant-id>" -Scopes "Application.Read.All","Group.Read.All","Directory.Read.All"
85
83
  ```
86
84
 
87
- Create the resource snapshot:
88
-
89
- ```bash
90
- npx ownerlens collect:azure -SubscriptionIds "sub-id-1,sub-id-2"
91
- ```
92
-
93
- Create the Entra snapshot:
94
-
95
- ```bash
96
- npx ownerlens collect:entra -TenantId "<tenant-id>"
97
- ```
98
-
99
- More script options are documented in [tools/README.md](tools/README.md).
100
-
101
- Snapshot files can contain tenant, subscription, resource, identity, group, and
102
- activity-log metadata. Review them before sharing. Files matching
103
- `data/*snapshot.json` are ignored by git.
104
-
105
- ## Local Development
106
-
107
- Clone the repository, install dependencies, then run the development server:
108
-
109
- ```bash
110
- npm install
111
- npm run dev
112
- ```
113
-
114
- Open the Vite URL printed by the command, usually `http://127.0.0.1:5173`.
115
-
116
- You can also exercise the published CLI entrypoint from a repository checkout:
117
-
118
- ```bash
119
- npm run start
120
- npm run preview
121
- npm run collect:azure -- -SubscriptionIds "sub-id-1,sub-id-2"
122
- npm run collect:entra -- -TenantId "<tenant-id>"
123
- ```
124
-
125
- For a production build:
85
+ Import the PowerShell module:
126
86
 
127
- ```bash
128
- npm run build
129
- ```
130
-
131
- ## Configure Ownership Rules
132
-
133
- Edit [src/core/config.ts](src/core/config.ts) to change ownership resolution defaults.
134
-
135
- `ownerTags` is ordered by priority. The tag value is treated as the owner
136
- identity and can be a group name, security group alias, or user email.
137
-
138
- ```ts
139
- export const appConfig = {
140
- azure: {
141
- ownership: {
142
- ownerTags: [
143
- { name: "ownerGroup", confidence: "high" },
144
- { name: "costCenter", confidence: "high" },
145
- { name: "owner", confidence: "medium" }
146
- ]
147
- }
148
- }
149
- };
150
- ```
151
-
152
- ## Test
153
-
154
- ```bash
155
- npm test
87
+ ```powershell
88
+ Import-Module ./artifacts/OwnerLens/OwnerLens.psd1 -Force
156
89
  ```
157
90
 
158
- Run only component tests:
91
+ Start OwnerLens from PowerShell on Windows:
159
92
 
160
- ```bash
161
- npm run test:components
93
+ ```powershell
94
+ Start-OwnerLens
95
+ Open-OwnerLens
96
+ Get-OwnerLensStatus
97
+ Stop-OwnerLens
162
98
  ```
163
99
 
164
- Track component-test coverage:
100
+ `Start-OwnerLens` starts the local app on `127.0.0.1` using a free port and
101
+ stores runtime state under `$env:LOCALAPPDATA\OwnerLens`. To use a specific data
102
+ directory or port, pass them explicitly:
165
103
 
166
- ```bash
167
- npm run test:components:coverage
104
+ ```powershell
105
+ Start-OwnerLens -DataPath C:\OwnerLensData -Port 4174
168
106
  ```
169
107
 
170
- The component coverage report is written to `coverage/components`. Jest also
171
- enforces the current component coverage baseline so new UI changes do not
172
- silently reduce coverage.
173
-
174
- ## Dependency Graph
175
-
176
- Generate a folder-level dependency graph:
108
+ Create the resource snapshot:
177
109
 
178
- ```bash
179
- npm run deps:graph
110
+ ```powershell
111
+ Invoke-OwnerLensCollectAzure -SubscriptionIds "sub-id-1,sub-id-2"
180
112
  ```
181
113
 
182
- The generated SVG is written to `output/dependency-folders.svg`.
183
-
184
- Generate a file-level dependency graph:
114
+ Create the Entra snapshot:
185
115
 
186
- ```bash
187
- npm run deps:graph:files
116
+ ```powershell
117
+ Invoke-OwnerLensCollectEntra -TenantId "<tenant-id>"
188
118
  ```
189
119
 
190
- The generated SVG is written to `output/dependency-files.svg`.
120
+ More collector options are documented in [tools/README.md](tools/README.md).
191
121
 
192
- ## Project Structure
122
+ Snapshot files can contain tenant, subscription, resource, identity, group, and
123
+ activity-log metadata. Review them before sharing. Files matching
124
+ `data/*snapshot.json` are ignored by git.
193
125
 
194
- - `src/App.tsx` loads snapshot files and renders the report.
195
- - `src/core/config.ts` contains ownership resolution configuration.
196
- - `src/report` contains report UI, filtering, view helpers, and tests.
197
- - `src/providers/azure` contains Azure and Entra domain models and ownership
198
- analysis logic.
199
- - `tools` contains PowerShell scripts for exporting local snapshot files.
126
+ ## Development
200
127
 
201
- ## Contributing
128
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for local development, testing, dependency
129
+ graph, project structure, and ownership rule configuration notes.
202
130
 
203
131
  Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for local
204
132
  development expectations.
package/bin/ownerlens.js CHANGED
@@ -15,10 +15,10 @@ const dataDir = ensureDataDirectory(invocationRoot);
15
15
  printDataDirectorySummary(dataDir);
16
16
 
17
17
  const commands = new Map([
18
- ["collect:entra", "collect-entra.ps1"],
19
- ["collect-azure", "collect-azure.ps1"],
20
- ["collect:azure", "collect-azure.ps1"],
21
- ["collect-entra", "collect-entra.ps1"]
18
+ ["collect:entra", { root: "powershell", script: join("OwnerLens", "Public", "Invoke-OwnerLensCollectEntra.ps1") }],
19
+ ["collect-azure", { root: "powershell", script: join("OwnerLens", "Public", "Invoke-OwnerLensCollectAzure.ps1") }],
20
+ ["collect:azure", { root: "powershell", script: join("OwnerLens", "Public", "Invoke-OwnerLensCollectAzure.ps1") }],
21
+ ["collect-entra", { root: "powershell", script: join("OwnerLens", "Public", "Invoke-OwnerLensCollectEntra.ps1") }]
22
22
  ]);
23
23
 
24
24
  if (command === "help" || command === "--help" || command === "-h") {
@@ -36,9 +36,9 @@ if (commands.has(command)) {
36
36
  process.exit(1);
37
37
  }
38
38
 
39
- function runPowerShellScript(scriptName, args, options = {}) {
39
+ function runPowerShellScript(script, args, options = {}) {
40
40
  const pwsh = resolvePowerShell();
41
- const scriptPath = join(packageRoot, "tools", scriptName);
41
+ const scriptPath = join(packageRoot, script.root, script.script);
42
42
  const psArgs = [
43
43
  "-NoProfile",
44
44
  "-ExecutionPolicy",
@@ -382,7 +382,10 @@
382
382
  "additionalProperties": false,
383
383
  "properties": {
384
384
  "account": {
385
- "type": "string"
385
+ "type": [
386
+ "string",
387
+ "null"
388
+ ]
386
389
  },
387
390
  "appRoleAssignmentCount": {
388
391
  "type": "number"