Stride support (#624)
This commit is contained in:
		@@ -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:"-"`
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user