From d19ac5bfeb82243d83a06aaa34d1c9907e19b4ff Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sat, 20 Feb 2021 23:01:08 -0500 Subject: [PATCH 01/14] added mssql to switch case --- dynamicbeat/checks/checks.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dynamicbeat/checks/checks.go b/dynamicbeat/checks/checks.go index ef6e4d826..2d758a4e5 100644 --- a/dynamicbeat/checks/checks.go +++ b/dynamicbeat/checks/checks.go @@ -21,6 +21,7 @@ import ( "github.com/scorestack/scorestack/dynamicbeat/checks/icmp" "github.com/scorestack/scorestack/dynamicbeat/checks/imap" "github.com/scorestack/scorestack/dynamicbeat/checks/ldap" + "github.com/scorestack/scorestack/dynamicbeat/checks/mssql" "github.com/scorestack/scorestack/dynamicbeat/checks/mysql" "github.com/scorestack/scorestack/dynamicbeat/checks/noop" "github.com/scorestack/scorestack/dynamicbeat/checks/schema" @@ -161,6 +162,8 @@ func unpackDef(config schema.CheckConfig) (schema.Check, error) { def = &mysql.Definition{} case "smb": def = &smb.Definition{} + case "mssql": + def = &mssql.Definition{} default: logp.Warn("Invalid check type found. Offending check : %s:%s", config.Name, config.Type) def = &noop.Definition{} From 44a86deff8e74b9dee6341d515c38109034c5b18 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sat, 20 Feb 2021 23:01:20 -0500 Subject: [PATCH 02/14] untested mssql check implemented --- dynamicbeat/checks/mssql/mssql.go | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 dynamicbeat/checks/mssql/mssql.go diff --git a/dynamicbeat/checks/mssql/mssql.go b/dynamicbeat/checks/mssql/mssql.go new file mode 100644 index 000000000..09788c318 --- /dev/null +++ b/dynamicbeat/checks/mssql/mssql.go @@ -0,0 +1,110 @@ +package mssql + +import ( + "context" + "database/sql" + "fmt" + "regexp" + "strconv" + + "github.com/scorestack/scorestack/dynamicbeat/checks/schema" +) + +type Definition struct { + Config schema.CheckConfig // generic metadata about the check + Host string `optiontype:"required"` // IP or Hostname for the MSSQL server + Username string `optiontype:"required"` // Username for the database + Password string `optiontype:"required"` // Password for the user + Database string `optiontype:"required"` // Name of the database to access + Table string `optiontype:"required"` // Name of the table to access + Column string `optiontype:"required"` // Name of the column to access + MatchContent string `optiontype:"optional"` // Whether to perform a regex content match on the results of the query + ContentRegex string `optiontype:"optional" optiondefault:".*"` // Regex to match on + Port string `optiontype:"optional" optiondefault:"1433"` // Port for the server +} + +// Run a single instance of the check +func (d *Definition) Run(ctx context.Context) schema.CheckResult { + // Initialize empty result + result := schema.CheckResult{} + + // Create DB handle + db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s/instance?database=%s", d.Username, d.Password, d.Host, d.Database)) + if err != nil { + result.Message = fmt.Sprintf("Creating database handle failed : %s", err) + return result + } + defer db.Close() + + // Set connection parameters + db.SetMaxIdleConns(-1) + db.SetMaxOpenConns(1) + + // Check db connection + err = db.PingContext(ctx) + if err != nil { + result.Message = fmt.Sprintf("Failed to ping database : %s", err) + return result + } + + // Query the Db + // TODO: This is SQL injectable. FIgure out paramerterized queries + rows, err := db.QueryContext(ctx, fmt.Sprintf("SELECT %s FROM %s;", d.Column, d.Table)) + if err != nil { + result.Message = fmt.Sprintf("Could not query database : %s", err) + return result + } + defer rows.Close() + + // Store the value from the column + var val string + + // Perform regex matching if necessary + if matchContent, _ := strconv.ParseBool(d.MatchContent); matchContent { + // Compile the regex + regex, err := regexp.Compile(d.ContentRegex) + if err != nil { + result.Message = fmt.Sprintf("Error compiling regex string %s : %s", d.ContentRegex, err) + return result + } + + // Check the rows + for rows.Next() { + // Grab a value + err := rows.Scan(&val) + if err != nil { + result.Message = fmt.Sprintf("Could not scan row values : %s", err) + return result + } + // Check value with regex + if regex.MatchString(val) { + // If we reach here the check passes + result.Passed = true + return result + } + + } + } + + // Check for error in the rows + if rows.Err() != nil { + result.Message = fmt.Sprintf("Something happened to the rows : %s", err) + return result + } + + // Check passes if we reach here + result.Passed = true + return result + +} + +// GetConfig returns the current CheckConfig struct this check has been +// configured with +func (d *Definition) GetConfig() schema.CheckConfig { + return d.Config +} + +// SetConfig reconfigures this check with a new CheckConfig struct +func (d *Definition) SetConfig(config schema.CheckConfig) { + d.Config = config +} From aafef22bb4c7c971fd9fe062187f75a6b236baf9 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:21:03 -0500 Subject: [PATCH 03/14] added port to connection string --- dynamicbeat/checks/mssql/mssql.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dynamicbeat/checks/mssql/mssql.go b/dynamicbeat/checks/mssql/mssql.go index 09788c318..353e03c9d 100644 --- a/dynamicbeat/checks/mssql/mssql.go +++ b/dynamicbeat/checks/mssql/mssql.go @@ -7,6 +7,8 @@ import ( "regexp" "strconv" + // MSSQL driver + _ "github.com/denisenkom/go-mssqldb" "github.com/scorestack/scorestack/dynamicbeat/checks/schema" ) @@ -29,7 +31,7 @@ func (d *Definition) Run(ctx context.Context) schema.CheckResult { result := schema.CheckResult{} // Create DB handle - db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s/instance?database=%s", d.Username, d.Password, d.Host, d.Database)) + db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s:%s/instance?database=%s", d.Username, d.Password, d.Host, d.Port, d.Database)) if err != nil { result.Message = fmt.Sprintf("Creating database handle failed : %s", err) return result From eacaa8c84ff670fa4bee3495cbfe5c61eebc8b69 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:24:10 -0500 Subject: [PATCH 04/14] updated for new packages --- dynamicbeat/go.mod | 1 + dynamicbeat/go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dynamicbeat/go.mod b/dynamicbeat/go.mod index 879736867..2407cf820 100644 --- a/dynamicbeat/go.mod +++ b/dynamicbeat/go.mod @@ -21,6 +21,7 @@ replace ( require ( github.com/akavel/rsrc v0.9.0 // indirect + github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e github.com/dlclark/regexp2 v1.2.1 // indirect github.com/dop251/goja v0.0.0-20200929101608-beb0a9a01fbc // indirect github.com/dop251/goja_nodejs v0.0.0-20200811150831-9bc458b4bbeb // indirect diff --git a/dynamicbeat/go.sum b/dynamicbeat/go.sum index 78c57ce69..7ff37f156 100644 --- a/dynamicbeat/go.sum +++ b/dynamicbeat/go.sum @@ -175,6 +175,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE= +github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e h1:LzwWXEScfcTu7vUZNlDDWDARoSGEtvlDKK2BYHowNeE= github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/devigned/tab v0.1.2-0.20190607222403-0c15cf42f9a2/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= @@ -326,6 +327,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= From 1f32a4210b2b42de1e010eac13f26fd2e7ee049a Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:24:31 -0500 Subject: [PATCH 05/14] exmaple for mssql --- examples/mssql/admin-attribs.json | 8 ++++++++ examples/mssql/check.json | 17 +++++++++++++++++ examples/mssql/user-attribs.json | 3 +++ 3 files changed, 28 insertions(+) create mode 100644 examples/mssql/admin-attribs.json create mode 100644 examples/mssql/check.json create mode 100644 examples/mssql/user-attribs.json diff --git a/examples/mssql/admin-attribs.json b/examples/mssql/admin-attribs.json new file mode 100644 index 000000000..66e8fc581 --- /dev/null +++ b/examples/mssql/admin-attribs.json @@ -0,0 +1,8 @@ +{ + "Host": "localhost", + "Username": "sa", + "Database": "scorestack", + "Table": "stacks", + "Column": "testVal", + "MatchContent": "true" +} \ No newline at end of file diff --git a/examples/mssql/check.json b/examples/mssql/check.json new file mode 100644 index 000000000..634344f35 --- /dev/null +++ b/examples/mssql/check.json @@ -0,0 +1,17 @@ +{ + "id": "mssql", + "name": "MSSQL", + "type": "mssql", + "group": "example", + "score_weight": 1, + "definition": { + "Host": "{{.Host}}", + "Username": "{{.Username}}", + "Password": "{{.Password}}", + "Database": "{{.Database}}", + "Table": "{{.Table}}", + "Column": "{{.Column}}", + "MatchContent": "{{.MatchContent}}", + "ContentRegex": "hello" + } +} \ No newline at end of file diff --git a/examples/mssql/user-attribs.json b/examples/mssql/user-attribs.json new file mode 100644 index 000000000..ffbe84bf3 --- /dev/null +++ b/examples/mssql/user-attribs.json @@ -0,0 +1,3 @@ +{ + "Password": "StongPassword!" +} \ No newline at end of file From f98697ad5b82f9d9418d4550d3607041659a6056 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:37:48 -0500 Subject: [PATCH 06/14] added mssql reference docs --- docs/reference/mssql.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/reference/mssql.md diff --git a/docs/reference/mssql.md b/docs/reference/mssql.md new file mode 100644 index 000000000..3507799a2 --- /dev/null +++ b/docs/reference/mssql.md @@ -0,0 +1,27 @@ +MSSQL +===== + +| Name | Type | Required | Description | +| ------------ | ------ | ------------ | -------------------------------------------------------------------- | +| Host | String | Y | IP or FQDN for the MySQL server | +| Username | String | Y | Username for the database | +| Password | String | Y | Password for the user | +| Database | String | Y | Name of the database to access | +| Table | String | Y | Name of the table to access | +| Column | String | Y | Name of the column to access | +| MatchContent | String | N :: "false" | Whether to perform a regex content match on the results of the query | +| ContentRegex | String | N :: "\.\*" | Regex to match on | +| Port | String | N :: "1433" | Port for the server | + +Example Check +------------- + +The example check provided in the `examples/` folder uses the following schema: + +```sql +CREATE DATABASE scorestack +USE scorestack +CREATE TABLE stacks (testVal NVARCHAR(50)) +INSERT INTO stacks ("hello from scorestack!") +GO +``` From ba751c01a430810f03b955cabc06ff66ae92bcdc Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:42:49 -0500 Subject: [PATCH 07/14] added mssql to switch case --- dynamicbeat/checks/checks.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dynamicbeat/checks/checks.go b/dynamicbeat/checks/checks.go index 7114252d7..aa84edcc1 100644 --- a/dynamicbeat/checks/checks.go +++ b/dynamicbeat/checks/checks.go @@ -21,6 +21,7 @@ import ( "github.com/scorestack/scorestack/dynamicbeat/checks/icmp" "github.com/scorestack/scorestack/dynamicbeat/checks/imap" "github.com/scorestack/scorestack/dynamicbeat/checks/ldap" + "github.com/scorestack/scorestack/dynamicbeat/checks/mssql" "github.com/scorestack/scorestack/dynamicbeat/checks/mysql" "github.com/scorestack/scorestack/dynamicbeat/checks/noop" "github.com/scorestack/scorestack/dynamicbeat/checks/postgresql" @@ -164,6 +165,8 @@ func unpackDef(config schema.CheckConfig) (schema.Check, error) { def = &smb.Definition{} case "postgresql": def = &postgresql.Definition{} + case "mssql": + def = &mssql.Definition{} default: logp.Warn("Invalid check type found. Offending check : %s:%s", config.Name, config.Type) def = &noop.Definition{} From 40ddae3a48c1ccfa324267d289f840df3d733ea9 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sat, 20 Feb 2021 23:01:20 -0500 Subject: [PATCH 08/14] untested mssql check implemented --- dynamicbeat/checks/mssql/mssql.go | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 dynamicbeat/checks/mssql/mssql.go diff --git a/dynamicbeat/checks/mssql/mssql.go b/dynamicbeat/checks/mssql/mssql.go new file mode 100644 index 000000000..09788c318 --- /dev/null +++ b/dynamicbeat/checks/mssql/mssql.go @@ -0,0 +1,110 @@ +package mssql + +import ( + "context" + "database/sql" + "fmt" + "regexp" + "strconv" + + "github.com/scorestack/scorestack/dynamicbeat/checks/schema" +) + +type Definition struct { + Config schema.CheckConfig // generic metadata about the check + Host string `optiontype:"required"` // IP or Hostname for the MSSQL server + Username string `optiontype:"required"` // Username for the database + Password string `optiontype:"required"` // Password for the user + Database string `optiontype:"required"` // Name of the database to access + Table string `optiontype:"required"` // Name of the table to access + Column string `optiontype:"required"` // Name of the column to access + MatchContent string `optiontype:"optional"` // Whether to perform a regex content match on the results of the query + ContentRegex string `optiontype:"optional" optiondefault:".*"` // Regex to match on + Port string `optiontype:"optional" optiondefault:"1433"` // Port for the server +} + +// Run a single instance of the check +func (d *Definition) Run(ctx context.Context) schema.CheckResult { + // Initialize empty result + result := schema.CheckResult{} + + // Create DB handle + db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s/instance?database=%s", d.Username, d.Password, d.Host, d.Database)) + if err != nil { + result.Message = fmt.Sprintf("Creating database handle failed : %s", err) + return result + } + defer db.Close() + + // Set connection parameters + db.SetMaxIdleConns(-1) + db.SetMaxOpenConns(1) + + // Check db connection + err = db.PingContext(ctx) + if err != nil { + result.Message = fmt.Sprintf("Failed to ping database : %s", err) + return result + } + + // Query the Db + // TODO: This is SQL injectable. FIgure out paramerterized queries + rows, err := db.QueryContext(ctx, fmt.Sprintf("SELECT %s FROM %s;", d.Column, d.Table)) + if err != nil { + result.Message = fmt.Sprintf("Could not query database : %s", err) + return result + } + defer rows.Close() + + // Store the value from the column + var val string + + // Perform regex matching if necessary + if matchContent, _ := strconv.ParseBool(d.MatchContent); matchContent { + // Compile the regex + regex, err := regexp.Compile(d.ContentRegex) + if err != nil { + result.Message = fmt.Sprintf("Error compiling regex string %s : %s", d.ContentRegex, err) + return result + } + + // Check the rows + for rows.Next() { + // Grab a value + err := rows.Scan(&val) + if err != nil { + result.Message = fmt.Sprintf("Could not scan row values : %s", err) + return result + } + // Check value with regex + if regex.MatchString(val) { + // If we reach here the check passes + result.Passed = true + return result + } + + } + } + + // Check for error in the rows + if rows.Err() != nil { + result.Message = fmt.Sprintf("Something happened to the rows : %s", err) + return result + } + + // Check passes if we reach here + result.Passed = true + return result + +} + +// GetConfig returns the current CheckConfig struct this check has been +// configured with +func (d *Definition) GetConfig() schema.CheckConfig { + return d.Config +} + +// SetConfig reconfigures this check with a new CheckConfig struct +func (d *Definition) SetConfig(config schema.CheckConfig) { + d.Config = config +} From 00b91227267d7b9dda2f9b97b43dfdff6c6cc3b9 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:21:03 -0500 Subject: [PATCH 09/14] added port to connection string --- dynamicbeat/checks/mssql/mssql.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dynamicbeat/checks/mssql/mssql.go b/dynamicbeat/checks/mssql/mssql.go index 09788c318..353e03c9d 100644 --- a/dynamicbeat/checks/mssql/mssql.go +++ b/dynamicbeat/checks/mssql/mssql.go @@ -7,6 +7,8 @@ import ( "regexp" "strconv" + // MSSQL driver + _ "github.com/denisenkom/go-mssqldb" "github.com/scorestack/scorestack/dynamicbeat/checks/schema" ) @@ -29,7 +31,7 @@ func (d *Definition) Run(ctx context.Context) schema.CheckResult { result := schema.CheckResult{} // Create DB handle - db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s/instance?database=%s", d.Username, d.Password, d.Host, d.Database)) + db, err := sql.Open("mssql", fmt.Sprintf("sqlserver://%s:%s@%s:%s/instance?database=%s", d.Username, d.Password, d.Host, d.Port, d.Database)) if err != nil { result.Message = fmt.Sprintf("Creating database handle failed : %s", err) return result From 2d1b8e9e83d1b978371bb9bf27debca6eacdb189 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:24:10 -0500 Subject: [PATCH 10/14] updated for new packages --- dynamicbeat/go.mod | 1 + dynamicbeat/go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dynamicbeat/go.mod b/dynamicbeat/go.mod index 92ee0f897..8d678173f 100644 --- a/dynamicbeat/go.mod +++ b/dynamicbeat/go.mod @@ -21,6 +21,7 @@ replace ( require ( github.com/akavel/rsrc v0.9.0 // indirect + github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e github.com/dlclark/regexp2 v1.2.1 // indirect github.com/dop251/goja v0.0.0-20200929101608-beb0a9a01fbc // indirect github.com/dop251/goja_nodejs v0.0.0-20200811150831-9bc458b4bbeb // indirect diff --git a/dynamicbeat/go.sum b/dynamicbeat/go.sum index 32c68bd7c..9bc0b8343 100644 --- a/dynamicbeat/go.sum +++ b/dynamicbeat/go.sum @@ -178,6 +178,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE= +github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e h1:LzwWXEScfcTu7vUZNlDDWDARoSGEtvlDKK2BYHowNeE= github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/devigned/tab v0.1.2-0.20190607222403-0c15cf42f9a2/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= @@ -329,6 +330,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= From 4c2c26b851117e438b53c5ba2b6c5c3bb180f84d Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:24:31 -0500 Subject: [PATCH 11/14] exmaple for mssql --- examples/mssql/admin-attribs.json | 8 ++++++++ examples/mssql/check.json | 17 +++++++++++++++++ examples/mssql/user-attribs.json | 3 +++ 3 files changed, 28 insertions(+) create mode 100644 examples/mssql/admin-attribs.json create mode 100644 examples/mssql/check.json create mode 100644 examples/mssql/user-attribs.json diff --git a/examples/mssql/admin-attribs.json b/examples/mssql/admin-attribs.json new file mode 100644 index 000000000..66e8fc581 --- /dev/null +++ b/examples/mssql/admin-attribs.json @@ -0,0 +1,8 @@ +{ + "Host": "localhost", + "Username": "sa", + "Database": "scorestack", + "Table": "stacks", + "Column": "testVal", + "MatchContent": "true" +} \ No newline at end of file diff --git a/examples/mssql/check.json b/examples/mssql/check.json new file mode 100644 index 000000000..634344f35 --- /dev/null +++ b/examples/mssql/check.json @@ -0,0 +1,17 @@ +{ + "id": "mssql", + "name": "MSSQL", + "type": "mssql", + "group": "example", + "score_weight": 1, + "definition": { + "Host": "{{.Host}}", + "Username": "{{.Username}}", + "Password": "{{.Password}}", + "Database": "{{.Database}}", + "Table": "{{.Table}}", + "Column": "{{.Column}}", + "MatchContent": "{{.MatchContent}}", + "ContentRegex": "hello" + } +} \ No newline at end of file diff --git a/examples/mssql/user-attribs.json b/examples/mssql/user-attribs.json new file mode 100644 index 000000000..ffbe84bf3 --- /dev/null +++ b/examples/mssql/user-attribs.json @@ -0,0 +1,3 @@ +{ + "Password": "StongPassword!" +} \ No newline at end of file From 42e2bf5e1106cf53e17549b53d0a787fef57ab66 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:37:48 -0500 Subject: [PATCH 12/14] added mssql reference docs --- docs/reference/mssql.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/reference/mssql.md diff --git a/docs/reference/mssql.md b/docs/reference/mssql.md new file mode 100644 index 000000000..3507799a2 --- /dev/null +++ b/docs/reference/mssql.md @@ -0,0 +1,27 @@ +MSSQL +===== + +| Name | Type | Required | Description | +| ------------ | ------ | ------------ | -------------------------------------------------------------------- | +| Host | String | Y | IP or FQDN for the MySQL server | +| Username | String | Y | Username for the database | +| Password | String | Y | Password for the user | +| Database | String | Y | Name of the database to access | +| Table | String | Y | Name of the table to access | +| Column | String | Y | Name of the column to access | +| MatchContent | String | N :: "false" | Whether to perform a regex content match on the results of the query | +| ContentRegex | String | N :: "\.\*" | Regex to match on | +| Port | String | N :: "1433" | Port for the server | + +Example Check +------------- + +The example check provided in the `examples/` folder uses the following schema: + +```sql +CREATE DATABASE scorestack +USE scorestack +CREATE TABLE stacks (testVal NVARCHAR(50)) +INSERT INTO stacks ("hello from scorestack!") +GO +``` From 1163150f3e0c27757646f270640d6386d11d5680 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:47:16 -0500 Subject: [PATCH 13/14] added mssql changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e768343..3ecc2ad02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Each section organizes entries into the following subsections: #### Added - PostgreSQL check type (#294) +- MSSQL check type (#295) #### Fixed From 6d5ca62cbe15df817017e9900b8b1e4e16cc6830 Mon Sep 17 00:00:00 2001 From: oneNutW0nder Date: Sun, 21 Feb 2021 00:50:24 -0500 Subject: [PATCH 14/14] fixed typo --- docs/reference/mssql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/mssql.md b/docs/reference/mssql.md index 3507799a2..72e2a26cd 100644 --- a/docs/reference/mssql.md +++ b/docs/reference/mssql.md @@ -3,7 +3,7 @@ MSSQL | Name | Type | Required | Description | | ------------ | ------ | ------------ | -------------------------------------------------------------------- | -| Host | String | Y | IP or FQDN for the MySQL server | +| Host | String | Y | IP or FQDN for the MSSQL server | | Username | String | Y | Username for the database | | Password | String | Y | Password for the user | | Database | String | Y | Name of the database to access |