Skip to content

Commit 2d022c6

Browse files
chandra-progressNik08lbarry316IanMadd
authored
Doc changes for trust_server_certificate option in mssql_session resource (#86)
* Committed doc changes for mssql session resource from https://github.com/inspec/inspec/pull/7791/changes Signed-off-by: Nik08 <nikita.mathur@progress.com> * Fixes to lint pipelines Signed-off-by: Nik08 <nikita.mathur@progress.com> * Editorial mssql_session.md Signed-off-by: Lisa Barry <lbarry@progress.com> * Editing Signed-off-by: Ian Maddaus <ian.maddaus@progress.com> --------- Signed-off-by: Nik08 <nikita.mathur@progress.com> Signed-off-by: Lisa Barry <lbarry@progress.com> Signed-off-by: Ian Maddaus <ian.maddaus@progress.com> Co-authored-by: Nik08 <nikita.mathur@progress.com> Co-authored-by: lbarry316 <118758673+lbarry316@users.noreply.github.com> Co-authored-by: Ian Maddaus <ian.maddaus@progress.com>
1 parent db93292 commit 2d022c6

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

content/resources/core/mssql_session.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,49 @@ end
3434

3535
where:
3636

37-
- `mssql_session` declares a username and password with permission to run the query. Omitting the username or password parameters results in the use of Windows authentication as the user Chef InSpec is executing as. You may also optionally pass a host and instance name. If omitted, they will default to host: localhost and the default instance.
37+
- `mssql_session` declares credentials and connection settings used to connect to Microsoft SQL Server
3838
- `query('QUERY')` contains the query to be run
3939
- `its('value') { should eq('') }` compares the results of the query against the expected result in the test
4040

41+
### Optional parameters
42+
43+
This resource has the following parameters:
44+
45+
`user`
46+
: The SQL Server username for SQL authentication.
47+
48+
If `user` or `password` is omitted, `mssql_session` uses Windows authentication as the user running Chef InSpec.
49+
50+
`password`
51+
: The SQL Server password for SQL authentication.
52+
53+
`pass` (deprecated)
54+
: Deprecated alias for `password`. Use `password` instead.
55+
56+
`host`
57+
: The SQL Server host name. Default value: `localhost`.
58+
59+
`port`
60+
: The SQL Server port. By default, no explicit port is passed.
61+
62+
`instance`
63+
: The SQL Server instance name. By default, the server's default instance is used.
64+
65+
`db_name`
66+
: The database name to connect to before running the query.
67+
68+
`local_mode`
69+
: Set to `true` to run in local mode.
70+
71+
In local mode, the resource doesn't pass the host or port to `sqlcmd`.
72+
73+
`trust_server_certificate`
74+
: Set `trust_server_certificate: true` to pass `-C` to the underlying `sqlcmd`.
75+
76+
Use this when you need encrypted connectivity, but certificate validation would otherwise fail due to missing certificate-chain configuration (for example, SQL Server uses a self-signed certificate or a private CA that isn't available in the runner's trust store).
77+
78+
This option is less secure than full certificate validation because it trusts the server certificate without strict verification. Use this only if necessary. Instead, install the correct CA certificate or SQL Server certificate on the target system when possible.
79+
4180
## Examples
4281

4382
The following examples show how to use this Chef InSpec audit resource.
@@ -82,6 +121,16 @@ describe sql.query("SELECT Name AS result FROM Product WHERE ProductID == 1").ro
82121
end
83122
```
84123

124+
### Trust the SQL Server certificate
125+
126+
```ruby
127+
sql = mssql_session(user: 'my_user', password: 'password', trust_server_certificate: true)
128+
129+
describe sql.query("SELECT SERVERPROPERTY('ProductVersion') as result").row(0).column('result') do
130+
its("value") { should_not be_empty }
131+
end
132+
```
133+
85134
## Matchers
86135

87136
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

cspell.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ignoreRegExpList:
3939
words:
4040
- TCPS
4141
- tnsnames
42+
- sqlcmd
4243
languageSettings:
4344
- languageId: markdown
4445
ignoreRegExpList:

0 commit comments

Comments
 (0)