utils

package
v0.0.0-...-e6d3209 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//diss-backend code 0-200
	Fail                            = 1
	GetHostListErr                  = 2
	AddHostErr                      = 3
	DeleteHostErr                   = 4
	GetHostZero                     = 5
	HostExistError                  = 6
	GetHostMetricError              = 7
	EditHostErr                     = 8
	SiginErr                        = 17
	AuthorizeErr                    = 18
	GetUserInfoErr                  = 19
	ElasticConnErr                  = 21
	ElasticSearchErr                = 22
	AddSYSTemplateErr               = 23
	GetSYSTemplateErr               = 24
	AddBenchMarkLogErr              = 25
	GetBenchMarkLogErr              = 26
	GetHostPsErr                    = 27
	AddHostPsErr                    = 28
	EditHostInfoErr                 = 29
	GetHostInfoErr                  = 30
	AddHostConfigErr                = 31
	EditHostConfigErr               = 32
	GetHostConfigErr                = 33
	EditContainerConfigErr          = 34
	AddImageConfigErr               = 35
	GetImageConfigErr               = 36
	AddContainerConfigErr           = 37
	GetContainerConfigErr           = 38
	EditImageConfigErr              = 39
	EditHostPsErr                   = 40
	GetContainerInfoErr             = 41
	AddContainerInfoErr             = 42
	EditContainerInfoErr            = 43
	DeleteHostPsErr                 = 44
	DeleteContainerInfoErr          = 45
	GetContainerPsErr               = 46
	AddContainerPsErr               = 47
	EditContainerPsErr              = 48
	DeleteContainerPsErr            = 49
	AddImageInfoErr                 = 50
	GetImageInfoErr                 = 51
	GetCmdHistoryErr                = 52
	AddCmdHistoryErr                = 53
	DeleteCmdHistoryErr             = 54
	DeleteImageInfoErr              = 55
	DeleteImageConfigErr            = 56
	AddGroupErr                     = 57
	GetGroupErr                     = 58
	EditGroupErr                    = 59
	DeleteGroupErr                  = 60
	GetAccountClusterErr            = 61
	NoccountClusterErr              = 62
	AddAccountClusterErr            = 63
	DeleteContainerConfigErr        = 64
	ContainerConfigNotFoundErr      = 65
	EmptyDirtyDataContinerConfigErr = 66
	EmptyDirtyDataContinerInfoErr   = 67
	EmptyDirtyDataNameSpaceErr      = 68
	EmptyDirtyDataPodErr            = 69
	BindContainerErr                = 70
	UnBindContainerErr              = 71
	DeleteSYSTemplateErr            = 72
	EditSYSTemplateErr              = 73
	GetJobErr                       = 74
	AddJobErr                       = 75
	DeleteJobErr                    = 76
	AddSYSTemplateGroupErr          = 77
	GetSYSTemplateGroupErr          = 78
	DeleteSYSTemplateGroupErr       = 79
	EditSYSTemplateGroupErr         = 80
	ResourceNotFoundErr             = 81
	HostConfigNotFoundErr           = 82
	EditHostInfoDynamicErr          = 83
	EditHostConfigDynamicErr        = 84
	RelationJobHostErr              = 85
	RelationJobContainerErr         = 86
	EditJobErr                      = 87
	JobCommitErr                    = 88
	DeleteHostConfigErr             = 89
	DeleteHostinfoErr               = 90
	HostExistInJobErr               = 91
	ContainerExistInJobErr          = 92
	GetSYSJobErr                    = 93
	GetLatestTimeForCmdHistoryErr   = 94
	GetServiceErr                   = 95
	AddServiceErr                   = 96
	EditServiceErr                  = 97
	DeleteServiceErr                = 98
	GetLatestTimeForDockerEventErr  = 99
	OpenFileErr                     = 100
	UserAndPwdNotNull               = 101
	DeleteFileErr                   = 102
	AddHostPackageErr               = 103
	GetHostPackageErr               = 104
	DeleteHostPackageErr            = 105
	MailServerNotAvaiableErr        = 106
	LDAPIsDisabledErr               = 107
	LDAPLoginErr                    = 108
	MailServerNotAvaiable           = 109
	GetImageVulnStatisticsErr       = 110
	GetImageVulnErr                 = 111
	GetImageContentErr              = 112
	GetImageMetadataErr             = 113
	GetImageSensitivenfoErr         = 114
	NotEnoughParametersErr          = 115
	AddImageVulnerabilitiesErr      = 116
	GetImageVulnerabilitiesErr      = 117
	DeleteImageVulnerabilitiesErr   = 118
	AddVulnerabilitiesErr           = 119
	GetVulnerabilitiesErr           = 120
	AddImageBlockingErr             = 121
	GetImageBlockingErr             = 122
	LoginTypeErr                    = 123
	ParseKubeVulnRawLogErr          = 124
	AddKubeScanErr                  = 125
	AddKubeVulnerabilitiesErr       = 126
	GetKubeScanErr                  = 127
	DeleteKubeScanErr               = 128
	GetImageVirusErr                = 129
	AddRegistryErr                  = 130
	GetRegistryErr                  = 131
	DeleteRegistryErr               = 132
	TestLinkRegistryErr             = 133
	GetNamespacesErr                = 134
	ImportImageErr                  = 135
	DeleteImageDetailErr            = 136
	AddDockerVulnErr                = 137
	GetDockerVulnErr                = 138
	DeleteDockerVulnErr             = 139
	UpdateRegistryErr               = 140
	GetVersionErr                   = 141
	AddVersionErr                   = 142
	AddRoleErr                      = 143
	EditRoleErr                     = 144
	GetRoleErr                      = 145
	DeleteRoleErr                   = 146
	AddUserErr                      = 147
	EditUserErr                     = 148
	GetUserErr                      = 149
	DeleteUserErr                   = 150
	AddModuleErr                    = 151
	EditModuleErr                   = 152
	GetModuleErr                    = 153
	DeleteModuleErr                 = 154
	AddPolicyErr                    = 155
	RemovePolicyErr                 = 156
	UserExistErr                    = 157
	AddUserToRoleErr                = 158
	ChangeUserInRoleErr             = 159
	RemoveUserFromRoleErr           = 160
	AddRoleForUserErr               = 161
	ChangeRoleForUserErr            = 162
	RemoveRoleForUserErr            = 163
	SYSTemplateExistErr             = 164
	PasswordLengthErr               = 165
	RoleExistErr                    = 166
	PasswordFormatErr               = 167
	DeleteInbuildRoleErr            = 168
	UsernameOrPasswordErr           = 169

	//k8s 1001-1100
	AddNameSpaceErr                  = 1001
	AddPodErr                        = 1002
	AddClusterErr                    = 1003
	GetClusterErr                    = 1004
	GetPodErr                        = 1005
	EditNameSpaceErr                 = 1006
	EditPodErr                       = 1007
	GetNameSpaceErr                  = 1008
	IsBindErr                        = 1009
	NoNameSpacedErr                  = 1010
	NameSpaceExistErr                = 1011
	BindNameSpaceErr                 = 1012
	UnBindNameSpaceErr               = 1013
	BindPodErr                       = 1014
	UnBindPodErr                     = 1015
	EditClusterErr                   = 1006
	ClusterIsExistErr                = 1007
	DeleteNameSpaceErr               = 1008
	DeletePodErr                     = 1009
	DeleteClusterErr                 = 1010
	ClusterNoExistErr                = 1011
	ClusterNotActiveOrNotvailableErr = 1012
	ClusterIsSyncingOrIsClearingErr  = 1013
	GetDeploymentErr                 = 1014
	AddDeploymentErr                 = 1015
	EditDeploymentErr                = 1016
	DeleteDeploymentErr              = 1017
	GetNetworkPolicyErr              = 1018
	AddNetworkPolicyErr              = 1019
	EditNetworkPolicyErr             = 1020
	DeleteNetworkPolicyErr           = 1021
	GetHostListForClusterErr         = 1022
	GetSsopeYmlErr                   = 1023
	AnalysisSsopeYmlErr              = 1024
	InstallSsopeErr                  = 1025
	CretaeResourceError              = 1026
	NetworkPolicyExistErr            = 1027
	NotFoundHostForClusterErr        = 1028
	UpdateNetworkPolicyErr           = 1029
	ForbidenModifyUserErr            = 1030
	ForbidenRemoveUserErr            = 1031
	ForbidenCreateUserErr            = 1032
	ForbidenAdminDelSelfErr          = 1033
	ForbiddenRoleRemoveErr           = 1034

	//task job 1100-1200
	AddTaskErr        = 1100
	GetTaskErr        = 1101
	DeleteTaskErr     = 1102
	EditTaskErr       = 1103
	JobIsDisabledErr  = 1104
	TaskIsRunningWarn = 1105
	TaskCommitErr     = 1106
	TaskNotExistErr   = 1107

	//system 1200-1300
	CheckK8sFilePostErr             = 1200
	CheckK8sFileCreateClientErr     = 1201
	CheckK8sFileIsExistErr          = 1202
	UploadK8sFileErr                = 1203
	CreateClientByKubeConfigErr     = 1204
	UploadLogoErr                   = 1205
	ChecLogoPostErr                 = 1206
	CheckLogoIsNotExistErr          = 1207
	CheckLicenseFilePostErr         = 1208
	CheckLicenseFileCreateClientErr = 1209
	CheckLicenseFileIsExistErr      = 1210
	ImportLicenseFileErr            = 1211
	LicenseUnmarshalErr             = 1212
	LicenseBase64DecodeErr          = 1213
	EditLicenseErr                  = 1214
	SaveLicenseFileErr              = 1215
	AddLicenseHistoryErr            = 1216
	GetLicenseHistoryErr            = 1217
	DeleteLicenseModuleErr          = 1218
	LicenseCommitErr                = 1219
	CreateClientByBearerTokenErr    = 1220
	ClusterNotAvailableOrNoHostErr  = 1221
	CreateK8sClientErr              = 1222
	GetLicenseFileErr               = 1223
	NoLicenseFileErr                = 1224
	ConnectSyslogErr                = 1225
	AddLogConfigErr                 = 1226
	GetLogConfigErr                 = 1227
	EditLogConfigErr                = 1228
	AddTimeEdgePointErr             = 1229
	GetTimeEdgePointErr             = 1230
	EditTimeEdgePointErr            = 1231
	AddSysConfigErr                 = 1232
	GetSysConfigErr                 = 1233
	EditSysConfigErr                = 1234
	LicenseHostCountErr             = 1235
	GetLicenseDataErr               = 1236
	LicenseExpiredErr               = 1237
	LicenseFCodeErr                 = 1238
	LicenseHostErr                  = 1239
	LDAPConnErr                     = 1240
	AddWarningWhiteListErr          = 1241
	EditWarningWhiteListErr         = 1242
	GetWarningWhiteListErr          = 1243
	DeleteWarningWhiteListErr       = 1244
	GetRespCenterErr                = 1245
	AddRespCenterErr                = 1246
	UpdateRespCenterErr             = 1247
	CheckLogConfigErr               = 1248
	UploadWarnWhitelistErr          = 1249
	ImportWarnWhitelistErr          = 1250
	WarnWhitelistUnmarshalErr       = 1251
	CheckFilePostErr                = 1252
	CheckFileTypeErr                = 1253
	AddRuleDefineErr                = 1254
	EditRuleDefineErr               = 1255
	GetRuleDefineErr                = 1256
	DeleteRuleDefineErr             = 1257
	AddVulnerabilityLibErr          = 1258
	EditVulnerabilityLibErr         = 1259
	GetVulnerabilityLibErr          = 1260
	DeleteVulnerabilityLibErr       = 1261
	RestoreDefaultLogoErr           = 1262
	ParameterParseErr               = 1263
	RuleDefineDuplicate             = 1264
	DeleteRespCenterErr             = 1265

	// timescaledb 安全日志1300-1400
	GetIntrudeDetectLogErr = 1300
	AddTaskLogErr          = 1301
	GetTaskLogErr          = 1302
	GetDockerEventListErr  = 1303
	AddDockerEventErr      = 1304
	AddUserEventErr        = 1305
	GetUserEventListErr    = 1306
	GetWarningInfoListErr  = 1307
	AddWarningInfoListErr  = 1308
	UpdateWarningInfoErr   = 1309
	AddVirusLogErr         = 1310
	AddImageDetailErr      = 1311
	GetImageDetailErr      = 1312
	AddSensitiveInfoErr    = 1311
)
View Source
var (
	// default postgres
	Host                  = "host"
	HostConfig            = "host_config"
	HostInfo              = "host_info"
	Cluster               = "cluster"
	NameSpace             = "name_space"
	Pod                   = "pod"
	ImageConfig           = "image_config"
	ImageInfo             = "image_info"
	ImageBlocking         = "image_blocking"
	ContainerConfig       = "container_config"
	ContainerInfo         = "container_info"
	ContainerInspect      = "container_inspect"
	ContainerPs           = "container_ps"
	Task                  = "task"
	SYSTemplate           = "system_template"
	SYSTemplateGroup      = "system_template_group"
	BenchMarkLog          = "bench_mark_log"
	HostPs                = "host_ps"
	Groups                = "groups"
	Job                   = "job"
	LogConfig             = "log_config"
	TimeEdgePoint         = "time_edge_point"
	LicenseConfig         = "license_config"
	LicenseModule         = "license_module"
	LicenseHistory        = "license_history"
	Service               = "service"
	Deployment            = "deployment"
	NetworkPolicy         = "network_policy"
	SysConfig             = "sys_config"
	WarningWhiteList      = "warning_white_list"
	RespCenter            = "resp_center"
	ImageVulnerabilities  = "image_vulnerabilities"
	Vulnerabilities       = "vulnerabilities"
	KubeScan              = "kube_scan"
	KubeVulnerabilities   = "kube_vulnerabilities"
	RuleDefine            = "rule_define"
	Registry              = "registry"
	VulnerabiltyLib       = "vulnerability_lib"
	DockerVulnerabilities = "docker_vulnerabilities"
	Version               = "version"
	Role                  = "role"
	User                  = "user"
	Module                = "module"

	//security_log timescaledb
	DcokerIds     = "docker_ids"
	TaskLog       = "task_log"
	CmdHistory    = "cmd_history"
	DockerEvent   = "docker_event"
	UserEvent     = "user_event"
	WarningInfo   = "warning_info"
	HostPackage   = "host_package"
	VirusScan     = "virus_scan"
	VirusRecord   = "virus_record"
	ImageDetail   = "image_detail"
	SensitiveInfo = "sensitive_info"

	//Diss_api
	Accounts                    = "accounts"
	AccountUsers                = "account_users"
	ImageVirus                  = "image_virus"
	DockerVirus                 = "docker_virus"
	ImagePackageVulnerabilities = "image_package_vulnerabilities"
	FeedDataVulnerabilities     = "feed_data_vulnerabilities"
	Feeds                       = "feeds"
	UserAccessCredentials       = "user_access_credentials"
)
View Source
var (
	// 数据库 ---- 数据源(和app.config 文件中的必须对应)
	DS_Default      = "default"
	DS_Security_Log = "security_log"
	// 数据库 ----数据库驱动
	DS_Driver_Postgres = "postgres"
)

Functions

func CheckLengthAndChars

func CheckLengthAndChars(srcString string, minLen, maxLen int, avaChars string) bool

func ComparePassword

func ComparePassword(password, hash string) (bool, error)

ComparePassword is used to compare a user-inputted password to a hash to see

func ConvertType

func ConvertType(from interface{}, to interface{}) error

func FormatFileSize

func FormatFileSize(fileSize int64) (size string)

func GenRandomString

func GenRandomString(n int) string

func GeneratePassword

func GeneratePassword(c *PasswordConfig, password string) (string, error)

GeneratePassword is used to generate a new password hash for storing and

func GenerateRSAKey

func GenerateRSAKey(bits int)

生成RSA私钥和公钥,保存到文件中

func GetAgentPath

func GetAgentPath() string

func GetAgentUrl

func GetAgentUrl() string

func GetConn

func GetConn(DSAlias string) string

func GetDBCountSql

func GetDBCountSql(hostId string) string

func GetDefaultLogoName

func GetDefaultLogoName() string

func GetHTTPSAddr

func GetHTTPSAddr() string

func GetHTTPSPort

func GetHTTPSPort() string

func GetHostInfo

func GetHostInfo() *host.InfoStat

func GetHostMarkSummarySql

func GetHostMarkSummarySql(hostId string) string

func GetKubeScanEnvClusterIdKey

func GetKubeScanEnvClusterIdKey() string

func GetKubeScanEnvDisPatchUrlKey

func GetKubeScanEnvDisPatchUrlKey() string

func GetKubeScanEnvTaskIdKey

func GetKubeScanEnvTaskIdKey() string

func GetKubeScanReportApi

func GetKubeScanReportApi() string

func GetKubeScanReportUrl

func GetKubeScanReportUrl() string

func GetKubeScanYml

func GetKubeScanYml() string

func GetLogoName

func GetLogoName() string

func GetLogoPath

func GetLogoPath() string

func GetLogoUrl

func GetLogoUrl() string

func GetMarkSummarySql

func GetMarkSummarySql(BMLT string) string

func GetNatsClientId

func GetNatsClientId() string

func GetNatsClusterId

func GetNatsClusterId() string

func GetNatsServerUrl

func GetNatsServerUrl() string

*

  • @serverUrl nats://diss:diss@111.229.167.6:4222

func GetProbeDriverPath

func GetProbeDriverPath() string

func GetProbeDriverUrl

func GetProbeDriverUrl() string

func GetPublicPath

func GetPublicPath() string

func GetPublicUrl

func GetPublicUrl() string

func GetRoleString

func GetRoleString(s string) string

这个方法在Name字段加个前缀role_

func GetScopeAppName

func GetScopeAppName() string

func GetScopeNameSpace

func GetScopeNameSpace() string

func GetScopeYml

func GetScopeYml() string

func GetSystemIP

func GetSystemIP() string

func GetVirusPath

func GetVirusPath() string

func GetVirusrUrl

func GetVirusrUrl() string

func GetVulnDbPath

func GetVulnDbPath() string

func GetVulnDbUrl

func GetVulnDbUrl() string

func GetWarnWhitelistPath

func GetWarnWhitelistPath() string

func IgnoreLastInsertIdErrForPostgres

func IgnoreLastInsertIdErrForPostgres(err error) error

func IgnoreQuerySeterNoRowFoundErrForPostgres

func IgnoreQuerySeterNoRowFoundErrForPostgres(err error) error

func InitTable

func InitTable(table string, sql string) (pre string)

func IoutilReadFile

func IoutilReadFile(filename string) string

func IoutilWriteFile

func IoutilWriteFile(filename, content string)

func IsEnableNats

func IsEnableNats() bool

func MD5

func MD5(s string) string

func RSA_Decrypt

func RSA_Decrypt(cipherText []byte, path string) []byte

RSA解密

func RSA_Encrypt

func RSA_Encrypt(plainText []byte, path string) []byte

RSA加密

func ToIndentJSON

func ToIndentJSON(obj interface{}) (string, error)

func UnitConvert

func UnitConvert(size int64) string

Types

type EndpointPattern

type EndpointPattern struct {
	Endpoints []*endpoint `json:"endpoints"`
}

func ACRRegion

func ACRRegion() *EndpointPattern

func AWSRegion

func AWSRegion() *EndpointPattern

func DockerHubRegion

func DockerHubRegion() *EndpointPattern

func GoogleRegion

func GoogleRegion() *EndpointPattern

func SWRRegion

func SWRRegion() *EndpointPattern

type PasswordConfig

type PasswordConfig struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL