зеркало из https://github.com/mozilla/mig.git
Merge pull request #474 from mozilla/scribe-cleanup
Always set SourceName to 'mig-runner'
This commit is contained in:
Коммит
828dd39095
|
@ -22,14 +22,15 @@ import (
|
|||
"gopkg.in/gcfg.v1"
|
||||
)
|
||||
|
||||
const sourceName = "runner-scribe"
|
||||
|
||||
// config represents the configuration used by runner-scribe, and is read in on
|
||||
// initialization
|
||||
//
|
||||
// URL and Source are mandatory settings
|
||||
// URL is mandatory
|
||||
type config struct {
|
||||
MozDef struct {
|
||||
URL string // URL to post events to MozDef
|
||||
Source string // Source identifier for vulnerability events
|
||||
UseProxy bool // A switch to enable/disable the use of a system-configured proxy
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +79,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
for _, y := range items {
|
||||
y.SourceName = sourceName
|
||||
err = sendVulnerability(y)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -167,7 +169,6 @@ func makeVulnerability(initems []gozdef.VulnEvent, cmd mig.Command) (items []goz
|
|||
return items, err
|
||||
}
|
||||
for _, x := range el.Results {
|
||||
itemptr.SourceName = conf.MozDef.Source
|
||||
if !x.MasterResult {
|
||||
// Result was false (vulnerability did not match)
|
||||
continue
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
|
||||
type mozdef struct {
|
||||
URL string
|
||||
Source string
|
||||
UseProxy bool
|
||||
}
|
||||
|
||||
|
@ -32,13 +31,11 @@ func TestConfigParsing(t *testing.T) {
|
|||
ConfigString: `
|
||||
[mozdef]
|
||||
url = "testurl"
|
||||
source = "mozdef"
|
||||
useProxy = true
|
||||
`,
|
||||
ExpectedConfig: config{
|
||||
MozDef: mozdef{
|
||||
URL: "testurl",
|
||||
Source: "mozdef",
|
||||
UseProxy: true,
|
||||
},
|
||||
},
|
||||
|
@ -49,13 +46,11 @@ func TestConfigParsing(t *testing.T) {
|
|||
ConfigString: `
|
||||
[mozdef]
|
||||
url = "testurl"
|
||||
source = "mozdef"
|
||||
useProxy = "notbool"
|
||||
`,
|
||||
ExpectedConfig: config{
|
||||
MozDef: mozdef{
|
||||
URL: "testurl",
|
||||
Source: "mozdef",
|
||||
UseProxy: false,
|
||||
},
|
||||
},
|
||||
|
@ -101,13 +96,6 @@ func TestConfigParsing(t *testing.T) {
|
|||
conf.MozDef.URL)
|
||||
}
|
||||
|
||||
if conf.MozDef.Source != testCase.ExpectedConfig.MozDef.Source {
|
||||
t.Errorf(
|
||||
"Expected parsed Source to be %s but it's %s",
|
||||
testCase.ExpectedConfig.MozDef.Source,
|
||||
conf.MozDef.Source)
|
||||
}
|
||||
|
||||
if conf.MozDef.UseProxy != testCase.ExpectedConfig.MozDef.UseProxy {
|
||||
t.Errorf(
|
||||
"Expected parsed UseProxy to be %v but it's %v",
|
||||
|
|
Загрузка…
Ссылка в новой задаче