Skip to content

Commit

Permalink
adds pattern to catch other arch and platform values
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed May 2, 2024
1 parent 01f6ebf commit fa6ce27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rex/proto/mssql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ def detect_platform_and_arch
result = {}

server_vars = query('select @@version')[:rows][0][0]
arch = server_vars.match(/\b\d+\.\d+\.\d+\.\d+\s\((?<arch>[^)]*)\)/)[:arch] || server_vars
plat = server_vars.match(/\bon\b\s+(?<plat>\w+)/)[:plat] || server_vars

result[:arch] = map_compile_arch_to_architecture(server_vars)
result[:platform] = map_compile_os_to_platform(server_vars)
result[:arch] = map_compile_arch_to_architecture(arch)
result[:platform] = map_compile_os_to_platform(plat)
result
end

Expand Down
1 change: 1 addition & 0 deletions spec/lib/rex/proto/mssql/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
[
{ version: 'Microsoft SQL Server 2022 (RTM-CU12) (KB5033663) - 16.0.4115.5 (X64) Mar 4 2024 08:56:10 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 22.04.4 LTS) <X64>', expected: { arch: 'x86_64', platform: 'Linux' } },
{ version: 'Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (X64) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor)', expected: { arch: 'x86_64', platform: 'Windows' } },
{ version: 'Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (32) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Developer Edition (2-bit) on Mac Standard 10.0 <??> (Build 20348: ) (Hypervisor)', expected: { arch: '32', platform: 'mac' } },
].each do |test|
context "when the database is version #{test[:version]}" do
it "returns #{test[:expected]}" do
Expand Down

0 comments on commit fa6ce27

Please sign in to comment.