Files
fuzzygraph/types.go
T

118 lines
5.2 KiB
Go

package main
// EntityTypePreset defines an OSINT entity type with its visual properties and suggested metadata fields.
type EntityTypePreset struct {
TypeRef string `json:"type_ref"` // registry type ID
Label string `json:"label"` // human-readable
Color string `json:"color"` // hex color for graph nodes
MetadataFields []string `json:"metadata_fields"` // suggested metadata keys
}
// GraphData matches the frontend-lib GraphData interface for sigma.js rendering.
type GraphData struct {
Nodes []GraphNode `json:"nodes"`
Edges []GraphEdge `json:"edges"`
}
// GraphNode matches the frontend-lib GraphNode interface.
type GraphNode struct {
ID string `json:"id"`
Label string `json:"label"`
Type string `json:"type"`
Color string `json:"color"`
Size float64 `json:"size"`
X float64 `json:"x"`
Y float64 `json:"y"`
// Extra fields from entity metadata (flattened)
Extra map[string]any `json:"extra,omitempty"`
}
// GraphEdge matches the frontend-lib GraphEdge interface.
type GraphEdge struct {
ID string `json:"id"`
Source string `json:"source"`
Target string `json:"target"`
Label string `json:"label"`
Color string `json:"color"`
Size float64 `json:"size"`
Type string `json:"type"` // "arrow"
}
// ProjectInfo describes a project directory.
type ProjectInfo struct {
Name string `json:"name"`
Description string `json:"description"`
EntityCount int `json:"entity_count"`
RelCount int `json:"relation_count"`
}
// EntityInput is the DTO for creating/updating entities from the frontend.
type EntityInput struct {
Name string `json:"name"`
TypeRef string `json:"type_ref"`
Description string `json:"description"`
Tags []string `json:"tags"`
Metadata map[string]any `json:"metadata"`
Notes string `json:"notes"`
}
// RelationInput is the DTO for creating/updating relations from the frontend.
type RelationInputDTO struct {
Name string `json:"name"`
FromEntity string `json:"from_entity"`
ToEntity string `json:"to_entity"`
Description string `json:"description"`
Weight *float64 `json:"weight"`
Tags []string `json:"tags"`
Notes string `json:"notes"`
}
// AssertionInput is the DTO for creating assertions from the frontend.
type AssertionInput struct {
EntityID string `json:"entity_id"`
Name string `json:"name"`
Kind string `json:"kind"`
Rule string `json:"rule"`
Severity string `json:"severity"`
Description string `json:"description"`
}
// Color map for OSINT entity types
var entityTypeColors = map[string]string{
"osint_person_go_cybersecurity": "#e74c3c",
"osint_organization_go_cybersecurity": "#3498db",
"osint_crypto_wallet_go_cybersecurity": "#f39c12",
"osint_ip_address_go_cybersecurity": "#2ecc71",
"osint_domain_go_cybersecurity": "#9b59b6",
"osint_email_go_cybersecurity": "#1abc9c",
"osint_phone_go_cybersecurity": "#e67e22",
"osint_malware_go_cybersecurity": "#c0392b",
"osint_vulnerability_go_cybersecurity": "#8e44ad",
"osint_social_media_go_cybersecurity": "#2980b9",
"osint_document_go_cybersecurity": "#7f8c8d",
"osint_event_go_cybersecurity": "#d35400",
"osint_location_go_cybersecurity": "#27ae60",
}
var entityTypePresets = []EntityTypePreset{
{"osint_person_go_cybersecurity", "Person", "#e74c3c", []string{"full_name", "alias", "nationality", "dob", "gender", "risk_score"}},
{"osint_organization_go_cybersecurity", "Organization", "#3498db", []string{"legal_name", "country", "sector", "founded", "risk_score"}},
{"osint_crypto_wallet_go_cybersecurity", "Crypto Wallet", "#f39c12", []string{"address", "blockchain", "balance", "first_seen", "last_seen"}},
{"osint_ip_address_go_cybersecurity", "IP Address", "#2ecc71", []string{"ip", "asn", "country", "isp", "geolocation", "last_seen"}},
{"osint_domain_go_cybersecurity", "Domain", "#9b59b6", []string{"fqdn", "registrar", "created_date", "expires_date", "name_servers"}},
{"osint_email_go_cybersecurity", "Email", "#1abc9c", []string{"address", "provider", "verified", "breached"}},
{"osint_phone_go_cybersecurity", "Phone", "#e67e22", []string{"number", "country_code", "carrier", "phone_type"}},
{"osint_malware_go_cybersecurity", "Malware", "#c0392b", []string{"family", "hash_sha256", "first_seen", "last_seen", "threat_level"}},
{"osint_vulnerability_go_cybersecurity", "Vulnerability", "#8e44ad", []string{"cve_id", "cvss", "affected_product", "published", "exploited"}},
{"osint_social_media_go_cybersecurity", "Social Media", "#2980b9", []string{"platform", "username", "url", "followers", "verified"}},
{"osint_document_go_cybersecurity", "Document", "#7f8c8d", []string{"title", "format", "classification", "hash_sha256", "source"}},
{"osint_event_go_cybersecurity", "Event", "#d35400", []string{"event_type", "date", "location", "description", "severity"}},
{"osint_location_go_cybersecurity", "Location", "#27ae60", []string{"lat", "lon", "address", "country", "city"}},
}
var relationPresets = []string{
"funds", "employs", "communicates_with", "owns", "operates",
"controls", "affiliated_with", "located_at", "resolves_to",
"registered_by", "hosts", "exploits", "attributed_to", "related_to",
}