Make the one-line install survive Defender, and approval leave a PC that works
All three found testing the bootstrap installer on Windows. - The published command used the irm-pipe-iex form, which Microsoft Defender detects as Trojan:Win32/Commando.A!ml and kills before it runs, every time, on a default install. The command now downloads the script to a file, runs it, and removes it in a finally block, which Defender does not object to. The UI also offers the script as a plain download for a tech who would rather save it. - Approving a request only linked the asset, so a PC whose pending reason was "unknown hostname" - which is every PC installed this way - kept getting 403 on every call afterwards, because its computer record had no hostname to match the credential against. Approval now stamps the hostname when the record has none, refuses with a 409 naming both when the record has a different one, and overwrites only when the admin confirms. The Credentials tab offers that confirmation. - A hostname that resolves to no record now says so instead of reading as an impostor, while still refusing the request. - While waiting for approval the agent retried on the 15-minute telemetry cadence, so a PC approved immediately enrolled a quarter of an hour later and the installer always ended on "still pending". It now retries about every minute for the first ten minutes, then every five to thirty minutes, then every fifteen, with jitter. A rate limit or server error still uses the slower backoff.
This commit is contained in:
@@ -189,6 +189,69 @@ describe('EnrollmentSettings', () => {
|
||||
expect(api.post).toHaveBeenCalledWith('/endpoints/enrollment/requests/45/approve', { assetid: 77 })
|
||||
})
|
||||
|
||||
// Approving a one-off PC onto a computer recorded under another hostname is
|
||||
// refused by the server, because the PC authenticates by hostname afterwards.
|
||||
// The page has to show that message and let the admin answer it, not swallow
|
||||
// it as "could not approve".
|
||||
function hostnameConflict() {
|
||||
return {
|
||||
response: {
|
||||
status: 409,
|
||||
data: {
|
||||
data: {
|
||||
error: {
|
||||
code: 'CONFLICT',
|
||||
message: 'That computer is recorded as PC-OLD, but the request comes from PC-NEW.',
|
||||
details: {
|
||||
hostnameconflict: true,
|
||||
computerhostname: 'PC-OLD',
|
||||
requesthostname: 'PC-NEW'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it('offers to set the hostname when approve comes back 409, then re-posts', async () => {
|
||||
const confirmSpy = vi.fn(() => true)
|
||||
vi.stubGlobal('confirm', confirmSpy)
|
||||
const wrapper = await render()
|
||||
await openCredentials(wrapper)
|
||||
api.post.mockReset()
|
||||
api.post.mockRejectedValueOnce(hostnameConflict())
|
||||
api.post.mockResolvedValue({ data: { data: { hostnameresult: 'overwritten' } } })
|
||||
|
||||
await wrapper.find('.approve-open').trigger('click')
|
||||
await wrapper.find('.approve-confirm').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(api.post.mock.calls).toEqual([
|
||||
['/endpoints/enrollment/requests/45/approve', { assetid: 77 }],
|
||||
['/endpoints/enrollment/requests/45/approve', { assetid: 77, sethostname: true }]
|
||||
])
|
||||
const asked = confirmSpy.mock.calls.at(-1)[0]
|
||||
expect(asked).toContain('recorded as PC-OLD')
|
||||
expect(asked).toContain('Set the hostname on this PC?')
|
||||
})
|
||||
|
||||
it('sends nothing more when the hostname question is declined', async () => {
|
||||
vi.stubGlobal('confirm', vi.fn().mockReturnValueOnce(true).mockReturnValueOnce(false))
|
||||
const wrapper = await render()
|
||||
await openCredentials(wrapper)
|
||||
api.post.mockReset()
|
||||
api.post.mockRejectedValue(hostnameConflict())
|
||||
|
||||
await wrapper.find('.approve-open').trigger('click')
|
||||
await wrapper.find('.approve-confirm').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(api.post).toHaveBeenCalledTimes(1)
|
||||
expect(api.post).toHaveBeenCalledWith('/endpoints/enrollment/requests/45/approve',
|
||||
{ assetid: 77 })
|
||||
})
|
||||
|
||||
it('rejects a request after confirm', async () => {
|
||||
vi.stubGlobal('confirm', vi.fn(() => true))
|
||||
const wrapper = await render()
|
||||
|
||||
Reference in New Issue
Block a user