A (hardware-ingest-json v2.8-2.9): remove sensor location fields from schema and collector; tag HardwareMemory.Location as json:"-"; add PlatformConfig to HardwareSnapshot. B (no-hardcoded-vendors): consolidate PCI vendor IDs into collector/pci_vendors.go; replace all vendor-name string checks in isGPUDevice, isNVIDIADevice, isMellanoxDevice, isAMDGPUDevice, matchesGPUVendor (sat_overlay), and validateIsVendorGPU (page_validate) with numeric vendor_id comparisons. C (module-structure): split app/app.go (1413 lines) into app.go + app_format.go, app_network.go, app_services.go, app_packs.go, app_install.go — no logic changes. D (go-code-style): wrap bare return err in interfaceAdminState and interfaceIPv4Addrs (platform/network.go) with fmt.Errorf context including the interface name. E (go-project-bible): add bible-local/architecture/data-model.md and bible-local/architecture/api-surface.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
2.0 KiB
Go
68 lines
2.0 KiB
Go
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"bee/audit/internal/platform"
|
|
)
|
|
|
|
func (a *App) ListBeeServices() ([]string, error) {
|
|
return a.services.ListBeeServices()
|
|
}
|
|
|
|
func (a *App) ServiceState(name string) string {
|
|
return a.services.ServiceState(name)
|
|
}
|
|
|
|
func (a *App) ServiceStatus(name string) (string, error) {
|
|
return a.services.ServiceStatus(name)
|
|
}
|
|
|
|
func (a *App) ServiceStatusResult(name string) (ActionResult, error) {
|
|
body, err := a.services.ServiceStatus(name)
|
|
return ActionResult{Title: "service status: " + name, Body: bodyOr(body, "No status output.")}, err
|
|
}
|
|
|
|
func (a *App) ServiceDo(name string, action platform.ServiceAction) (string, error) {
|
|
return a.services.ServiceDo(name, action)
|
|
}
|
|
|
|
func (a *App) ServiceActionResult(name string, action platform.ServiceAction) (ActionResult, error) {
|
|
body, err := a.services.ServiceDo(name, action)
|
|
return ActionResult{Title: "service " + string(action) + ": " + name, Body: bodyOr(body, "Action completed.")}, err
|
|
}
|
|
|
|
func (a *App) TailFile(path string, lines int) string {
|
|
return a.tools.TailFile(path, lines)
|
|
}
|
|
|
|
func (a *App) CheckTools(names []string) []platform.ToolStatus {
|
|
return a.tools.CheckTools(names)
|
|
}
|
|
|
|
func (a *App) ToolCheckResult(names []string) ActionResult {
|
|
if len(names) == 0 {
|
|
return ActionResult{Title: "Required tools", Body: "No tools checked."}
|
|
}
|
|
var body strings.Builder
|
|
for _, tool := range a.tools.CheckTools(names) {
|
|
status := "MISSING"
|
|
if tool.OK {
|
|
status = "OK (" + tool.Path + ")"
|
|
}
|
|
fmt.Fprintf(&body, "- %s: %s\n", tool.Name, status)
|
|
}
|
|
return ActionResult{Title: "Required tools", Body: strings.TrimSpace(body.String())}
|
|
}
|
|
|
|
func (a *App) AuditLogTailResult() ActionResult {
|
|
logTail := strings.TrimSpace(a.tools.TailFile(DefaultAuditLogPath, 40))
|
|
jsonTail := strings.TrimSpace(a.tools.TailFile(DefaultAuditJSONPath, 20))
|
|
body := strings.TrimSpace(logTail + "\n\n" + jsonTail)
|
|
if body == "" {
|
|
body = "No audit logs found."
|
|
}
|
|
return ActionResult{Title: "Audit log tail", Body: body}
|
|
}
|