sourcegraph / cody

AI that knows your entire codebase
https://cody.dev
Apache License 2.0
2.25k stars 215 forks source link

Windows: make win-ca also work with the agent #4618

Closed olafurpg closed 2 weeks ago

olafurpg commented 2 weeks ago

In the PR https://github.com/sourcegraph/cody/pull/4598, we fixed a bug related to how we installed self-signed certificates on Windows. This PR only fixed the issue for VS Code. This PR additionally fixes the problem for the agent. For the agent, we use a slightly different extensionUri. This PR adds logic to manually copy the roots.exe file over to the directory we use as extensionUri with the agent. The benefit of solving this problem like this is that it works automatically for all agent clients, avoiding the need to do custom solutions for individual clients like JetBrains.

Test plan

Manually confirmed that we are no longer printing out an error when running the tests on Windows.

github-actions[bot] commented 2 weeks ago

‼️ Hey @sourcegraph/cody-security, please review this PR carefully as it introduces the usage of an unsafe_ function or abuses PromptString.

olafurpg commented 2 weeks ago

From the unit test logs on Windows in the main branch, we see the error related to installing certificates https://github.com/sourcegraph/cody/actions/runs/9578259706/job/26408138136

Error installing Windows certs <ref *1> Error: spawnSync c:\Users\runneradmin\AppData\Roaming\Cody-nodejs\Config\dist\win-ca-roots.exe ENOENT
    at Object.spawnSync (node:internal/child_process:1124:20)
    at spawnSync (node:child_process:876:24)
    at Object.execFileSync (node:child_process:919:15)
    at Object.run2 (D:\a\cody\cody\node_modules\.pnpm\win-ca@3.5.1\node_modules\win-ca\lib\fallback.js:46:26)
    at api (D:\a\cody\cody\node_modules\.pnpm\win-ca@3.5.1\node_modules\win-ca\lib\index.js:60:10)
    at registerLocalCertificates (D:\a\cody\cody\vscode\src\certs.js:[35](https://github.com/sourcegraph/cody/actions/runs/9578259706/job/26408138136#step:9:36):9)
    at initializeNetworkAgent (D:\a\cody\cody\vscode\src\fetch.node.ts:97:5)

The logs for this PR no longer show this error https://github.com/sourcegraph/cody/actions/runs/9578695458/job/26409501979?pr=4618#step:9:31