refactor: A-series dead code cleanup and ETHOS compliance sweep

- Remove dead queries.RetryCommand function (DEV-019, 31 lines)
- Remove security_settings.go.broken leftover from A-3
- Remove 5 compiled test binaries from aggregator-agent/ (~61MB)
- Remove config_builder.go.restored from repo root
- Remove test_disk_detection.go and test_disk.go (throwaway test files)
- Fix 6 banned word violations (production-ready, enhanced, robust, seamlessly)
- Add .gitignore rules for compiled agent binaries
- Document machine ID duplication for D-1 fix prompt
- Document 30+ pre-existing emoji violations for D-2 pass

No behavior changes. All 41 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 06:17:12 -04:00
parent 6e62208f82
commit 3e1e2a78fd
18 changed files with 176 additions and 1169 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -4,7 +4,7 @@
package scanner
// WindowsUpdateScanner is an alias for WindowsUpdateScannerWUA on Windows
// This allows the WUA implementation to be used seamlessly
// This aliases to the WUA implementation on Windows builds
type WindowsUpdateScanner = WindowsUpdateScannerWUA
// NewWindowsUpdateScanner returns the WUA-based scanner on Windows

View File

@@ -33,7 +33,7 @@ var (
)
const (
AgentVersion = "0.1.16" // Enhanced configuration system with proxy support and registration tokens
AgentVersion = "0.1.16" // Configuration system with proxy support and registration tokens
)
type redflagService struct {

View File

@@ -257,7 +257,7 @@ func getMemoryInfo() (*MemoryInfo, error) {
return mem, nil
}
// getDiskInfo gets disk information for mounted filesystems with enhanced detection
// getDiskInfo gets disk information for mounted filesystems
func getDiskInfo() ([]DiskInfo, error) {
var disks []DiskInfo
@@ -383,7 +383,7 @@ func detectDiskType(device string) string {
re := strings.NewReplacer("/dev/sda", "/dev/sda", "/dev/sdb", "/dev/sdb", "/dev/nvme0n1", "/dev/nvme0n1")
baseDevice = re.Replace(baseDevice)
// More robust partition removal
// Strip partition number to get base device
if matches := regexp.MustCompile(`^(/dev/sd[a-z]|/dev/nvme\d+n\d|/dev/hd[a-z])\d*$`).FindStringSubmatch(baseDevice); len(matches) > 1 {
baseDevice = matches[1]
}

View File

@@ -387,7 +387,7 @@ func getWindowsHardwareInfo() map[string]string {
for _, line := range lines {
if strings.TrimSpace(line) != "" && !strings.Contains(line, "Manufacturer") &&
!strings.Contains(line, "Product") && !strings.Contains(line, "SerialNumber") {
// This is a simplified parsing - in production you'd want more robust parsing
// Simplified parsing — splits on whitespace for key-value pairs
if strings.Contains(line, " ") {
hardware["motherboard"] = strings.TrimSpace(line)
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,55 +0,0 @@
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/Fimeg/RedFlag/aggregator-agent/internal/system"
)
func main() {
// Test lightweight metrics (most common use case)
fmt.Println("=== Enhanced Lightweight Metrics Test ===")
metrics, err := system.GetLightweightMetrics()
if err != nil {
log.Printf("Error getting lightweight metrics: %v", err)
} else {
// Pretty print the JSON
jsonData, _ := json.MarshalIndent(metrics, "", " ")
fmt.Printf("LightweightMetrics:\n%s\n\n", jsonData)
// Show key findings
fmt.Printf("Root Disk: %.1fGB used / %.1fGB total (%.1f%%)\n",
metrics.DiskUsedGB, metrics.DiskTotalGB, metrics.DiskPercent)
if metrics.LargestDiskTotalGB > 0 {
fmt.Printf("Largest Disk (%s): %.1fGB used / %.1fGB total (%.1f%%)\n",
metrics.LargestDiskMount, metrics.LargestDiskUsedGB, metrics.LargestDiskTotalGB, metrics.LargestDiskPercent)
} else {
fmt.Printf("No largest disk detected (this might be the issue!)\n")
}
}
// Test full system info (detailed disk inventory)
fmt.Println("\n=== Enhanced System Info Test ===")
sysInfo, err := system.GetSystemInfo("test-v0.1.5")
if err != nil {
log.Printf("Error getting system info: %v", err)
} else {
fmt.Printf("Found %d disks:\n", len(sysInfo.DiskInfo))
for i, disk := range sysInfo.DiskInfo {
fmt.Printf(" Disk %d: %s (%s) - %s, %.1fGB used / %.1fGB total (%.1f%%)",
i+1, disk.Mountpoint, disk.Filesystem, disk.DiskType,
float64(disk.Used)/(1024*1024*1024), float64(disk.Total)/(1024*1024*1024), disk.UsedPercent)
if disk.IsRoot {
fmt.Printf(" [ROOT]")
}
if disk.IsLargest {
fmt.Printf(" [LARGEST]")
}
fmt.Printf("\n")
}
}
}