Chatwork support (#634)
This commit is contained in:
@@ -94,13 +94,14 @@ type Config struct {
|
||||
DebugSQL bool
|
||||
Lang string
|
||||
|
||||
EMail SMTPConf
|
||||
Slack SlackConf
|
||||
Stride StrideConf
|
||||
HipChat HipChatConf
|
||||
Syslog SyslogConf
|
||||
Default ServerInfo
|
||||
Servers map[string]ServerInfo
|
||||
EMail SMTPConf
|
||||
Slack SlackConf
|
||||
Stride StrideConf
|
||||
HipChat HipChatConf
|
||||
ChatWork ChatWorkConf
|
||||
Syslog SyslogConf
|
||||
Default ServerInfo
|
||||
Servers map[string]ServerInfo
|
||||
|
||||
CvssScoreOver float64
|
||||
IgnoreUnscoredCves bool
|
||||
@@ -132,6 +133,7 @@ type Config struct {
|
||||
ToSlack bool
|
||||
ToStride bool
|
||||
ToHipChat bool
|
||||
ToChatWork bool
|
||||
ToEmail bool
|
||||
ToSyslog bool
|
||||
ToLocalFile bool
|
||||
@@ -279,6 +281,10 @@ func (c Config) ValidateOnReport() bool {
|
||||
errs = append(errs, hipchaterrs...)
|
||||
}
|
||||
|
||||
if chatworkerrs := c.ChatWork.Validate(); 0 < len(chatworkerrs) {
|
||||
errs = append(errs, chatworkerrs...)
|
||||
}
|
||||
|
||||
if strideerrs := c.Stride.Validate(); 0 < len(strideerrs) {
|
||||
errs = append(errs, strideerrs...)
|
||||
}
|
||||
@@ -519,6 +525,32 @@ func (c *HipChatConf) Validate() (errs []error) {
|
||||
return
|
||||
}
|
||||
|
||||
// ChatWorkConf is ChatWork config
|
||||
type ChatWorkConf struct {
|
||||
ApiToken string `json:"ApiToken"`
|
||||
Room string `json:"Room"`
|
||||
}
|
||||
|
||||
// Validate validates configuration
|
||||
func (c *ChatWorkConf) Validate() (errs []error) {
|
||||
if !Conf.ToChatWork {
|
||||
return
|
||||
}
|
||||
if len(c.Room) == 0 {
|
||||
errs = append(errs, fmt.Errorf("chatworkcaht.room must not be empty"))
|
||||
}
|
||||
|
||||
if len(c.ApiToken) == 0 {
|
||||
errs = append(errs, fmt.Errorf("chatworkcaht.ApiToken must not be empty"))
|
||||
}
|
||||
|
||||
_, err := valid.ValidateStruct(c)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SyslogConf is syslog config
|
||||
type SyslogConf struct {
|
||||
Protocol string
|
||||
|
||||
@@ -46,6 +46,7 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
|
||||
Conf.Slack = conf.Slack
|
||||
Conf.Stride = conf.Stride
|
||||
Conf.HipChat = conf.HipChat
|
||||
Conf.ChatWork = conf.ChatWork
|
||||
Conf.Syslog = conf.Syslog
|
||||
|
||||
d := conf.Default
|
||||
|
||||
Reference in New Issue
Block a user