forked from Ullaakut/cameradar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.go
More file actions
74 lines (66 loc) · 1.52 KB
/
ui.go
File metadata and controls
74 lines (66 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package cameradar
import (
"fmt"
"strings"
)
// Mode defines which UI renderer to use.
type Mode string
// Supported rendering modes.
const (
ModeAuto Mode = "auto"
ModeTUI Mode = "tui"
ModePlain Mode = "plain"
)
// Step identifies a stage in the workflow.
type Step string
// Supported steps.
const (
StepScan Step = "scan"
StepAttackRoutes Step = "attack-routes"
StepDetectAuth Step = "detect-auth"
StepAttackCredentials Step = "attack-credentials"
StepValidateStreams Step = "validate-streams"
StepSummary Step = "summary"
)
// StepLabel returns the human-readable label for a step.
func StepLabel(step Step) string {
switch step {
case StepScan:
return "Scan targets"
case StepAttackRoutes:
return "Attack routes"
case StepDetectAuth:
return "Detect authentication"
case StepAttackCredentials:
return "Attack credentials"
case StepValidateStreams:
return "Validate streams"
case StepSummary:
return "Summary"
default:
return string(step)
}
}
// Steps returns the ordered list of steps.
func Steps() []Step {
return []Step{
StepScan,
StepAttackRoutes,
StepDetectAuth,
StepAttackCredentials,
StepValidateStreams,
StepSummary,
}
}
// ParseMode parses a user-provided UI mode.
func ParseMode(value string) (Mode, error) {
mode := Mode(strings.ToLower(strings.TrimSpace(value)))
switch mode {
case ModeAuto, ModeTUI, ModePlain:
return mode, nil
case "":
return ModeAuto, nil
default:
return ModeAuto, fmt.Errorf("invalid ui mode %q", value)
}
}