feat: add config sync endpoint and security UI updates
- Add GET /api/v1/agents/:id/config endpoint for server configuration - Agent fetches config during check-in and applies updates - Add version tracking to prevent unnecessary config applications - Clean separation: config sync independent of commands - Fix agent UI subsystem settings to actually control agent behavior - Update Security Health UI with frosted glass styling and tooltips
This commit is contained in:
@@ -285,21 +285,59 @@ func handleScanDocker(apiClient *client.Client, cfg *config.Config, ackTracker *
|
||||
log.Printf("Failed to report scan log: %v\n", err)
|
||||
}
|
||||
|
||||
// Report updates to server if any were found
|
||||
if len(result.Updates) > 0 {
|
||||
report := client.UpdateReport{
|
||||
CommandID: commandID,
|
||||
Timestamp: time.Now(),
|
||||
Updates: result.Updates,
|
||||
// Report Docker images to server using dedicated endpoint
|
||||
// Get Docker scanner and use proper interface
|
||||
dockerScanner, err := orchestrator.NewDockerScanner()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create Docker scanner: %w", err)
|
||||
}
|
||||
defer dockerScanner.Close()
|
||||
|
||||
if dockerScanner.IsAvailable() {
|
||||
images, err := dockerScanner.ScanDocker()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to scan Docker images: %w", err)
|
||||
}
|
||||
|
||||
if err := apiClient.ReportUpdates(cfg.AgentID, report); err != nil {
|
||||
return fmt.Errorf("failed to report Docker updates: %w", err)
|
||||
}
|
||||
// Always report all Docker images (not just those with updates)
|
||||
if len(images) > 0 {
|
||||
// Convert DockerImage to DockerReportItem for API call
|
||||
imageItems := make([]client.DockerReportItem, 0, len(images))
|
||||
for _, image := range images {
|
||||
item := client.DockerReportItem{
|
||||
PackageType: "docker_image",
|
||||
PackageName: image.ImageName,
|
||||
CurrentVersion: image.ImageID,
|
||||
AvailableVersion: image.LatestImageID,
|
||||
Severity: image.Severity,
|
||||
RepositorySource: image.RepositorySource,
|
||||
Metadata: image.Metadata,
|
||||
}
|
||||
imageItems = append(imageItems, item)
|
||||
}
|
||||
|
||||
log.Printf("✓ Reported %d Docker image updates to server\n", len(result.Updates))
|
||||
report := client.DockerReport{
|
||||
CommandID: commandID,
|
||||
Timestamp: time.Now(),
|
||||
Images: imageItems,
|
||||
}
|
||||
|
||||
if err := apiClient.ReportDockerImages(cfg.AgentID, report); err != nil {
|
||||
return fmt.Errorf("failed to report Docker images: %w", err)
|
||||
}
|
||||
|
||||
updateCount := 0
|
||||
for _, image := range images {
|
||||
if image.HasUpdate {
|
||||
updateCount++
|
||||
}
|
||||
}
|
||||
log.Printf("✓ Reported %d Docker images (%d with updates) to server\n", len(images), updateCount)
|
||||
} else {
|
||||
log.Println("No Docker images found")
|
||||
}
|
||||
} else {
|
||||
log.Println("No Docker image updates found")
|
||||
log.Println("Docker not available on this system")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user