Stride support (#624)

This commit is contained in:
kazuminn
2018-04-10 13:30:22 +09:00
committed by Kota Kanbe
parent 5076326589
commit 7a1644135a
5 changed files with 118 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ type Config struct {
EMail SMTPConf
Slack SlackConf
Stride StrideConf
HipChat HipChatConf
Syslog SyslogConf
Default ServerInfo
@@ -129,6 +130,7 @@ type Config struct {
RefreshCve bool
ToSlack bool
ToStride bool
ToHipChat bool
ToEmail bool
ToSyslog bool
@@ -277,6 +279,10 @@ func (c Config) ValidateOnReport() bool {
errs = append(errs, hipchaterrs...)
}
if strideerrs := c.Stride.Validate(); 0 < len(strideerrs) {
errs = append(errs, strideerrs...)
}
if syslogerrs := c.Syslog.Validate(); 0 < len(syslogerrs) {
errs = append(errs, syslogerrs...)
}
@@ -416,6 +422,33 @@ func (c *SMTPConf) Validate() (errs []error) {
return
}
// StrideConf is stride config
type StrideConf struct {
HookURL string `json:"hook_url"`
AuthToken string `json:"AuthToken"`
}
// Validate validates configuration
func (c *StrideConf) Validate() (errs []error) {
if !Conf.ToStride {
return
}
if len(c.HookURL) == 0 {
errs = append(errs, fmt.Errorf("stride.HookURL must not be empty"))
}
if len(c.AuthToken) == 0 {
errs = append(errs, fmt.Errorf("stride.AuthToken must not be empty"))
}
_, err := valid.ValidateStruct(c)
if err != nil {
errs = append(errs, err)
}
return
}
// SlackConf is slack config
type SlackConf struct {
HookURL string `valid:"url" json:"-"`