Skip to content

Commit 0a4cd19

Browse files
authored
feat: Add Always Encrypted -g (#457)
1 parent 9a6b932 commit 0a4cd19

File tree

20 files changed

+1927
-1179
lines changed

20 files changed

+1927
-1179
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"request": "launch",
2525
"mode" : "auto",
2626
"program": "${workspaceFolder}/cmd/modern",
27-
"args" : ["-Q", "EXIT(select net_transport from sys.dm_exec_connections)"],
27+
"args" : ["-S", "davidshi-2022", "-g", "-Q", "select nvarcharcol from encrypt.dbo.encrypted", "--driver-logging-level=65"],
2828
},
2929
{
3030
"name" : "Run file query",

NOTICE.md

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This repository incorporates material as listed below or described in the code.
66
## github.com/Azure/azure-sdk-for-go/sdk/azcore
77

88
* Name: github.com/Azure/azure-sdk-for-go/sdk/azcore
9-
* Version: v1.6.0
10-
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azcore/v1.6.0/sdk/azcore/LICENSE.txt)
9+
* Version: v1.7.1
10+
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azcore/v1.7.1/sdk/azcore/LICENSE.txt)
1111

1212
```
1313
MIT License
@@ -96,11 +96,71 @@ SOFTWARE
9696
9797
```
9898

99+
## github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys
100+
101+
* Name: github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys
102+
* Version: v1.0.0
103+
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/security/keyvault/azkeys/v1.0.0/sdk/security/keyvault/azkeys/LICENSE.txt)
104+
105+
```
106+
MIT License
107+
108+
Copyright (c) Microsoft Corporation. All rights reserved.
109+
110+
Permission is hereby granted, free of charge, to any person obtaining a copy
111+
of this software and associated documentation files (the "Software"), to deal
112+
in the Software without restriction, including without limitation the rights
113+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
114+
copies of the Software, and to permit persons to whom the Software is
115+
furnished to do so, subject to the following conditions:
116+
117+
The above copyright notice and this permission notice shall be included in all
118+
copies or substantial portions of the Software.
119+
120+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
122+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
124+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
125+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
126+
SOFTWARE
127+
```
128+
129+
## github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal
130+
131+
* Name: github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal
132+
* Version: v0.8.0
133+
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/security/keyvault/internal/v0.8.0/sdk/security/keyvault/internal/LICENSE.txt)
134+
135+
```
136+
MIT License
137+
138+
Copyright (c) Microsoft Corporation. All rights reserved.
139+
140+
Permission is hereby granted, free of charge, to any person obtaining a copy
141+
of this software and associated documentation files (the "Software"), to deal
142+
in the Software without restriction, including without limitation the rights
143+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
144+
copies of the Software, and to permit persons to whom the Software is
145+
furnished to do so, subject to the following conditions:
146+
147+
The above copyright notice and this permission notice shall be included in all
148+
copies or substantial portions of the Software.
149+
150+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
153+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
155+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
156+
SOFTWARE
157+
```
158+
99159
## github.com/AzureAD/microsoft-authentication-library-for-go/apps
100160

101161
* Name: github.com/AzureAD/microsoft-authentication-library-for-go/apps
102-
* Version: v1.0.0
103-
* License: [MIT](https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v1.0.0/LICENSE)
162+
* Version: v1.1.0
163+
* License: [MIT](https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v1.1.0/LICENSE)
104164

105165
```
106166
MIT License
@@ -1408,11 +1468,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14081468
14091469
```
14101470

1411-
## github.com/golang-jwt/jwt/v4
1471+
## github.com/golang-jwt/jwt/v5
14121472

1413-
* Name: github.com/golang-jwt/jwt/v4
1414-
* Version: v4.5.0
1415-
* License: [MIT](https://github.com/golang-jwt/jwt/blob/v4.5.0/LICENSE)
1473+
* Name: github.com/golang-jwt/jwt/v5
1474+
* Version: v5.0.0
1475+
* License: [MIT](https://github.com/golang-jwt/jwt/blob/v5.0.0/LICENSE)
14161476

14171477
```
14181478
Copyright (c) 2012 Dave Grijalva
@@ -4683,8 +4743,8 @@ THE SOFTWARE.
46834743
## golang.org/x/crypto
46844744

46854745
* Name: golang.org/x/crypto
4686-
* Version: v0.9.0
4687-
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/crypto/+/v0.9.0:LICENSE)
4746+
* Version: v0.12.0
4747+
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/crypto/+/v0.12.0:LICENSE)
46884748

46894749
```
46904750
Copyright (c) 2009 The Go Authors. All rights reserved.
@@ -4720,8 +4780,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47204780
## golang.org/x/net
47214781

47224782
* Name: golang.org/x/net
4723-
* Version: v0.10.0
4724-
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.10.0:LICENSE)
4783+
* Version: v0.14.0
4784+
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.14.0:LICENSE)
47254785

47264786
```
47274787
Copyright (c) 2009 The Go Authors. All rights reserved.
@@ -4757,8 +4817,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47574817
## golang.org/x/sys
47584818

47594819
* Name: golang.org/x/sys
4760-
* Version: v0.8.0
4761-
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.8.0:LICENSE)
4820+
* Version: v0.11.0
4821+
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.11.0:LICENSE)
47624822

47634823
```
47644824
Copyright (c) 2009 The Go Authors. All rights reserved.
@@ -4794,8 +4854,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47944854
## golang.org/x/text
47954855

47964856
* Name: golang.org/x/text
4797-
* Version: v0.9.0
4798-
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.9.0:LICENSE)
4857+
* Version: v0.12.0
4858+
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.12.0:LICENSE)
47994859

48004860
```
48014861
Copyright (c) 2009 The Go Authors. All rights reserved.

cmd/sqlcmd/sqlcmd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type SQLCmdArguments struct {
7070
RemoveControlCharacters *int
7171
EchoInput bool
7272
QueryTimeout int
73+
EnableColumnEnryption bool
7374
// Keep Help at the end of the list
7475
Help bool
7576
}
@@ -380,7 +381,7 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
380381
rootCmd.Flags().StringVarP(&args.Query, "query", "Q", "", localizer.Sprintf("Executes a query when sqlcmd starts and then immediately exits sqlcmd. Multiple-semicolon-delimited queries can be executed"))
381382
rootCmd.Flags().StringVarP(&args.Server, "server", "S", "", localizer.Sprintf("%s Specifies the instance of SQL Server to which to connect. It sets the sqlcmd scripting variable %s.", localizer.ConnStrPattern, localizer.ServerEnvVar))
382383
_ = rootCmd.Flags().IntP(disableCmdAndWarn, "X", 0, localizer.Sprintf("%s Disables commands that might compromise system security. Passing 1 tells sqlcmd to exit when disabled commands are run.", "-X[1]"))
383-
rootCmd.Flags().StringVar(&args.AuthenticationMethod, "authentication-method", "", localizer.Sprintf("Specifies the SQL authentication method to use to connect to Azure SQL Database. One of: ActiveDirectoryDefault, ActiveDirectoryIntegrated, ActiveDirectoryPassword, ActiveDirectoryInteractive, ActiveDirectoryManagedIdentity, ActiveDirectoryServicePrincipal, SqlPassword"))
384+
rootCmd.Flags().StringVar(&args.AuthenticationMethod, "authentication-method", "", localizer.Sprintf("Specifies the SQL authentication method to use to connect to Azure SQL Database. One of: ActiveDirectoryDefault, ActiveDirectoryIntegrated, ActiveDirectoryPassword, ActiveDirectoryInteractive, ActiveDirectoryManagedIdentity, ActiveDirectoryServicePrincipal, ActiveDirectoryAzCli, ActiveDirectoryDeviceCode, SqlPassword"))
384385
rootCmd.Flags().BoolVarP(&args.UseAad, "use-aad", "G", false, localizer.Sprintf("Tells sqlcmd to use ActiveDirectory authentication. If no user name is provided, authentication method ActiveDirectoryDefault is used. If a password is provided, ActiveDirectoryPassword is used. Otherwise ActiveDirectoryInteractive is used"))
385386
rootCmd.Flags().BoolVarP(&args.DisableVariableSubstitution, "disable-variable-substitution", "x", false, localizer.Sprintf("Causes sqlcmd to ignore scripting variables. This parameter is useful when a script contains many %s statements that may contain strings that have the same format as regular variables, such as $(variable_name)", localizer.InsertKeyword))
386387
var variables map[string]string
@@ -422,6 +423,7 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
422423
_ = rootCmd.Flags().IntP(removeControlCharacters, "k", 0, localizer.Sprintf("%s Remove control characters from output. Pass 1 to substitute a space per character, 2 for a space per consecutive characters", "-k [1|2]"))
423424
rootCmd.Flags().BoolVarP(&args.EchoInput, "echo-input", "e", false, localizer.Sprintf("Echo input"))
424425
rootCmd.Flags().IntVarP(&args.QueryTimeout, "query-timeout", "t", 0, "Query timeout")
426+
rootCmd.Flags().BoolVarP(&args.EnableColumnEnryption, "enable-column-encryption", "g", false, localizer.Sprintf("Enable column encryption"))
425427
}
426428

427429
func setScriptVariable(v string) string {
@@ -680,6 +682,7 @@ func setConnect(connect *sqlcmd.ConnectSettings, args *SQLCmdArguments, vars *sq
680682
connect.ExitOnError = args.ExitOnError
681683
connect.ErrorSeverityLevel = args.ErrorSeverityLevel
682684
connect.DedicatedAdminConnection = args.DedicatedAdminConnection
685+
connect.EnableColumnEnryption = args.EnableColumnEnryption
683686
}
684687

685688
func isConsoleInitializationRequired(connect *sqlcmd.ConnectSettings, args *SQLCmdArguments) bool {

go.mod

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ require (
1010
github.com/docker/go-connections v0.4.0
1111
github.com/golang-sql/sqlexp v0.1.0
1212
github.com/google/uuid v1.3.0
13-
github.com/microsoft/go-mssqldb v1.5.0
13+
github.com/microsoft/go-mssqldb v1.6.0
1414
github.com/opencontainers/image-spec v1.0.2
1515
github.com/peterh/liner v1.2.2
1616
github.com/pkg/errors v0.9.1
1717
github.com/spf13/cobra v1.6.1
1818
github.com/spf13/pflag v1.0.5
1919
github.com/spf13/viper v1.14.0
20-
github.com/stretchr/testify v1.8.1
21-
golang.org/x/sys v0.8.0
22-
golang.org/x/text v0.9.0
20+
github.com/stretchr/testify v1.8.4
21+
golang.org/x/sys v0.11.0
22+
golang.org/x/text v0.12.0
2323
golang.org/x/tools v0.6.0
2424
gopkg.in/yaml.v2 v2.4.0
2525
)
2626

2727
require (
28-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect
28+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 // indirect
2929
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
3030
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
31-
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
31+
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 // indirect
32+
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 // indirect
33+
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 // indirect
3234
github.com/Microsoft/go-winio v0.6.0 // indirect
3335
github.com/beorn7/perks v1.0.1 // indirect
3436
github.com/cespare/xxhash/v2 v2.1.1 // indirect
@@ -39,7 +41,7 @@ require (
3941
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
4042
github.com/fsnotify/fsnotify v1.6.0 // indirect
4143
github.com/gogo/protobuf v1.3.2 // indirect
42-
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
44+
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
4345
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
4446
github.com/golang/protobuf v1.5.2 // indirect
4547
github.com/gorilla/mux v1.8.0 // indirect
@@ -66,9 +68,9 @@ require (
6668
github.com/spf13/cast v1.5.0 // indirect
6769
github.com/spf13/jwalterweatherman v1.1.0 // indirect
6870
github.com/subosito/gotenv v1.4.1 // indirect
69-
golang.org/x/crypto v0.9.0 // indirect
71+
golang.org/x/crypto v0.12.0 // indirect
7072
golang.org/x/mod v0.8.0 // indirect
71-
golang.org/x/net v0.10.0 // indirect
73+
golang.org/x/net v0.14.0 // indirect
7274
google.golang.org/protobuf v1.28.1 // indirect
7375
gopkg.in/ini.v1 v1.67.0 // indirect
7476
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)