Skip to content

Commit

Permalink
Improves version detection for Azure Linux, macOS and Windows (matomo…
Browse files Browse the repository at this point in the history
…-org#7922)

* Adds detection for Cygwin
* Adds detection for Azure Blob Storage
* Improves version detection for Windows
* Improves version detection for macOS
* Improves platform detection
* Improves detection for Azure Linux
  • Loading branch information
liviuconcioiu authored Nov 19, 2024
1 parent f3c7b29 commit ed39ce4
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Parser/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ protected function parsePlatform(): string
return 'SPARC64';
}

if ($this->matchUserAgent('64-?bit|WOW64|(?:Intel)?x64|WINDOWS_64|win64|.*amd64|x86_?64')) {
if ($this->matchUserAgent('64-?bit|WOW64|(?:Intel)?x64|WINDOWS_64|win64|.*amd64|.*x86_?64')) {
return 'x64';
}

Expand Down
12 changes: 12 additions & 0 deletions Tests/Parser/Client/fixtures/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,15 @@
type: library
name: PhantomJS
version: 2.1.1
-
user_agent: Cygwin-Setup/2.932 (Windows NT 10.0.20348;x86_64;0409;SymLinkPriv)
client:
type: library
name: Cygwin
version: "2.932"
-
user_agent: azsdk-python-storage-blob/12.23.0 Python/3.12.5 (Windows-2022Server-10.0.20348-SP0)
client:
type: library
name: Azure Blob Storage
version: 12.23.0
72 changes: 72 additions & 0 deletions Tests/Parser/fixtures/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5733,3 +5733,75 @@
version: "24"
platform: ""
family: Other Mobile
-
user_agent: azsdk-python-storage-blob/12.23.1 Python/3.12.6 (Windows-11-10.0.22631-SP0)
os:
name: Windows
short_name: WIN
version: "11"
platform: ""
family: Windows
-
user_agent: AZURECLI/2.65.0 (MSI) azsdk-python-storage-blob/12.16.0 Python/3.11.8 (Windows-10-10.0.20348-SP0) VSTS_bbc9b9e6-59b6-4cd2-a1a6-91f2e5eb8d58_build_58_0
os:
name: Windows
short_name: WIN
version: "10"
platform: ""
family: Windows
-
user_agent: azsdk-python-storage-blob/12.23.1 Python/3.13.0 (Windows-2025Server-10.0.26100-SP0)
os:
name: Windows
short_name: WIN
version: Server 2025
platform: ""
family: Windows
-
user_agent: azsdk-python-storage-blob/12.23.0 Python/3.12.5 (Windows-2022Server-10.0.20348-SP0)
os:
name: Windows
short_name: WIN
version: Server 2022
platform: ""
family: Windows
-
user_agent: azsdk-python-storage-blob/12.23.1 Python/3.13.0 (Windows-2019Server-10.0.17763-SP0)
os:
name: Windows
short_name: WIN
version: Server 2019
platform: ""
family: Windows
-
user_agent: azsdk-python-storage-blob/12.23.0 Python/3.12.5 (Windows-2016Server-10.0.14393-SP0)
os:
name: Windows
short_name: WIN
version: Server 2016
platform: ""
family: Windows
-
user_agent: azsdk-python-storage-blob/12.17.0 Python/3.12.4 (macOS-14.7-arm64-arm-64bit)
os:
name: Mac
short_name: MAC
version: "14.7"
platform: ARM
family: Mac
-
user_agent: azsdk-python-storage-blob/12.23.1 Python/3.9.20 (Linux-6.5.0-1025-azure-x86_64-with-glibc2.31)
os:
name: Azure Linux
short_name: AZU
version: ""
platform: x64
family: GNU/Linux
-
user_agent: azsdk-python-storage-blob/12.17.0 Python/3.11.10 (Linux-5.15.164.1-1.cm2-x86_64-with-glibc2.31)
os:
name: Azure Linux
short_name: AZU
version: "2"
platform: x64
family: GNU/Linux
10 changes: 10 additions & 0 deletions regexes/client/libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,13 @@
name: 'ICAP Client'
version: '$1'
url: 'https://github.com/Peoplecantfly/icapserver'

- regex: 'Cygwin-Setup(?:/(\d+[.\d]+))?'
name: 'Cygwin'
version: '$1'
url: 'https://www.cygwin.com/'

- regex: 'azsdk-python-storage-blob(?:/(\d+[.\d]+))?'
name: 'Azure Blob Storage'
version: '$1'
url: 'https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python'
16 changes: 14 additions & 2 deletions regexes/oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
##########
# Azure Linux (https://github.com/microsoft/azurelinux)
##########
- regex: 'Linux/.+-Microsoft'
- regex: '.+.cm(\d).x86_64'
name: 'Azure Linux'
version: '$1'

- regex: 'Linux[/-].+-(azure|Microsoft)'
name: 'Azure Linux'
version: ''

Expand Down Expand Up @@ -1149,6 +1153,10 @@
name: 'Windows'
version: '$1'

- regex: 'Windows-(1[01])-'
name: 'Windows'
version: '$1'

- regex: 'CYGWIN_NT-10\.0|Win(?:dows )?NT 10\.0|Windows[ /]10'
name: 'Windows'
version: '10'
Expand All @@ -1157,6 +1165,10 @@
name: 'Windows'
version: '10'

- regex: 'Windows[/-](2016|2019|2022|2025)Server'
name: 'Windows'
version: 'Server $1'

- regex: 'Windows/2012ServerR2'
name: 'Windows'
version: 'Server 2012 R2'
Expand Down Expand Up @@ -1764,7 +1776,7 @@
name: 'Mac'
version: '$1'

- regex: '(?:macOS(?:\(Catalyst\))?[ /,]|Mac-)(\d+[.\d]+)'
- regex: '(?:macOS(?:\(Catalyst\))?[ /,]|Mac(?:os)?-)(\d+[.\d]+)'
name: 'Mac'
version: '$1'

Expand Down

0 comments on commit ed39ce4

Please sign in to comment.