refactor(go): Update Go commands and TUI controller
Update api-server and gen-keys main files Update TUI controller commands, helpers, and settings
This commit is contained in:
parent
6faa13aabf
commit
abd27bf0a2
5 changed files with 11 additions and 11 deletions
|
|
@ -74,7 +74,7 @@ func runSecurityAudit(configFile string) {
|
||||||
if mode&0077 != 0 {
|
if mode&0077 != 0 {
|
||||||
issues = append(issues, fmt.Sprintf("Config file %s is world/group readable (permissions: %04o)", configFile, mode))
|
issues = append(issues, fmt.Sprintf("Config file %s is world/group readable (permissions: %04o)", configFile, mode))
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("✓ Config file permissions: %04o (secure)\n", mode)
|
fmt.Printf("Config file permissions: %04o (secure)\n", mode)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warnings = append(warnings, fmt.Sprintf("Could not check config file: %v", err))
|
warnings = append(warnings, fmt.Sprintf("Could not check config file: %v", err))
|
||||||
|
|
@ -91,14 +91,14 @@ func runSecurityAudit(configFile string) {
|
||||||
if len(exposedVars) > 0 {
|
if len(exposedVars) > 0 {
|
||||||
warnings = append(warnings, fmt.Sprintf("Sensitive environment variables exposed: %v (will be cleared on startup)", exposedVars))
|
warnings = append(warnings, fmt.Sprintf("Sensitive environment variables exposed: %v (will be cleared on startup)", exposedVars))
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("✓ No sensitive environment variables exposed")
|
fmt.Println("No sensitive environment variables exposed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check 3: Running as root
|
// Check 3: Running as root
|
||||||
if os.Getuid() == 0 {
|
if os.Getuid() == 0 {
|
||||||
issues = append(issues, "Running as root (UID 0) - should run as non-root user")
|
issues = append(issues, "Running as root (UID 0) - should run as non-root user")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("✓ Running as non-root user (UID: %d)\n", os.Getuid())
|
fmt.Printf("Running as non-root user (UID: %d)\n", os.Getuid())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check 4: API key file permissions
|
// Check 4: API key file permissions
|
||||||
|
|
@ -109,7 +109,7 @@ func runSecurityAudit(configFile string) {
|
||||||
if mode&0077 != 0 {
|
if mode&0077 != 0 {
|
||||||
issues = append(issues, fmt.Sprintf("API key file %s is world/group readable (permissions: %04o)", apiKeyFile, mode))
|
issues = append(issues, fmt.Sprintf("API key file %s is world/group readable (permissions: %04o)", apiKeyFile, mode))
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("✓ API key file permissions: %04o (secure)\n", mode)
|
fmt.Printf("API key file permissions: %04o (secure)\n", mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +117,7 @@ func runSecurityAudit(configFile string) {
|
||||||
// Report results
|
// Report results
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if len(issues) == 0 && len(warnings) == 0 {
|
if len(issues) == 0 && len(warnings) == 0 {
|
||||||
fmt.Println("✓ All security checks passed")
|
fmt.Println("All security checks passed")
|
||||||
} else {
|
} else {
|
||||||
if len(issues) > 0 {
|
if len(issues) > 0 {
|
||||||
fmt.Printf("✗ Found %d security issue(s):\n", len(issues))
|
fmt.Printf("✗ Found %d security issue(s):\n", len(issues))
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print summary
|
// Print summary
|
||||||
fmt.Printf("✓ Generated Ed25519 signing keys\n")
|
fmt.Printf("Generated Ed25519 signing keys\n")
|
||||||
fmt.Printf(" Key ID: %s\n", *keyID)
|
fmt.Printf(" Key ID: %s\n", *keyID)
|
||||||
fmt.Printf(" Private key: %s (permissions: 0600)\n", privKeyPath)
|
fmt.Printf(" Private key: %s (permissions: 0600)\n", privKeyPath)
|
||||||
fmt.Printf(" Public key: %s\n", pubKeyPath)
|
fmt.Printf(" Public key: %s\n", pubKeyPath)
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ func (c *Controller) queueJob(jobName string, args string) tea.Cmd {
|
||||||
|
|
||||||
c.logger.Info("job queued", "job_name", jobName, "task_id", task.ID[:8], "priority", priority)
|
c.logger.Info("job queued", "job_name", jobName, "task_id", task.ID[:8], "priority", priority)
|
||||||
resultChan <- model.StatusMsg{
|
resultChan <- model.StatusMsg{
|
||||||
Text: fmt.Sprintf("✓ Queued: %s (ID: %s, P:%d)", jobName, task.ID[:8], priority),
|
Text: fmt.Sprintf("Queued: %s (ID: %s, P:%d)", jobName, task.ID[:8], priority),
|
||||||
Level: "success",
|
Level: "success",
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
@ -287,7 +287,7 @@ func (c *Controller) deleteJob(jobName string) tea.Cmd {
|
||||||
if _, err := c.server.Exec(cmd); err != nil {
|
if _, err := c.server.Exec(cmd); err != nil {
|
||||||
return model.StatusMsg{Text: fmt.Sprintf("Failed to archive %s: %v", jobName, err), Level: "error"}
|
return model.StatusMsg{Text: fmt.Sprintf("Failed to archive %s: %v", jobName, err), Level: "error"}
|
||||||
}
|
}
|
||||||
return model.StatusMsg{Text: fmt.Sprintf("✓ Archived: %s", jobName), Level: "success"}
|
return model.StatusMsg{Text: fmt.Sprintf("Archived: %s", jobName), Level: "success"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,7 +309,7 @@ func (c *Controller) cancelTask(taskID string) tea.Cmd {
|
||||||
return model.StatusMsg{Text: fmt.Sprintf("Cancel failed: %v", err), Level: "error"}
|
return model.StatusMsg{Text: fmt.Sprintf("Cancel failed: %v", err), Level: "error"}
|
||||||
}
|
}
|
||||||
c.logger.Info("task cancelled", "task_id", taskID[:8])
|
c.logger.Info("task cancelled", "task_id", taskID[:8])
|
||||||
return model.StatusMsg{Text: fmt.Sprintf("✓ Cancelled: %s", taskID[:8]), Level: "success"}
|
return model.StatusMsg{Text: fmt.Sprintf("Cancelled: %s", taskID[:8]), Level: "success"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func formatStatus(m model.State) string {
|
||||||
stats = append(stats, fmt.Sprintf("▶ %d", count))
|
stats = append(stats, fmt.Sprintf("▶ %d", count))
|
||||||
}
|
}
|
||||||
if count := m.JobStats[model.StatusFinished]; count > 0 {
|
if count := m.JobStats[model.StatusFinished]; count > 0 {
|
||||||
stats = append(stats, fmt.Sprintf("✓ %d", count))
|
stats = append(stats, fmt.Sprintf("%d", count))
|
||||||
}
|
}
|
||||||
if count := m.JobStats[model.StatusFailed]; count > 0 {
|
if count := m.JobStats[model.StatusFailed]; count > 0 {
|
||||||
stats = append(stats, fmt.Sprintf("✗ %d", count))
|
stats = append(stats, fmt.Sprintf("✗ %d", count))
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ func getSettingsIndicator(m model.State, index int) string {
|
||||||
|
|
||||||
func getAPIKeyStatus(m model.State) string {
|
func getAPIKeyStatus(m model.State) string {
|
||||||
if m.APIKey != "" {
|
if m.APIKey != "" {
|
||||||
return "✓ API Key is set\n" + maskAPIKey(m.APIKey)
|
return "API Key is set\n" + maskAPIKey(m.APIKey)
|
||||||
}
|
}
|
||||||
return "⚠ No API Key configured"
|
return "⚠ No API Key configured"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue