This commit addresses the OWASP security audit by enforcing strict host key verification and resolves persistent CI issues. Security Changes: - Replaced StrictHostKeyChecking=accept-new with yes in pkg/container and devops. - Removed insecure host key verification from pkg/ansible. - Implemented synchronous host key discovery using ssh-keyscan during VM boot. - Updated Boot lifecycle to wait for host key verification. - Handled missing known_hosts file in pkg/ansible. - Refactored hardcoded SSH port to DefaultSSHPort constant. CI and Maintenance: - Fixed auto-merge.yml by inlining the script and adding repository context to 'gh' command, resolving the "not a git repository" error in CI. - Resolved merge conflicts in .github/workflows/auto-merge.yml with dev branch. - Added pkg/ansible/ssh_test.go for SSH client verification. - Fixed formatting in pkg/io/local/client.go to pass QA checks.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package unifi
|
|
|
|
import (
|
|
"github.com/host-uk/core/pkg/cli"
|
|
"github.com/host-uk/core/pkg/log"
|
|
uf "github.com/host-uk/core/pkg/unifi"
|
|
)
|
|
|
|
// addSitesCommand adds the 'sites' subcommand for listing UniFi sites.
|
|
func addSitesCommand(parent *cli.Command) {
|
|
cmd := &cli.Command{
|
|
Use: "sites",
|
|
Short: "List controller sites",
|
|
Long: "List all sites configured on the UniFi controller.",
|
|
RunE: func(cmd *cli.Command, args []string) error {
|
|
return runSites()
|
|
},
|
|
}
|
|
|
|
parent.AddCommand(cmd)
|
|
}
|
|
|
|
func runSites() error {
|
|
client, err := uf.NewFromConfig("", "", "", "")
|
|
if err != nil {
|
|
return log.E("unifi.sites", "failed to initialise client", err)
|
|
}
|
|
|
|
sites, err := client.GetSites()
|
|
if err != nil {
|
|
return log.E("unifi.sites", "failed to fetch sites", err)
|
|
}
|
|
|
|
if len(sites) == 0 {
|
|
cli.Text("No sites found.")
|
|
return nil
|
|
}
|
|
|
|
table := cli.NewTable("Name", "Description")
|
|
|
|
for _, s := range sites {
|
|
table.AddRow(
|
|
valueStyle.Render(s.Name),
|
|
dimStyle.Render(s.Desc),
|
|
)
|
|
}
|
|
|
|
cli.Blank()
|
|
cli.Print(" %d sites\n\n", len(sites))
|
|
table.Render()
|
|
|
|
return nil
|
|
}
|