fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.13k stars 431 forks source link

Panic when running "Apply latest configuration to Fleet" GitHub action #22244

Open allenhouchins opened 2 months ago

allenhouchins commented 2 months ago

Fleet version: 4.56.0

Web browser and operating system: Safari or Chrome on macOS


💥  Actual behavior

Following the configuration steps found here: https://github.com/fleetdm/fleet-gitops

When attempting to run theApply latest configuration to Fleet action, I encounter a panic. Logs included below.

🧑‍💻  Steps to reproduce

  1. New installation of Fleet on Render
  2. New configuration of fleet-gitops following the directions in the README found here: https://github.com/fleetdm/fleet-gitops
  3. Attempt to run the Apply latest configuration to Fleet action

🕯️ More info (optional)

[-] deleting 1 policies [+] would've applied 'No Team' software installers panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xebc425] goroutine 1 [running]: github.com/fleetdm/fleet/v4/server/service.(Client).DoGitOps(0xc0009a7360, {0x1b8e9e0, 0x26ee0c0}, 0xc000600f20, {0x7ffe907efb54, 0x16}, 0xc000a57860, 0x1, 0xc00072e8c9, 0xc00081a908) github.com/fleetdm/fleet/v4/server/service/client.go:1207 +0x185 main.gitopsCommand.func1(0xc000822a40) github.com/fleetdm/fleet/v4/cmd/fleetctl/gitops.go:175 +0xba5 github.com/urfave/cli/v2.(Command).Run(0xc0008428c0, 0xc000822a40, {0xc00081d380, 0x6, 0x6}) github.com/urfave/cli/v2@v2.23.5/command.go:271 +0x99f github.com/urfave/cli/v2.(Command).Run(0xc000842dc0, 0xc000822900, {0xc00013a000, 0x7, 0x7}) github.com/urfave/cli/v2@v2.23.5/command.go:264 +0xbdd github.com/urfave/cli/v2.(App).RunContext(0xc0007e25a0, {0x1b8e9e0, 0x26ee0c0}, {0xc00013a000, 0x7, 0x7}) github.com/urfave/cli/v2@v2.23.5/app.go:329 +0x536 github.com/urfave/cli/v2.(*App).Run(...) github.com/urfave/cli/v2@v2.23.5/app.go:306 main.main() github.com/fleetdm/fleet/v4/cmd/fleetctl/fleetctl.go:29 +0x6d Error: Process completed with exit code 2.

getvictor commented 2 months ago

This occurs when script path is empty.

Looks like we need a null check here:

    for i, script := range config.Controls.Scripts {
        scripts[i] = *script.Path
    }