Documentation ¶
Index ¶
- Constants
- Variables
- func BoolArrayToInterfaceArray(a []bool) []interface{}
- func CheckKafkaConn(kafkaBrokers []string) error
- func CreateMissingTopics(kafkaBrokers []string, topics []string, partitions int32, replicas int16, ...) error
- func CritialTaskOpts(opts ...asynq.Option) []asynq.Option
- func DefaultTaskOpts(opts ...asynq.Option) []asynq.Option
- func ExecuteCommand(commandStr string, envVars map[string]string) (string, error)
- func FileExists(name string) bool
- func FromMap(bb map[string]interface{}, c interface{})
- func GenerateHashFromString(s string) string
- func GenerateRandomNumber(numberOfDigits int) (int64, error)
- func GetCurrentDatetime() time.Time
- func GetCustomerNamespace(s string) (string, error)
- func GetDatetimeNow() string
- func GetEmailDomain(email string) (string, error)
- func GetEnvOrDefault(envVar string, defaultValue string) string
- func GetEnvOrDefaultInt(envVar string, defaultValue int) int
- func GetErrorRedirectUrl(consoleUrl, errorMessage string) string
- func GetHttpClient() *http.Client
- func GetInfoRedirectUrl(consoleUrl, message string) string
- func GetInsecureHttpClient() *http.Client
- func GetInt64ValueFromInterfaceMap(claims map[string]interface{}, key string) (int64, error)
- func GetScheduledJobHash(schedule postgresqlDb.Scheduler) string
- func GetStringValueFromInterfaceMap(claims map[string]interface{}, key string) (string, error)
- func GetTimestamp() int64
- func InSlice[T comparable](e T, s []T) bool
- func InterfaceToInt(a interface{}) (int64, error)
- func IsJWTExpired(token string) bool
- func IsUUIDValid(uuidStr string) bool
- func LowTaskOpts(opts ...asynq.Option) []asynq.Option
- func MapKeys(input map[string]string) []int32
- func NewHTTPClient() (*http.Client, error)
- func NewUUID() uuid.UUID
- func NewUUIDString() string
- func RandomString(nByte int) (string, error)
- func RecursiveZip(pathsToZip []string, excludePathPrefixes []string, destinationPath string) error
- func RemoveURLPath(inUrl string) (string, error)
- func ResourceTypeToNeo4jLabel(t CloudProvider) string
- func SHA256sum(data []byte) string
- func SetCookie(w http.ResponseWriter, r *http.Request, name, value, path string)
- func SplitFullName(name string) (string, string)
- func StartKafkaProducer(ctx context.Context, brokers []string, ingestChan chan *kgo.Record)
- func StringArrayToInterfaceArray(a []string) []interface{}
- func StripAnsi(str []byte) []byte
- func StripAnsiStr(str string) string
- func StructToMap[T any](c T) map[string]interface{}
- func TaskOptions(queue string, opts ...asynq.Option) []asynq.Option
- func TasksMaxRetries() asynq.Option
- func ToMap[T any](c T) map[string]interface{}
- func ToSnakeCase(str string) string
- func URLDecode(s string) (string, error)
- func URLEncode(s string) string
- func UUIDFromString(uuidStr string) (uuid.UUID, error)
- func UploadFile(url string, fileName string) ([]byte, int, error)
- func ValidateEmail(email string) bool
- func WaitServiceTcpConn(host string, port string, timeout time.Duration) error
- type AdvancedReportFilters
- type AgentID
- type CloudProvider
- type MalwareScanParameters
- type MinioError
- type Neo4jScanType
- type RegistrySyncParams
- type ReportFilters
- type ReportParams
- type ReportType
- type SbomBody
- type SbomParameters
- type ScanSbomRequest
- type SecretScanParameters
Constants ¶
View Source
const ( DefaultTaskMaxRetries = 3 Q_CRITICAL = "critical" Q_DEFAULT = "default" Q_LOW = "low" )
View Source
const ( AUDIT_LOGS = "audit-logs" VULNERABILITY_SCAN = "vulnerability-scan" VULNERABILITY_SCAN_STATUS = "vulnerability-scan-status" SECRET_SCAN = "secret-scan" SECRET_SCAN_STATUS = "secret-scan-status" MALWARE_SCAN = "malware-scan" MALWARE_SCAN_STATUS = "malware-scan-status" SBOM_ARTIFACTS = "sbom-artifact" SBOM_CVE_SCAN = "sbom-cve-scan" CLOUD_COMPLIANCE_SCAN = "cloud-compliance-scan" CLOUD_COMPLIANCE_SCAN_STATUS = "cloud-compliance-scan-status" COMPLIANCE_SCAN = "compliance-scan" COMPLIANCE_SCAN_STATUS = "compliance-scan-status" CLOUD_TRAIL_ALERTS = "cloudtrail-alert" CLOUD_RESOURCE = "cloud-resource" )
kafka topics
View Source
const ( CleanUpGraphDBTask = "clean_up_graph_db" CleanUpPostgresqlTask = "clean_up_postgresql" CleanupDiagnosisLogs = "clean_up_diagnosis_logs" RetryFailedScansTask = "retry_failed_scans" RetryFailedUpgradesTask = "retry_failed_upgrades" ScanSBOMTask = "tasks_scan_sbom" GenerateSBOMTask = "tasks_generate_sbom" CheckAgentUpgradeTask = "tasks_check_agent_upgrade" SyncRegistryTask = "task_sync_registry" TriggerConsoleActionsTask = "trigger_console_actions" ScheduledTasks = "scheduled_tasks" SecretScanTask = "task_secret_scan" MalwareScanTask = "task_malware_scan" ReportGeneratorTask = "tasks_generate_report" ComputeThreatTask = "compute_threat" SendNotificationTask = "tasks_send_notification" CloudComplianceTask = "cloud_compliance" CachePostureProviders = "cache_posture_providers" ReportCleanUpTask = "tasks_cleanup_reports" LinkCloudResourceTask = "link_cloud_resource" LinkNodesTask = "link_nodes" StopSecretScanTask = "task_stop_secret_scan" StopMalwareScanTask = "task_stop_malware_scan" StopVulnerabilityScanTask = "task_stop_vulnerability_scan" UpdateCloudResourceScanStatusTask = "update_cloud_resource_scan_status" UpdatePodScanStatusTask = "update_pod_scan_status" )
task names
View Source
const ( SCAN_STATUS_SUCCESS = "COMPLETE" SCAN_STATUS_STARTING = "STARTING" SCAN_STATUS_INPROGRESS = "IN_PROGRESS" SCAN_STATUS_FAILED = "ERROR" SCAN_STATUS_CANCEL_PENDING = "CANCEL_PENDING" SCAN_STATUS_CANCELLING = "CANCELLING" SCAN_STATUS_CANCELLED = "CANCELLED" )
View Source
const ( NodeTypeCloudProvider = "CloudProvider" NodeTypeCloudRegion = "CloudRegion" NodeTypeKubernetesCluster = "KubernetesCluster" NodeTypeContainerImage = "ContainerImage" NodeTypeHost = "Node" NodeTypeContainer = "Container" NodeTypePod = "Pod" NodeTypeProcess = "Process" NodeTypeCloudNode = "CloudNode" NodeTypeCloudResource = "CloudResource" NodeTypeRegistryAccount = "RegistryAccount" )
Neo4j Node Labels
View Source
const ( MASK_GLOBAL = "mask_global" MASK_ALL_IMAGE_TAG = "mask_all_image_tag" MASK_ENTITY = "mask_entity" MASK_IMAGE_TAG = "mask_image_tag" )
View Source
const (
ErrorUserNotFound = "user not found"
)
View Source
const (
Project = "ThreatMapper"
)
Variables ¶
View Source
var ( ScanTypeDetectedNode = map[Neo4jScanType]string{ NEO4J_VULNERABILITY_SCAN: "Vulnerability", NEO4J_SECRET_SCAN: "Secret", NEO4J_MALWARE_SCAN: "Malware", NEO4J_COMPLIANCE_SCAN: "Compliance", NEO4J_CLOUD_COMPLIANCE_SCAN: "CloudCompliance", } DetectedNodeScanType = map[string]Neo4jScanType{ "Vulnerability": NEO4J_VULNERABILITY_SCAN, "Secret": NEO4J_SECRET_SCAN, "Malware": NEO4J_MALWARE_SCAN, "Compliance": NEO4J_COMPLIANCE_SCAN, "CloudCompliance": NEO4J_CLOUD_COMPLIANCE_SCAN, } )
View Source
var (
KgoLogger kgo.Logger = kgo.BasicLogger(log.NewIOWriter(zerolog.InfoLevel), kgo.LogLevelInfo, nil)
)
kafka client logger
View Source
var ScanIdReplacer = strings.NewReplacer("/", "_", ":", "_", ".", "_")
View Source
var Tasks = []string{ CleanUpGraphDBTask, CleanUpPostgresqlTask, CleanupDiagnosisLogs, RetryFailedScansTask, RetryFailedUpgradesTask, ScanSBOMTask, GenerateSBOMTask, CheckAgentUpgradeTask, SyncRegistryTask, TriggerConsoleActionsTask, ScheduledTasks, SecretScanTask, MalwareScanTask, ReportGeneratorTask, ComputeThreatTask, SendNotificationTask, CloudComplianceTask, CachePostureProviders, ReportCleanUpTask, LinkCloudResourceTask, LinkNodesTask, StopSecretScanTask, StopMalwareScanTask, StopVulnerabilityScanTask, UpdateCloudResourceScanStatusTask, UpdatePodScanStatusTask, }
list of task names to create topics
View Source
var Topics = []string{ VULNERABILITY_SCAN, VULNERABILITY_SCAN_STATUS, SECRET_SCAN, SECRET_SCAN_STATUS, MALWARE_SCAN, MALWARE_SCAN_STATUS, SBOM_ARTIFACTS, SBOM_CVE_SCAN, CLOUD_COMPLIANCE_SCAN, CLOUD_COMPLIANCE_SCAN_STATUS, COMPLIANCE_SCAN, COMPLIANCE_SCAN_STATUS, CLOUD_TRAIL_ALERTS, AUDIT_LOGS, CLOUD_RESOURCE, }
Functions ¶
func BoolArrayToInterfaceArray ¶
func BoolArrayToInterfaceArray(a []bool) []interface{}
func CheckKafkaConn ¶
func CreateMissingTopics ¶
func ExecuteCommand ¶
func FileExists ¶
func FromMap ¶
func FromMap(bb map[string]interface{}, c interface{})
FromMap Convert map[string]interface{} into structs e.g:
type Titi struct { Tata string `json:"tata"` } type Toto struct { Foo string `json:"foo"` Bar int `json:"bar"` Ta Titi `json:"ta"` Tas []Titi `json:"tas"` Tass []string `json:"tass"` } m := map[string]interface{}{ "foo": "toto", "bar": 42, "ta": map[string]interface{}{"tata": "ok"}, "tas": []map[string]interface{}{{"tata": "ok2"}, {"tata": "ok1"}}, "tass": []string{"a"}, }
var t Toto FromMap(m, &t)
func GenerateHashFromString ¶
func GenerateRandomNumber ¶
func GetCurrentDatetime ¶
func GetCustomerNamespace ¶
func GetDatetimeNow ¶
func GetDatetimeNow() string
func GetEmailDomain ¶
func GetEnvOrDefault ¶
func GetEnvOrDefaultInt ¶
func GetErrorRedirectUrl ¶
func GetHttpClient ¶
func GetInfoRedirectUrl ¶
func GetInsecureHttpClient ¶
func GetScheduledJobHash ¶
func GetScheduledJobHash(schedule postgresqlDb.Scheduler) string
func GetTimestamp ¶
func GetTimestamp() int64
func InSlice ¶
func InSlice[T comparable](e T, s []T) bool
func InterfaceToInt ¶
func IsJWTExpired ¶
func IsUUIDValid ¶
func NewHTTPClient ¶
func NewUUIDString ¶
func NewUUIDString() string
func RandomString ¶
func RecursiveZip ¶
func RemoveURLPath ¶
func ResourceTypeToNeo4jLabel ¶
func ResourceTypeToNeo4jLabel(t CloudProvider) string
func SplitFullName ¶
func StartKafkaProducer ¶
func StringArrayToInterfaceArray ¶
func StringArrayToInterfaceArray(a []string) []interface{}
func StripAnsiStr ¶
StripAnsiStr remove ansi color from log lines
func StructToMap ¶
func TasksMaxRetries ¶
func ToSnakeCase ¶
func ValidateEmail ¶
Types ¶
type AdvancedReportFilters ¶
type AdvancedReportFilters struct { Masked []bool `json:"masked,omitempty"` ScanStatus []string `json:"scan_status,omitempty"` PodName []string `json:"pod_name,omitempty"` ContainerName []string `json:"container_name,omitempty"` ImageName []string `json:"image_name,omitempty"` HostName []string `json:"host_name,omitempty"` AccountId []string `json:"account_id,omitempty"` KubernetesClusterName []string `json:"kubernetes_cluster_name,omitempty"` }
type CloudProvider ¶
type CloudProvider int
const ( AWS CloudProvider = iota GCP Azure DO AWSOrg GCPOrg )
func StringToCloudProvider ¶
func StringToCloudProvider(s string) CloudProvider
type MalwareScanParameters ¶
type MalwareScanParameters struct { ImageName string `json:"image_name"` ImageId string `json:"image_id"` ScanId string `json:"scan_id" required:"true"` KubernetesClusterName string `json:"kubernetes_cluster_name"` HostName string `json:"host_name"` NodeId string `json:"node_id"` NodeType string `json:"node_type"` ScanType string `json:"scan_type"` ContainerName string `json:"container_name"` Mode string `json:"mode,omitempty"` RegistryId string `json:"registry_id,omitempty"` }
type MinioError ¶
type MinioError struct { XMLName xml.Name `xml:"Error"` Text string `xml:",chardata"` Code string `xml:"Code"` Message string `xml:"Message"` Key string `xml:"Key"` BucketName string `xml:"BucketName"` Resource string `xml:"Resource"` RequestId string `xml:"RequestId"` HostId string `xml:"HostId"` }
type Neo4jScanType ¶
type Neo4jScanType string
const ( NEO4J_SECRET_SCAN Neo4jScanType = "SecretScan" NEO4J_VULNERABILITY_SCAN Neo4jScanType = "VulnerabilityScan" NEO4J_MALWARE_SCAN Neo4jScanType = "MalwareScan" NEO4J_COMPLIANCE_SCAN Neo4jScanType = "ComplianceScan" NEO4J_CLOUD_COMPLIANCE_SCAN Neo4jScanType = "CloudComplianceScan" )
func StringToNeo4jScanType ¶
func StringToNeo4jScanType(s string) Neo4jScanType
type RegistrySyncParams ¶
type RegistrySyncParams struct {
PgID int32 `json:"pg_id"`
}
type ReportFilters ¶
type ReportFilters struct { ScanId string `json:"scan_id"` ScanType string `json:"scan_type" validate:"required" required:"true" enum:"vulnerability,secret,malware,compliance,cloud_compliance"` NodeType string `json:"node_type" validate:"required" required:"true" enum:"host,container,container_image,linux,cluster,aws,gcp,azure"` SeverityOrCheckType []string `json:"severity_or_check_type" enum:"critical,high,medium,low,cis,gdpr,nist,hipaa,pci,soc_2"` IncludeDeadNode bool `json:"include_dead_nodes"` MostExploitableReport bool `json:"most_exploitable_report"` AdvancedReportFilters AdvancedReportFilters `json:"advanced_report_filters,omitempty"` }
func (ReportFilters) String ¶
func (r ReportFilters) String() string
type ReportParams ¶
type ReportParams struct { ReportID string `json:"report_id"` ReportType string `json:"report_type"` Duration int `json:"duration"` Filters ReportFilters `json:"filters"` }
type ReportType ¶
type ReportType string
const ( ReportXLSX ReportType = "xlsx" ReportPDF ReportType = "pdf" )
type SbomParameters ¶
type SbomParameters struct { ImageName string `json:"image_name"` ImageId string `json:"image_id"` ScanId string `json:"scan_id" required:"true"` KubernetesClusterName string `json:"kubernetes_cluster_name"` HostName string `json:"host_name"` NodeId string `json:"node_id"` NodeType string `json:"node_type"` ScanType string `json:"scan_type"` ContainerName string `json:"container_name"` SBOMFilePath string `json:"sbom_file_path"` Mode string `json:"mode,omitempty"` RegistryId string `json:"registry_id,omitempty"` SkipScan bool `json:"skip_scan,omitempty"` }
type ScanSbomRequest ¶
type ScanSbomRequest struct { SbomParameters SbomBody }
type SecretScanParameters ¶
type SecretScanParameters struct { ImageName string `json:"image_name"` ImageId string `json:"image_id"` ScanId string `json:"scan_id" required:"true"` KubernetesClusterName string `json:"kubernetes_cluster_name"` HostName string `json:"host_name"` NodeId string `json:"node_id"` NodeType string `json:"node_type"` ScanType string `json:"scan_type"` ContainerName string `json:"container_name"` Mode string `json:"mode,omitempty"` RegistryId string `json:"registry_id,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.