From 35ab058a9df7ae56d513ec7f1c2dcc352cb221f3 Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Fri, 12 Apr 2024 11:28:39 +0200 Subject: [PATCH] Adds detection for Alpine Linux, AOSC OS, Clear Linux OS, EulerOS, Loongnix, Rocky Linux, Scientific Linux and improves version detection for CentOS, Debian, iPadOS, macOS, Red Hat, SUSE and Windows (#7654) * Improves version detection for macOS * Improves version detection for macOS * Improves version detection for Windows * Adds detection for LoongArch64 * Adds detection for AOSC OS * Adds detection for Loongnix * Adds detection for EulerOS * Adds detection for Scientific Linux * Adds detection for Alpine Linux * Adds detection for Clear Linux OS * Adds detection for Rocky Linux * Improves version detection for CentOS * Improves version detection for Debian * Improves detection for Red Hat * Improves detection for SUSE * Improves detection for iPadOS --------- Co-authored-by: Tutik Alexsandr --- Parser/OperatingSystem.php | 18 +++- Tests/Parser/fixtures/oss.yml | 192 ++++++++++++++++++++++++++++++++++ regexes/oss.yml | 109 +++++++++++++++++-- 3 files changed, 308 insertions(+), 11 deletions(-) diff --git a/Parser/OperatingSystem.php b/Parser/OperatingSystem.php index 80d9cf5a2b..3ad3ade443 100644 --- a/Parser/OperatingSystem.php +++ b/Parser/OperatingSystem.php @@ -43,11 +43,13 @@ class OperatingSystem extends AbstractParser 'AIX' => 'AIX', 'AND' => 'Android', 'ADR' => 'Android TV', + 'ALP' => 'Alpine Linux', 'AMZ' => 'Amazon Linux', 'AMG' => 'AmigaOS', 'ARM' => 'Armadillo OS', 'ATV' => 'tvOS', 'ARL' => 'Arch Linux', + 'AOS' => 'AOSC OS', 'ASP' => 'ASPLinux', 'BTR' => 'BackTrack', 'SBA' => 'Bada', @@ -60,6 +62,7 @@ class OperatingSystem extends AbstractParser 'CAI' => 'Caixa Mágica', 'CES' => 'CentOS', 'CST' => 'CentOS Stream', + 'CLO' => 'Clear Linux OS', 'CLR' => 'ClearOS Mobile', 'COS' => 'Chrome OS', 'CRS' => 'Chromium OS', @@ -70,6 +73,7 @@ class OperatingSystem extends AbstractParser 'DFB' => 'DragonFly', 'DVK' => 'DVKBuntu', 'ELE' => 'ElectroBSD', + 'EUL' => 'EulerOS', 'FED' => 'Fedora', 'FEN' => 'Fenix', 'FOS' => 'Firefox OS', @@ -103,6 +107,7 @@ class OperatingSystem extends AbstractParser 'LNS' => 'Linspire', 'LEN' => 'Lineage OS', 'LIR' => 'Liri OS', + 'LOO' => 'Loongnix', 'LBT' => 'Lubuntu', 'LOS' => 'Lumin OS', 'LUN' => 'LuneOS', @@ -143,6 +148,7 @@ class OperatingSystem extends AbstractParser 'RED' => 'RedOS', 'REV' => 'Revenge OS', 'ROS' => 'RISC OS', + 'ROC' => 'Rocky Linux', 'ROK' => 'Roku OS', 'RSO' => 'Rosa', 'ROU' => 'RouterOS', @@ -153,6 +159,7 @@ class OperatingSystem extends AbstractParser 'SAB' => 'Sabayon', 'SSE' => 'SUSE', 'SAF' => 'Sailfish OS', + 'SCI' => 'Scientific Linux', 'SEE' => 'SeewoOS', 'SER' => 'SerenityOS', 'SIR' => 'Sirin OS', @@ -222,7 +229,8 @@ class OperatingSystem extends AbstractParser 'LOS', 'DVK', 'ROK', 'OWR', 'OTV', 'KTV', 'PUR', 'PLA', 'FUC', 'PAR', 'FOR', 'MON', 'KAN', 'ZEN', 'LND', 'LNS', 'CHN', 'AMZ', 'TEN', 'CST', 'NOV', 'ROU', 'ZOR', 'RED', 'KAL', 'ORA', 'VID', 'TIV', 'BSN', 'RAS', - 'UOS', 'PIO', 'FRI', 'LIR', 'WEB', 'SER', 'ASP', + 'UOS', 'PIO', 'FRI', 'LIR', 'WEB', 'SER', 'ASP', 'AOS', 'LOO', 'EUL', + 'SCI', 'ALP', 'CLO', 'ROC', ], 'Mac' => ['MAC'], 'Mobile Gaming Console' => ['PSP', 'NDS', 'XBX'], @@ -630,6 +638,10 @@ protected function parsePlatform(): string return 'ARM'; } + if (false !== \strpos($arch, 'loongarch64')) { + return 'LoongArch64'; + } + if (false !== \strpos($arch, 'mips')) { return 'MIPS'; } @@ -657,6 +669,10 @@ protected function parsePlatform(): string return 'ARM'; } + if ($this->matchUserAgent('loongarch64')) { + return 'LoongArch64'; + } + if ($this->matchUserAgent('mips')) { return 'MIPS'; } diff --git a/Tests/Parser/fixtures/oss.yml b/Tests/Parser/fixtures/oss.yml index fa1cfd3788..32c143ff67 100644 --- a/Tests/Parser/fixtures/oss.yml +++ b/Tests/Parser/fixtures/oss.yml @@ -4686,3 +4686,195 @@ version: "13" platform: "" family: Android +- + user_agent: conda/23.5.0 requests/2.29.0 CPython/3.10.11 Darwin/22.5.0 OSX/13.4 + os: + name: Mac + short_name: MAC + version: "13.4" + platform: "" + family: Mac +- + user_agent: python-requests/2.2.1 CPython/2.7.5 Darwin/13.1.0 + os: + name: Mac + short_name: MAC + version: 10.9.2 + platform: "" + family: Mac +- + user_agent: Boto3/1.17.18 Python/3.8.5 Darwin/19.6.0 Botocore/1.20.18 + os: + name: Mac + short_name: MAC + version: 10.15.6 + platform: "" + family: Mac +- + user_agent: python-requests/2.6.0 CPython/3.8.9 Windows/10 + os: + name: Windows + short_name: WIN + version: "10" + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.18 Windows/8.1 + os: + name: Windows + short_name: WIN + version: "8.1" + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.18 Windows/7 + os: + name: Windows + short_name: WIN + version: "7" + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.0 Windows/2003Server + os: + name: Windows + short_name: WIN + version: Server 2003 + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.9 Windows/2012Server + os: + name: Windows + short_name: WIN + version: Server 2012 + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.18 Windows/2012ServerR2 + os: + name: Windows + short_name: WIN + version: Server 2012 R2 + platform: "" + family: Windows +- + user_agent: python-requests/2.7.0 CPython/2.7.18 Windows/2008ServerR2 + os: + name: Windows + short_name: WIN + version: Server 2008 R2 + platform: "" + family: Windows +- + user_agent: Mozilla/5.0 (X11; AOSC OS; Linux loongarch64; rv:120.0) Gecko/20100101 Firefox/120.0 + os: + name: AOSC OS + short_name: AOS + version: "" + platform: LoongArch64 + family: GNU/Linux +- + user_agent: conda/22.9.0 requests/2.26.0 CPython/3.8.6 Linux/4.19.190-6.2.4.lns8.loongarch64 loongnix-server/8.4.0 glibc/2.28 + os: + name: Loongnix + short_name: LOO + version: 8.4.0 + platform: LoongArch64 + family: GNU/Linux +- + user_agent: conda/4.8.2 requests/2.22.0 CPython/3.7.6 Linux/4.18.0-147.5.1.6.h841.eulerosv2r9.x86_64 ubuntu/18.04.6 glibc/2.27 + os: + name: EulerOS + short_name: EUL + version: "2.9" + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.6.14 requests/2.21.0 CPython/3.7.3 Linux/3.10.0-957.12.1.el7.x86_64 scientific/7.6 glibc/2.17 + os: + name: Scientific Linux + short_name: SCI + version: "7.6" + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.8.2 requests/2.22.0 CPython/3.7.6 Linux/5.4.46-1-lts alpine/3.9.5 glibc/2.28 + os: + name: Alpine Linux + short_name: ALP + version: 3.9.5 + platform: "" + family: GNU/Linux +- + user_agent: conda/4.11.0 requests/2.28.1 CPython/3.10.6 Linux/5.19.1-1175.native clear-linux-os/36820 glibc/2.36 + os: + name: Clear Linux OS + short_name: CLO + version: "36820" + platform: "" + family: GNU/Linux +- + user_agent: conda/23.5.0 requests/2.31.0 CPython/3.9.16 Linux/5.14.0-162.23.1.el9_1.x86_64 rocky/9.1 glibc/2.34 + os: + name: Rocky Linux + short_name: ROC + version: "9.1" + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.10.3 requests/2.26.0 CPython/3.9.7 Linux/3.10.0-1160.53.1.el7.x86_64 centos/7.9.2009 glibc/2.17 + os: + name: CentOS + short_name: CES + version: 7.9.2009 + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.3.27 requests/2.18.4 CPython/2.7.13 Linux/3.10.0-957.27.2.el7.x86_64 CentOS Linux/7.6.1810 glibc/2.17 + os: + name: CentOS + short_name: CES + version: 7.6.1810 + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.3.31 requests/2.18.4 CPython/2.7.14 Linux/4.4.0-109-generic debian/stretch/sid glibc/2.23 + os: + name: Debian + short_name: DEB + version: "9.13" + platform: "" + family: GNU/Linux +- + user_agent: conda/4.5.11 requests/2.18.4 CPython/3.6.4 Linux/2.6.32-696.20.1.el6.x86_64 rhel/6.9 glibc/2.12 + os: + name: Red Hat + short_name: RHT + version: "6.9" + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.3.24 requests/2.14.2 CPython/3.6.1 Linux/3.10.0-514.el7.x86_64 Red Hat Enterprise Linux Server/7.3 glibc/2.17 + os: + name: Red Hat + short_name: RHT + version: "7.3" + platform: x64 + family: GNU/Linux +- + user_agent: conda/4.4.10 requests/2.18.4 CPython/3.6.4 Linux/4.4.114-94.14-default sles/12.3 glibc/2.22 + os: + name: SUSE + short_name: SSE + version: "12.3" + platform: "" + family: GNU/Linux +- + user_agent: Pinterest for iOS/12.3 (iPad11,6; 17.2) + os: + name: iPadOS + short_name: IPA + version: "17.2" + platform: "" + family: iOS diff --git a/regexes/oss.yml b/regexes/oss.yml index eee62e4f96..74d72f258f 100644 --- a/regexes/oss.yml +++ b/regexes/oss.yml @@ -5,6 +5,59 @@ # @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later ############### +########## +# Rocky Linux (https://rockylinux.org/) +########## +- regex: 'rocky/(\d+[\.\d]+)' + name: 'Rocky Linux' + version: '$1' + +########## +# Clear Linux OS (https://www.clearlinux.org/) +########## +- regex: 'clear-linux-os/(\d+[\.\d]+)' + name: 'Clear Linux OS' + version: '$1' + +########## +# Alpine Linux (https://www.alpinelinux.org/) +########## +- regex: 'alpine/(\d+[\.\d]+)' + name: 'Alpine Linux' + version: '$1' + +########## +# Scientific Linux (https://scientificlinux.org/) +########## +- regex: 'scientific/(\d+[\.\d]+)' + name: 'Scientific Linux' + version: '$1' + +########## +# EulerOS (https://developer.huaweicloud.com/intl/en-us/euleros/index.html) +########## +- regex: 'eulerosv(\d)r(\d+)' + name: 'EulerOS' + version: '$1.$2' + +########## +# Loongnix (https://www.loongson.cn/EN/system/loongnix) +########## +- regex: 'loongnix-server/(\d+[\.\d]+)' + name: 'Loongnix' + version: '$1' + +- regex: 'Linux/(?:\d+\.[\d.-]+)\.lns(\d+(?:[_.]\d+)*)\.loongarch64' + name: 'Loongnix' + version: '$1' + +########## +# AOSC OS (https://aosc.io/) +########## +- regex: 'AOSC OS' + name: 'AOSC OS' + version: '' + ########## # SerenityOS (https://github.com/SerenityOS/serenity) ########## @@ -753,10 +806,26 @@ name: 'VectorLinux' version: '$1' +- regex: 'sles/(\d+[\.\d]+)' + name: 'SUSE' + version: '$1' + +- regex: '(?:rhel|Red Hat Enterprise Linux Server)/(\d+[\.\d]+)' + name: 'Red Hat' + version: '$1' + +- regex: '.+redhat-linux-gnu|rhel|Red Hat Enterprise Linux Server' + name: 'Red Hat' + version: '' + - regex: 'CentOS Stream (\d)' name: 'CentOS Stream' version: '$1' +- regex: 'centos(?: Linux)?/(\d+[\.\d]+) ' + name: 'CentOS' + version: '$1' + - regex: '.+.el(\d+(?:[_\.]\d+)*).(?:centos|x86_64)' name: 'CentOS' version: '$1' @@ -785,6 +854,10 @@ name: 'Ubuntu' version: '8.04' +- regex: 'debian/stretch' + name: 'Debian' + version: '9.13' + - regex: 'Ubuntu[-/]feisty' name: 'Ubuntu' version: '7.04' @@ -817,10 +890,6 @@ name: '$1' version: '$2' -- regex: '.+redhat-linux-gnu' - name: 'Red Hat' - version: '' - - regex: 'OS ROSA; Linux' name: 'Rosa' version: '' @@ -884,7 +953,7 @@ name: 'Windows' version: '$1' -- regex: 'CYGWIN_NT-10\.0|Windows NT 10\.0|Windows 10' +- regex: 'CYGWIN_NT-10\.0|Windows NT 10\.0|Windows[ /]10' name: 'Windows' version: '10' @@ -892,15 +961,27 @@ name: 'Windows' version: '10' -- regex: 'CYGWIN_NT-6\.3|Windows NT 6\.3|Windows 8\.1' +- regex: 'Windows/2012ServerR2' + name: 'Windows' + version: 'Server 2012 R2' + +- regex: 'CYGWIN_NT-6\.3|Windows NT 6\.3|Windows[ /]8\.1' name: 'Windows' version: '8.1' +- regex: 'Windows/2012Server' + name: 'Windows' + version: 'Server 2012' + - regex: 'CYGWIN_NT-6\.2|Windows NT 6\.2|Windows 8' name: 'Windows' version: '8' -- regex: 'CYGWIN_NT-6\.1|Windows NT 6\.1|Windows 7|win7|Windows \(6\.1' +- regex: 'Windows/2008ServerR2' + name: 'Windows' + version: 'Server 2008 R2' + +- regex: 'CYGWIN_NT-6\.1|Windows NT 6\.1|Windows[ /]7|win7|Windows \(6\.1' name: 'Windows' version: '7' @@ -908,7 +989,7 @@ name: 'Windows' version: 'Vista' -- regex: 'CYGWIN_NT-5\.2|Windows NT 5\.2|Windows Server 2003 / XP x64' +- regex: 'CYGWIN_NT-5\.2|Windows NT 5\.2|Windows Server 2003 / XP x64|Windows/2003Server' name: 'Windows' version: 'Server 2003' @@ -1007,6 +1088,10 @@ name: 'iPadOS' version: '$1.$2' +- regex: 'Pinterest for iOS/.*iPad.*; (\d(?:[\d\.]*))[)]$' + name: 'iPadOS' + version: '$1' + ########## # iOS ########## @@ -1018,7 +1103,7 @@ name: 'iOS' version: '$1' -- regex: 'Pinterest for iOS/.*; (\d(?:[\d\.]*))[)]$' +- regex: 'Pinterest for iOS/.*iPhone.*; (\d(?:[\d\.]*))[)]$' name: 'iOS' version: '$1' @@ -1263,7 +1348,7 @@ ########## # Mac ########## -- regex: '(?:CFNetwork|Mana|StudioDisplay)/.+Darwin(?:/|; )(?:[\d\.]+).+(?:x86_64|i386|Power%20Macintosh)|(?:x86_64-apple-)?darwin(?:[\d\.]+)|PowerMac|com\.apple\.Safari\.SearchHelper|^Safari' +- regex: '(?:CFNetwork|Mana|StudioDisplay)/.+Darwin(?:/|; )(?:[\d\.]+).+(?:x86_64|i386|Power%20Macintosh)|(?:x86_64-apple-)?darwin(?:[\d\.]+)|C?Python.*Darwin|PowerMac|com\.apple\.Safari\.SearchHelper|^Safari' name: 'Mac' versions: - regex: '(?:x86_64-apple-)?Darwin(?:/|; )?23\.5\.0' @@ -1463,6 +1548,10 @@ name: 'Mac' version: '$1' +- regex: 'OSX/(\d+[\.\d]+)' + name: 'Mac' + version: '$1' + - regex: 'Darwin|Macintosh|Mac[ _]PowerPC|PPC|iMac|MacBook|.*macOS|AppleExchangeWebServices|com\.apple\.trustd|Sonos/.+\(MDCR_|WhatsApp/.*N$' name: 'Mac' version: ''