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 3, 2024
1 parent 01f6ebf commit 6547fdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rex/proto/mssql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ def map_compile_arch_to_architecture(server_info)
def detect_platform_and_arch
result = {}

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

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
2 changes: 2 additions & 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,8 @@
[
{ 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' } },
{ version: 'unknown', expected: { arch: 'unknown', platform: 'unknown' } },
].each do |test|
context "when the database is version #{test[:version]}" do
it "returns #{test[:expected]}" do
Expand Down

0 comments on commit 6547fdb

Please sign in to comment.