Skip to content

[pkg firewall] wire up endor-vscode.ps1 and document the ecosystem - #31

Open
dekkagaijin wants to merge 1 commit into
vscode-fw-7-powershell-lifecyclefrom
vscode-fw-8-powershell-wiring
Open

[pkg firewall] wire up endor-vscode.ps1 and document the ecosystem#31
dekkagaijin wants to merge 1 commit into
vscode-fw-7-powershell-lifecyclefrom
vscode-fw-8-powershell-wiring

Conversation

@dekkagaijin

Copy link
Copy Markdown
Contributor

Merge after #30

Final chunk. Completes the Windows side and adds the top-level documentation, which only becomes true once both platforms are in.

powershell/templates/vscode.ps1 the ecosystem template
powershell/templates/remove.ps1 watcher first, then unpatch per install
powershell/templates/script-header.ps1 -NoVSCodeWatcher
powershell/generate.ps1 gallery base, block assignment, repatch
payload builder
powershell/README.md per-script behaviour and prerequisites
package-firewall/README.md, README.md ecosystem tables, tests section

One behaviour here is worth reading closely. In repatch mode the template must NOT recompute the attributed token: the Scheduled Task can fire at startup with nobody logged in, so $ConsoleUser is empty there, and recomputing would mint a token attributed to no user at all — losing the attribution that makes firewall events traceable to a developer. The prelude reads the URL rendered at install time out of the sidecar state instead, and the template refuses to patch if that URL is empty rather than proceeding with a bad one.

The repatch payload is written from the base64 embedded at generation time, not copied from $PSCommandPath: MDM tools routinely run scripts from a temp file that is already gone by the time the task fires.

Also fixes stale documentation the VS Code work turned up, predating the user-attribution change: both READMEs conflated generation-time and install-time placeholders, listed NPM_AUTH_B64 / PYPI_URL / PIP_INDEX_URL / GO_PROXY_URL as generation-time when they are install-time fills, omitted the real API_SECRET_B64 and FQDN_HOST, and bash/README.md claimed env.sh still exports ENDOR_PYPI_URL.

Tests: 43 assertions over the generated PowerShell. The installer cannot run wholesale off-Windows — its header calls [WindowsIdentity]::GetCurrent() — so the header is stubbed and everything after it is extracted verbatim from the generated file and executed for real: block splitting, token construction, the patch loop, state writes, the watcher call, the repatch counter. The stub is deliberately narrow so what is not covered stays obvious. Among the assertions: the token is recomputed independently from the attribution scheme, and repatch is checked to reuse that same token rather than deriving a new one.

https://endorlabs.atlassian.net/browse/LM-452

@dekkagaijin
dekkagaijin requested a review from shrey-endor August 4, 2026 23:15
Final chunk. Completes the Windows side and adds the top-level documentation,
which only becomes true once both platforms are in.

  powershell/templates/vscode.ps1        the ecosystem template
  powershell/templates/remove.ps1        watcher first, then unpatch per install
  powershell/templates/script-header.ps1 -NoVSCodeWatcher
  powershell/generate.ps1                gallery base, block assignment, repatch
                                         payload builder
  powershell/README.md                   per-script behaviour and prerequisites
  package-firewall/README.md, README.md  ecosystem tables, tests section

One behaviour here is worth reading closely. In repatch mode the template must
NOT recompute the attributed token: the Scheduled Task can fire at startup with
nobody logged in, so $ConsoleUser is empty there, and recomputing would mint a
token attributed to no user at all — losing the attribution that makes firewall
events traceable to a developer. The prelude reads the URL rendered at install
time out of the sidecar state instead, and the template refuses to patch if that
URL is empty rather than proceeding with a bad one.

The repatch payload is written from the base64 embedded at generation time, not
copied from $PSCommandPath: MDM tools routinely run scripts from a temp file that
is already gone by the time the task fires.

Also fixes stale documentation the VS Code work turned up, predating the
user-attribution change: both READMEs conflated generation-time and install-time
placeholders, listed NPM_AUTH_B64 / PYPI_URL / PIP_INDEX_URL / GO_PROXY_URL as
generation-time when they are install-time fills, omitted the real API_SECRET_B64
and FQDN_HOST, and bash/README.md claimed env.sh still exports ENDOR_PYPI_URL.

Tests: 43 assertions over the generated PowerShell. The installer cannot run
wholesale off-Windows — its header calls [WindowsIdentity]::GetCurrent() — so the
header is stubbed and everything after it is extracted verbatim from the generated
file and executed for real: block splitting, token construction, the patch loop,
state writes, the watcher call, the repatch counter. The stub is deliberately
narrow so what is not covered stays obvious. Among the assertions: the token is
recomputed independently from the attribution scheme, and repatch is checked to
reuse that same token rather than deriving a new one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dekkagaijin
dekkagaijin force-pushed the vscode-fw-8-powershell-wiring branch from 67eeded to b2d7209 Compare August 6, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant