osel/qualys/utils.go
Nate Johnston ca0e1ca769 Initial import of osel code
This is an initial import of the osel codebase.  The osel tool is a tool that
initiates external security scans (initially through Qualys) upon reciept of
AMQP events that indicate certain sensitive events have occurred, like a
security group rule change.

The commit history had to be thrown away because it contained some non-public
data, so I would like to call out the following contributors:

This uses go 1.10 and vgo for dependency management.

Co-Authored-By: Charles Bitter <Charles_Bitter@cable.comcast.com>
Co-Authored-By: Olivier Gagnon <Olivier_Gagnon@cable.comcast.com>
Co-Authored-By: Joseph Sleiman <Joseph_Sleiman@comcast.com>

Change-Id: Ib6abe2024fd91978b783ceee4cff8bb4678d7b15
2018-03-24 15:30:57 +00:00

45 lines
744 B
Go

package qualys
import (
"net/url"
"reflect"
"github.com/google/go-querystring/query"
)
func containsString(strList []string, testStr string) bool {
for _, str := range strList {
if testStr == str {
return true
}
}
return false
}
func addURLParameters(urlString string, opt interface{}) (string, error) {
v := reflect.ValueOf(opt)
if v.Kind() == reflect.Ptr && v.IsNil() {
return urlString, nil
}
origURL, err := url.Parse(urlString)
if err != nil {
return urlString, err
}
origValues := origURL.Query()
newValues, err := query.Values(opt)
if err != nil {
return urlString, err
}
for k, v := range newValues {
origValues[k] = v
}
origURL.RawQuery = origValues.Encode()
return origURL.String(), nil
}