norn-cli 1.10.2 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +98 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -109460,6 +109460,9 @@ function getConnectionValue(values, ...keys) {
|
|
|
109460
109460
|
function getConnectionString(values) {
|
|
109461
109461
|
return getConnectionValue(values, "connectionString");
|
|
109462
109462
|
}
|
|
109463
|
+
function usesWindowsIntegratedSqlServerAuth(connectionString) {
|
|
109464
|
+
return /(?:^|;)\s*Integrated\s+Security\s*=\s*(?:true|yes|sspi)\s*(?:;|$)/i.test(connectionString) || /(?:^|;)\s*Trusted_Connection\s*=\s*(?:true|yes|sspi)\s*(?:;|$)/i.test(connectionString);
|
|
109465
|
+
}
|
|
109463
109466
|
function buildMissingConnectionError(adapterLabel, profile) {
|
|
109464
109467
|
return `Missing required ${adapterLabel} connection string. Expected 'connectionString ${profile} = ...' in .nornenv.`;
|
|
109465
109468
|
}
|
|
@@ -109517,7 +109520,7 @@ if ([string]::IsNullOrWhiteSpace($raw)) {
|
|
|
109517
109520
|
throw 'Missing SQL adapter payload.'
|
|
109518
109521
|
}
|
|
109519
109522
|
|
|
109520
|
-
$payload = $raw | ConvertFrom-Json
|
|
109523
|
+
$payload = $raw | ConvertFrom-Json
|
|
109521
109524
|
$connectionString = [string]$payload.connection.values.connectionString
|
|
109522
109525
|
if ([string]::IsNullOrWhiteSpace($connectionString)) {
|
|
109523
109526
|
throw 'Missing SQL Server Integrated Auth connection string.'
|
|
@@ -109548,9 +109551,13 @@ $resolveHandler = [System.ResolveEventHandler]{
|
|
|
109548
109551
|
$sqlText = [string]$payload.operation.sql
|
|
109549
109552
|
$mode = [string]$payload.mode
|
|
109550
109553
|
$paramsObject = $payload.params
|
|
109554
|
+
$connectionStringHasUserId = $connectionString -match '(?i)(?:^|;)s*(?:User ID|UID)s*='
|
|
109555
|
+
$connectionStringHasPassword = $connectionString -match '(?i)(?:^|;)s*(?:Password|PWD)s*='
|
|
109551
109556
|
|
|
109552
109557
|
$connection = $null
|
|
109558
|
+
$connectionBuilder = $null
|
|
109553
109559
|
try {
|
|
109560
|
+
$connectionBuilder = New-Object Microsoft.Data.SqlClient.SqlConnectionStringBuilder $connectionString
|
|
109554
109561
|
$connection = New-Object Microsoft.Data.SqlClient.SqlConnection $connectionString
|
|
109555
109562
|
$command = $connection.CreateCommand()
|
|
109556
109563
|
$command.CommandText = $sqlText
|
|
@@ -109622,18 +109629,97 @@ try {
|
|
|
109622
109629
|
$response | ConvertTo-Json -Depth 100 -Compress
|
|
109623
109630
|
}
|
|
109624
109631
|
catch {
|
|
109625
|
-
$details =
|
|
109632
|
+
$details = New-Object System.Collections.Generic.List[string]
|
|
109626
109633
|
if ($_.Exception -and $_.Exception.GetType()) {
|
|
109627
|
-
$details
|
|
109634
|
+
$details.Add("type: $($_.Exception.GetType().FullName)")
|
|
109628
109635
|
}
|
|
109629
109636
|
if ($_.InvocationInfo -and $_.InvocationInfo.ScriptLineNumber) {
|
|
109630
|
-
$details
|
|
109637
|
+
$details.Add("line: $($_.InvocationInfo.ScriptLineNumber)")
|
|
109631
109638
|
}
|
|
109632
109639
|
if ($_.FullyQualifiedErrorId) {
|
|
109633
|
-
$details
|
|
109640
|
+
$details.Add("id: $($_.FullyQualifiedErrorId)")
|
|
109641
|
+
}
|
|
109642
|
+
|
|
109643
|
+
try {
|
|
109644
|
+
$details.Add("adapter: sqlserver-windows")
|
|
109645
|
+
$details.Add("powershell: $($PSVersionTable.PSVersion)")
|
|
109646
|
+
$details.Add("sqlClientVersion: $(([Microsoft.Data.SqlClient.SqlConnection]).Assembly.GetName().Version)")
|
|
109647
|
+
$details.Add("windowsIdentity: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)")
|
|
109648
|
+
} catch {
|
|
109649
|
+
}
|
|
109650
|
+
|
|
109651
|
+
if ($null -ne $connectionBuilder) {
|
|
109652
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$connectionBuilder.DataSource)) {
|
|
109653
|
+
$details.Add("dataSource: $($connectionBuilder.DataSource)")
|
|
109654
|
+
}
|
|
109655
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$connectionBuilder.InitialCatalog)) {
|
|
109656
|
+
$details.Add("database: $($connectionBuilder.InitialCatalog)")
|
|
109657
|
+
}
|
|
109658
|
+
$details.Add("integratedSecurity: $($connectionBuilder.IntegratedSecurity)")
|
|
109659
|
+
$details.Add("encrypt: $($connectionBuilder.Encrypt)")
|
|
109660
|
+
$details.Add("trustServerCertificate: $($connectionBuilder.TrustServerCertificate)")
|
|
109661
|
+
$details.Add("applicationIntent: $($connectionBuilder.ApplicationIntent)")
|
|
109662
|
+
$details.Add("multiSubnetFailover: $($connectionBuilder.MultiSubnetFailover)")
|
|
109663
|
+
|
|
109664
|
+
try {
|
|
109665
|
+
$hostNameInCertificate = [string]$connectionBuilder['HostNameInCertificate']
|
|
109666
|
+
if (-not [string]::IsNullOrWhiteSpace($hostNameInCertificate)) {
|
|
109667
|
+
$details.Add("hostNameInCertificate: $hostNameInCertificate")
|
|
109668
|
+
}
|
|
109669
|
+
} catch {
|
|
109670
|
+
}
|
|
109671
|
+
}
|
|
109672
|
+
|
|
109673
|
+
$details.Add("userIdPresent: $connectionStringHasUserId")
|
|
109674
|
+
$details.Add("passwordPresent: $connectionStringHasPassword")
|
|
109675
|
+
|
|
109676
|
+
$sqlException = $null
|
|
109677
|
+
if ($_.Exception -is [Microsoft.Data.SqlClient.SqlException]) {
|
|
109678
|
+
$sqlException = [Microsoft.Data.SqlClient.SqlException]$_.Exception
|
|
109679
|
+
} elseif ($_.Exception -and $_.Exception.InnerException -is [Microsoft.Data.SqlClient.SqlException]) {
|
|
109680
|
+
$sqlException = [Microsoft.Data.SqlClient.SqlException]$_.Exception.InnerException
|
|
109681
|
+
}
|
|
109682
|
+
|
|
109683
|
+
if ($null -ne $sqlException) {
|
|
109684
|
+
$details.Add("sqlNumber: $($sqlException.Number)")
|
|
109685
|
+
$details.Add("sqlState: $($sqlException.State)")
|
|
109686
|
+
$details.Add("sqlClass: $($sqlException.Class)")
|
|
109687
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$sqlException.Server)) {
|
|
109688
|
+
$details.Add("sqlServer: $($sqlException.Server)")
|
|
109689
|
+
}
|
|
109690
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$sqlException.Procedure)) {
|
|
109691
|
+
$details.Add("sqlProcedure: $($sqlException.Procedure)")
|
|
109692
|
+
}
|
|
109693
|
+
if ($sqlException.LineNumber -gt 0) {
|
|
109694
|
+
$details.Add("sqlLineNumber: $($sqlException.LineNumber)")
|
|
109695
|
+
}
|
|
109696
|
+
if ($sqlException.ClientConnectionId -ne [guid]::Empty) {
|
|
109697
|
+
$details.Add("clientConnectionId: $($sqlException.ClientConnectionId)")
|
|
109698
|
+
}
|
|
109699
|
+
if ($sqlException.Errors -and $sqlException.Errors.Count -gt 0) {
|
|
109700
|
+
$messages = @()
|
|
109701
|
+
foreach ($sqlError in $sqlException.Errors) {
|
|
109702
|
+
if ($sqlError -and -not [string]::IsNullOrWhiteSpace([string]$sqlError.Message)) {
|
|
109703
|
+
$messages += [string]$sqlError.Message
|
|
109704
|
+
}
|
|
109705
|
+
}
|
|
109706
|
+
if ($messages.Count -gt 0) {
|
|
109707
|
+
$details.Add("sqlErrors: $($messages -join ' | ')")
|
|
109708
|
+
}
|
|
109709
|
+
}
|
|
109710
|
+
}
|
|
109711
|
+
|
|
109712
|
+
if ($_.Exception -and $_.Exception.InnerException) {
|
|
109713
|
+
$details.Add("innerType: $($_.Exception.InnerException.GetType().FullName)")
|
|
109714
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$_.Exception.InnerException.Message)) {
|
|
109715
|
+
$details.Add("innerMessage: $($_.Exception.InnerException.Message)")
|
|
109716
|
+
}
|
|
109717
|
+
}
|
|
109718
|
+
|
|
109719
|
+
[Console]::Error.WriteLine("$($_.Exception.Message)")
|
|
109720
|
+
foreach ($detail in $details) {
|
|
109721
|
+
[Console]::Error.WriteLine(" $detail")
|
|
109634
109722
|
}
|
|
109635
|
-
$suffix = if ($details.Count -gt 0) { " ($($details -join ', '))" } else { '' }
|
|
109636
|
-
[Console]::Error.WriteLine("$($_.Exception.Message)$suffix")
|
|
109637
109723
|
exit 1
|
|
109638
109724
|
}
|
|
109639
109725
|
finally {
|
|
@@ -109794,6 +109880,9 @@ async function runBuiltInSqlServerAdapter(request) {
|
|
|
109794
109880
|
if (!connectionString) {
|
|
109795
109881
|
fail(buildMissingConnectionError("SQL Server", request.connection.profile));
|
|
109796
109882
|
}
|
|
109883
|
+
if (usesWindowsIntegratedSqlServerAuth(connectionString)) {
|
|
109884
|
+
fail("This SQL Server connection string uses Windows/Integrated authentication. Use adapter 'sqlserver-windows' in norn.sql.json.");
|
|
109885
|
+
}
|
|
109797
109886
|
const pool = new mssql.ConnectionPool(connectionString);
|
|
109798
109887
|
try {
|
|
109799
109888
|
await pool.connect();
|
|
@@ -109832,7 +109921,7 @@ async function runBuiltInSqlServerIntegratedAdapter(request) {
|
|
|
109832
109921
|
const values = request.connection.values;
|
|
109833
109922
|
const connectionString = getConnectionString(values);
|
|
109834
109923
|
if (!connectionString) {
|
|
109835
|
-
fail(buildMissingConnectionError("SQL Server
|
|
109924
|
+
fail(buildMissingConnectionError("SQL Server (Windows)", request.connection.profile));
|
|
109836
109925
|
}
|
|
109837
109926
|
const compiled = compileSqlServerSql(request.operation.sql, request.params || {});
|
|
109838
109927
|
const compiledRequest = {
|
|
@@ -109846,7 +109935,7 @@ async function runBuiltInSqlServerIntegratedAdapter(request) {
|
|
|
109846
109935
|
try {
|
|
109847
109936
|
return await runSqlServerIntegratedViaPowerShell(compiledRequest);
|
|
109848
109937
|
} catch (error) {
|
|
109849
|
-
throw formatBuiltInDriverError("SQL Server
|
|
109938
|
+
throw formatBuiltInDriverError("SQL Server (Windows)", error);
|
|
109850
109939
|
}
|
|
109851
109940
|
}
|
|
109852
109941
|
function isBuiltInSqlAdapter(adapterId) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "norn-cli",
|
|
3
3
|
"displayName": "Norn - REST Client",
|
|
4
4
|
"description": "A powerful REST client for making HTTP requests with sequences, variables, scripts, and cookie support",
|
|
5
|
-
"version": "1.10.
|
|
5
|
+
"version": "1.10.3",
|
|
6
6
|
"publisher": "Norn-PeterKrustanov",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Peter Krastanov"
|