feat: separate data classification architecture

- Create separate scanner interfaces for storage, system, and docker data
- Add dedicated endpoints for metrics and docker images instead of misclassifying as updates
- Implement proper database tables for storage metrics and docker images
- Fix storage/system metrics appearing incorrectly as package updates
- Add scanner types with proper data structures for each subsystem
- Update agent handlers to use correct endpoints for each data type
This commit is contained in:
Fimeg
2025-11-03 21:44:48 -05:00
parent 57be3754c6
commit eccc38d7c9
16 changed files with 2183 additions and 100 deletions

View File

@@ -2,6 +2,7 @@ package models
import (
"time"
"github.com/google/uuid"
)
// DockerPort represents a port mapping in a Docker container
@@ -81,4 +82,56 @@ type BulkDockerUpdateRequest struct {
ImageID string `json:"image_id" binding:"required"`
} `json:"updates" binding:"required"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
}
// DockerReportRequest is sent by agents when reporting Docker image updates
type DockerReportRequest struct {
CommandID string `json:"command_id"`
Timestamp time.Time `json:"timestamp"`
Images []DockerImage `json:"images"`
}
// DockerImageUpdate represents a Docker image update from agent scans
type DockerImageUpdate struct {
PackageType string `json:"package_type"` // "docker_image"
PackageName string `json:"package_name"` // image name:tag
CurrentVersion string `json:"current_version"` // current image ID
AvailableVersion string `json:"available_version"` // latest image ID
Severity string `json:"severity"` // "low", "moderate", "high", "critical"
RepositorySource string `json:"repository_source"` // registry URL
Metadata map[string]string `json:"metadata"`
}
// StoredDockerImage represents a Docker image update in the database
type StoredDockerImage struct {
ID uuid.UUID `json:"id" db:"id"`
AgentID uuid.UUID `json:"agent_id" db:"agent_id"`
PackageType string `json:"package_type" db:"package_type"`
PackageName string `json:"package_name" db:"package_name"`
CurrentVersion string `json:"current_version" db:"current_version"`
AvailableVersion string `json:"available_version" db:"available_version"`
Severity string `json:"severity" db:"severity"`
RepositorySource string `json:"repository_source" db:"repository_source"`
Metadata JSONB `json:"metadata" db:"metadata"`
EventType string `json:"event_type" db:"event_type"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
}
// DockerFilter represents filtering options for Docker image queries
type DockerFilter struct {
AgentID *uuid.UUID `json:"agent_id,omitempty"`
ImageName *string `json:"image_name,omitempty"`
Registry *string `json:"registry,omitempty"`
Severity *string `json:"severity,omitempty"`
HasUpdates *bool `json:"has_updates,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
// DockerResult represents the result of a Docker image query
type DockerResult struct {
Images []StoredDockerImage `json:"images"`
Total int `json:"total"`
Page int `json:"page"`
PerPage int `json:"per_page"`
}