base dashboard and login

This commit is contained in:
2026-05-17 08:28:16 +00:00
parent 64f4f3c5d4
commit 317a7f3f13
40 changed files with 3327 additions and 72 deletions
+3 -2
View File
@@ -328,8 +328,9 @@ func (c *CLIClient) listHubItems(ctx context.Context, kind string) ([]HubItem, e
}
func (c *CLIClient) hubAction(ctx context.Context, kind, action, name string) error {
if err := validateName(name); err != nil {
return err
// Hub item names can contain slashes (e.g. crowdsecurity/ssh-bf); use safeArg not validateName.
if !safeArg.MatchString(name) || name == "" {
return fmt.Errorf("invalid hub item name: %q", name)
}
_, err := c.run(ctx, kind, action, name)
return err
+137
View File
@@ -0,0 +1,137 @@
package crowdsec
// -----------------------------------------------------------------------
// LAPI types
// -----------------------------------------------------------------------
type LoginRequest struct {
MachineID string `json:"machine_id"`
Password string `json:"password"`
Scenarios []string `json:"scenarios,omitempty"`
}
type LoginResponse struct {
Token string `json:"token"`
Expire string `json:"expire"`
}
type Decision struct {
ID int64 `json:"id"`
Origin string `json:"origin"`
Type string `json:"type"`
Scope string `json:"scope"`
Value string `json:"value"`
Duration string `json:"duration"`
Scenario string `json:"scenario"`
Simulated bool `json:"simulated"`
Until string `json:"until,omitempty"`
}
type DecisionInput struct {
Duration string `json:"duration"`
Origin string `json:"origin"`
Scenario string `json:"scenario"`
Scope string `json:"scope"`
Simulated bool `json:"simulated"`
Type string `json:"type"`
Value string `json:"value"`
}
type AlertSource struct {
AsName string `json:"as_name,omitempty"`
AsNumber int `json:"as_number,omitempty"`
CN string `json:"cn,omitempty"`
IP string `json:"ip,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
Range string `json:"range,omitempty"`
Scope string `json:"scope"`
Value string `json:"value"`
}
type AlertEvent struct {
Meta []MetaItem `json:"meta"`
Timestamp string `json:"timestamp"`
}
type MetaItem struct {
Key string `json:"key"`
Value string `json:"value"`
}
type Alert struct {
ID int64 `json:"id"`
UUID string `json:"uuid,omitempty"`
Capacity int32 `json:"capacity"`
CreatedAt string `json:"created_at"`
Decisions []Decision `json:"decisions"`
Events []AlertEvent `json:"events"`
EventsCount int32 `json:"events_count"`
Leakspeed string `json:"leakspeed"`
MachineID string `json:"machine_id,omitempty"`
Message string `json:"message"`
Remediation bool `json:"remediation"`
Scenario string `json:"scenario"`
ScenarioHash string `json:"scenario_hash"`
ScenarioVersion string `json:"scenario_version"`
Simulated bool `json:"simulated"`
Source AlertSource `json:"source"`
StartAt string `json:"start_at"`
StopAt string `json:"stop_at"`
}
// -----------------------------------------------------------------------
// CLI types (cscli output)
// -----------------------------------------------------------------------
type Bouncer struct {
APIKey string `json:"api_key"`
AuthType string `json:"auth_type"`
AutoCreated bool `json:"auto_created"`
CreatedAt string `json:"created_at"`
IPAddress string `json:"ip_address"`
LastPull string `json:"last_pull"`
Name string `json:"name"`
Revoked bool `json:"revoked"`
Type string `json:"type"`
Version string `json:"version"`
}
type AddBouncerResult struct {
Name string
APIKey string
}
type Machine struct {
AuthType string `json:"auth_type"`
CreatedAt string `json:"createdAt"`
IPAddress string `json:"ipAddress"`
IsValidated bool `json:"isValidated"`
LastHeartbeat string `json:"last_heartbeat"`
LastPush string `json:"lastPush"`
MachineID string `json:"machineId"`
Scenarios string `json:"scenarios"`
Status string `json:"status"`
Version string `json:"version"`
}
type HubItem struct {
Author string `json:"author"`
Description string `json:"description"`
Downloaded bool `json:"downloaded"`
Installed bool `json:"installed"`
Local bool `json:"local"`
Name string `json:"name"`
Path string `json:"path"`
Stage string `json:"stage"`
Status string `json:"status"`
Tainted bool `json:"tainted"`
UpToDate bool `json:"up_to_date"`
Version string `json:"version"`
}
type MetricsSection struct {
Title string
Headers []string
Rows [][]string
}