2018-03-21 12:18:45 +01:00
|
|
|
package middlebox
|
|
|
|
|
|
|
|
import (
|
2018-09-27 11:40:57 +02:00
|
|
|
"errors"
|
|
|
|
|
2018-03-21 12:18:45 +01:00
|
|
|
"github.com/measurement-kit/go-measurement-kit"
|
2018-05-03 14:59:55 +02:00
|
|
|
"github.com/ooni/probe-cli/nettests"
|
2018-03-21 12:18:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// HTTPInvalidRequestLine test implementation
|
|
|
|
type HTTPInvalidRequestLine struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run starts the test
|
|
|
|
func (h HTTPInvalidRequestLine) Run(ctl *nettests.Controller) error {
|
|
|
|
mknt := mk.NewNettest("HttpInvalidRequestLine")
|
|
|
|
ctl.Init(mknt)
|
|
|
|
return mknt.Run()
|
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// HTTPInvalidRequestLineTestKeys for the test
|
|
|
|
type HTTPInvalidRequestLineTestKeys struct {
|
|
|
|
IsAnomaly bool `json:"-"`
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// GetTestKeys generates a summary for a test run
|
2018-09-27 11:40:57 +02:00
|
|
|
func (h HTTPInvalidRequestLine) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
|
|
|
testKeys := HTTPInvalidRequestLineTestKeys{IsAnomaly: false}
|
2018-03-21 12:18:45 +01:00
|
|
|
|
2018-09-27 11:40:57 +02:00
|
|
|
tampering, ok := tk["tampering"].(bool)
|
|
|
|
if !ok {
|
|
|
|
return testKeys, errors.New("tampering is not bool")
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
2018-09-27 11:40:57 +02:00
|
|
|
testKeys.IsAnomaly = tampering
|
|
|
|
|
|
|
|
return testKeys, nil
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// LogSummary writes the summary to the standard output
|
|
|
|
func (h HTTPInvalidRequestLine) LogSummary(s string) error {
|
|
|
|
return nil
|
|
|
|
}
|