cleanup: remove 2,369 lines of dead code
Removed backup files and unused legacy scanner function. All code verified as unreferenced.
This commit is contained in:
@@ -36,13 +36,14 @@ type AgentFileInventory struct {
|
||||
|
||||
// MigrationDetection represents the result of migration detection
|
||||
type MigrationDetection struct {
|
||||
CurrentAgentVersion string `json:"current_agent_version"`
|
||||
CurrentConfigVersion int `json:"current_config_version"`
|
||||
RequiresMigration bool `json:"requires_migration"`
|
||||
RequiredMigrations []string `json:"required_migrations"`
|
||||
MissingSecurityFeatures []string `json:"missing_security_features"`
|
||||
CurrentAgentVersion string `json:"current_agent_version"`
|
||||
CurrentConfigVersion int `json:"current_config_version"`
|
||||
RequiresMigration bool `json:"requires_migration"`
|
||||
RequiredMigrations []string `json:"required_migrations"`
|
||||
MissingSecurityFeatures []string `json:"missing_security_features"`
|
||||
Inventory *AgentFileInventory `json:"inventory"`
|
||||
DetectionTime time.Time `json:"detection_time"`
|
||||
DockerDetection *DockerDetection `json:"docker_detection,omitempty"`
|
||||
DetectionTime time.Time `json:"detection_time"`
|
||||
}
|
||||
|
||||
// SecurityFeature represents a security feature that may be missing
|
||||
@@ -104,6 +105,15 @@ func DetectMigrationRequirements(config *FileDetectionConfig) (*MigrationDetecti
|
||||
missingFeatures := identifyMissingSecurityFeatures(detection)
|
||||
detection.MissingSecurityFeatures = missingFeatures
|
||||
|
||||
// Detect Docker secrets requirements if in Docker environment
|
||||
if IsDockerEnvironment() {
|
||||
dockerDetection, err := DetectDockerSecretsRequirements(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to detect Docker secrets requirements: %w", err)
|
||||
}
|
||||
detection.DockerDetection = dockerDetection
|
||||
}
|
||||
|
||||
return detection, nil
|
||||
}
|
||||
|
||||
@@ -143,8 +153,9 @@ func scanAgentFiles(config *FileDetectionConfig) (*AgentFileInventory, error) {
|
||||
},
|
||||
}
|
||||
|
||||
// Scan old directory paths
|
||||
for _, dirPath := range inventory.OldDirectoryPaths {
|
||||
// Scan both old and new directory paths
|
||||
allPaths := append(inventory.OldDirectoryPaths, inventory.NewDirectoryPaths...)
|
||||
for _, dirPath := range allPaths {
|
||||
if _, err := os.Stat(dirPath); err == nil {
|
||||
files, err := scanDirectory(dirPath, filePatterns)
|
||||
if err != nil {
|
||||
@@ -292,6 +303,16 @@ func determineRequiredMigrations(detection *MigrationDetection, config *FileDete
|
||||
migrations = append(migrations, "config_migration")
|
||||
}
|
||||
|
||||
// Check if Docker secrets migration is needed (v5)
|
||||
if detection.CurrentConfigVersion < 5 {
|
||||
migrations = append(migrations, "config_v5_migration")
|
||||
}
|
||||
|
||||
// Check if Docker secrets migration is needed
|
||||
if detection.DockerDetection != nil && detection.DockerDetection.MigrateToSecrets {
|
||||
migrations = append(migrations, "docker_secrets_migration")
|
||||
}
|
||||
|
||||
// Check if security features need to be applied
|
||||
if len(detection.MissingSecurityFeatures) > 0 {
|
||||
migrations = append(migrations, "security_hardening")
|
||||
|
||||
Reference in New Issue
Block a user