Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds pattern to catch other arch and platform values #19125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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|
adfoster-r7 marked this conversation as resolved.
Show resolved Hide resolved
context "when the database is version #{test[:version]}" do
it "returns #{test[:expected]}" do
Expand Down
Loading