os-normalizer 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of os-normalizer might be problematic. Click here for more details.
- os_normalizer/__init__.py +10 -0
- os_normalizer/constants.py +87 -0
- os_normalizer/cpe.py +265 -0
- os_normalizer/helpers.py +107 -0
- os_normalizer/models.py +159 -0
- os_normalizer/os_normalizer.py +313 -0
- os_normalizer/parsers/__init__.py +16 -0
- os_normalizer/parsers/bsd.py +69 -0
- os_normalizer/parsers/linux.py +121 -0
- os_normalizer/parsers/macos.py +111 -0
- os_normalizer/parsers/mobile.py +37 -0
- os_normalizer/parsers/network/__init__.py +61 -0
- os_normalizer/parsers/network/cisco.py +96 -0
- os_normalizer/parsers/network/fortinet.py +56 -0
- os_normalizer/parsers/network/huawei.py +38 -0
- os_normalizer/parsers/network/juniper.py +42 -0
- os_normalizer/parsers/network/netgear.py +41 -0
- os_normalizer/parsers/windows.py +197 -0
- os_normalizer-0.3.2.dist-info/METADATA +172 -0
- os_normalizer-0.3.2.dist-info/RECORD +22 -0
- os_normalizer-0.3.2.dist-info/WHEEL +4 -0
- os_normalizer-0.3.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: os-normalizer
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Normalize raw OS strings/metadata into structured data (family, product, version, arch).
|
|
5
|
+
Project-URL: Homepage, https://github.com/johnscillieri/os-normalizer
|
|
6
|
+
Project-URL: Repository, https://github.com/johnscillieri/os-normalizer
|
|
7
|
+
Project-URL: Issues, https://github.com/johnscillieri/os-normalizer/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/johnscillieri/os-normalizer/releases
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2025 OS Normalizer contributors
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: cpe,fingerprint,normalize,os,parsing
|
|
32
|
+
Classifier: Development Status :: 4 - Beta
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
42
|
+
Classifier: Topic :: System :: Operating System
|
|
43
|
+
Requires-Python: >=3.11
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# OS Normalizer
|
|
47
|
+
|
|
48
|
+
A Python library for identifying and parsing operating system information from various sources.
|
|
49
|
+
|
|
50
|
+
## Overview
|
|
51
|
+
|
|
52
|
+
The OS Normalizer library parses raw operating system strings and JSON data to identify the OS family, version, architecture, and other details. It supports parsing of:
|
|
53
|
+
|
|
54
|
+
- Windows (NT builds, versions)
|
|
55
|
+
- macOS (Darwin versions, codenames)
|
|
56
|
+
- Linux distributions (Ubuntu, Debian, Red Hat, etc.)
|
|
57
|
+
- iOS and Android mobile OS
|
|
58
|
+
- BSD variants (FreeBSD, OpenBSD, NetBSD)
|
|
59
|
+
- Network operating systems (Cisco IOS, Junos, FortiOS, etc.)
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install os-normalizer
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
The main entry point is the `normalize_os` function, which takes a string and an optional data dictionary and returns a structured `OSData` result.
|
|
70
|
+
|
|
71
|
+
### Basic Usage
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from os_normalizer import normalize_os
|
|
75
|
+
|
|
76
|
+
# Parse the OS information
|
|
77
|
+
result = normalize_os("Windows NT 10.0 build 22631 Enterprise x64")
|
|
78
|
+
print(result.family) # windows
|
|
79
|
+
print(result.product) # Windows 11
|
|
80
|
+
print(result.version_major) # 11
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Using Raw OS JSON Data
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from os_normalizer import normalize_os
|
|
87
|
+
|
|
88
|
+
# Fingerprint with both raw string and JSON data
|
|
89
|
+
raw_os_string="Linux host 5.15.0-122-generic x86_64"
|
|
90
|
+
raw_os_json={
|
|
91
|
+
"os_release": 'NAME="Ubuntu"\nID=ubuntu\nVERSION_ID="22.04.4"\nVERSION_CODENAME=jammy\nPRETTY_NAME="Ubuntu 22.04.4 LTS"'}
|
|
92
|
+
|
|
93
|
+
result = normalize_os(raw_os_string, raw_os_json)
|
|
94
|
+
print(result.family) # linux
|
|
95
|
+
print(result.product) # Ubuntu
|
|
96
|
+
print(result.codename) # Jammy
|
|
97
|
+
print(result.arch) # x86_64
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Parsing Network Operating Systems
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from os_normalizer import normalize_os
|
|
104
|
+
|
|
105
|
+
# Parse Cisco IOS XE
|
|
106
|
+
raw_os_string="Cisco IOS XE Software, Version 17.9.4a (Amsterdam) C9300-24T, universalk9, c9300-universalk9.17.09.04a.SPA.bin"
|
|
107
|
+
|
|
108
|
+
result = normalize_os(raw_os_string)
|
|
109
|
+
print(result.family) # network-os
|
|
110
|
+
print(result.vendor) # Cisco
|
|
111
|
+
print(result.product) # IOS XE
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Models
|
|
115
|
+
|
|
116
|
+
### OSData
|
|
117
|
+
|
|
118
|
+
Represents structured operating system information:
|
|
119
|
+
|
|
120
|
+
- `family`: OS family (windows, linux, macos, ios, android, bsd, network-os)
|
|
121
|
+
- `vendor`: Vendor name (Microsoft, Apple, Cisco, etc.)
|
|
122
|
+
- `product`: Product name (Windows 11, Ubuntu, macOS, etc.)
|
|
123
|
+
- `edition`: Edition information (Pro, Enterprise, etc.)
|
|
124
|
+
- `codename`: Release codename (Sequoia, Ventura, etc.)
|
|
125
|
+
- `channel`: Release channel (GA, LTS, etc.)
|
|
126
|
+
- `version_major`, `version_minor`, `version_patch`, `version_build`: Version components
|
|
127
|
+
- `kernel_name`, `kernel_version`: Kernel details
|
|
128
|
+
- `arch`: Architecture (x86_64, arm64, etc.)
|
|
129
|
+
- `distro`: Distribution name
|
|
130
|
+
- `like_distros`: List of similar distributions
|
|
131
|
+
- `pretty_name`: Pretty formatted name
|
|
132
|
+
- `hw_model`, `build_id`: Network device details
|
|
133
|
+
- `precision`: Precision level (family, product, major, minor, patch, build)
|
|
134
|
+
- `confidence`: Confidence score (0.0 to 1.0)
|
|
135
|
+
- `evidence`: Evidence used for parsing decisions
|
|
136
|
+
- `os_key`: Canonical key for deduplication
|
|
137
|
+
|
|
138
|
+
## Architecture
|
|
139
|
+
|
|
140
|
+
The library follows a modular architecture:
|
|
141
|
+
|
|
142
|
+
- **os_normalizer.py**: Main orchestration logic that delegates to appropriate parsers
|
|
143
|
+
- **parsers/**: OS-specific parsers (macOS, Linux, Windows, Network, Mobile, BSD)
|
|
144
|
+
- **models.py**: Data models for parsed results
|
|
145
|
+
- **constants.py**: Static lookup tables (aliases, build maps, codenames)
|
|
146
|
+
- **helpers.py**: Utility functions (architecture extraction, confidence calculation)
|
|
147
|
+
|
|
148
|
+
## Testing
|
|
149
|
+
|
|
150
|
+
You can run tests with uv in a few ways:
|
|
151
|
+
|
|
152
|
+
- Ephemeral runner (downloads pytest if needed):
|
|
153
|
+
- `uvx pytest`
|
|
154
|
+
- Use the project environment and dev dependencies declared in `pyproject.toml`:
|
|
155
|
+
- `uv run --group dev pytest`
|
|
156
|
+
- Optional editable install for import paths:
|
|
157
|
+
- `uv pip install -e .`
|
|
158
|
+
- `uv run pytest`
|
|
159
|
+
|
|
160
|
+
### Using Nox (with nox-uv)
|
|
161
|
+
|
|
162
|
+
If you prefer repeatable sessions, this project includes Nox configured with the `nox-uv` plugin so virtualenvs are created via `uv`:
|
|
163
|
+
|
|
164
|
+
- Run tests: `uv run nox`
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
os_normalizer/__init__.py,sha256=ZA2JnO3juuAn8xQBqUoUXxca10B-rE1MIuwtzDofpKs,212
|
|
2
|
+
os_normalizer/constants.py,sha256=aIm6TiT95Mr7adABYwW6f57Hef0-_thopnNoHssiHFA,2676
|
|
3
|
+
os_normalizer/cpe.py,sha256=G7hFiuVMlXM2d70ra7NA8v3a7kV7gYBt24bFunCAzk8,8742
|
|
4
|
+
os_normalizer/helpers.py,sha256=IymYS2NAJ6J8ngI_HL5PH2_6zN6zzIpWMx1-05D2O3c,3347
|
|
5
|
+
os_normalizer/models.py,sha256=_FAisDt9Pi5GDHIvzzfilEE8svvjyx6EcG2ZvMSRRJ0,5793
|
|
6
|
+
os_normalizer/os_normalizer.py,sha256=IsWxE_Yes7FQxxNhA8twNrzmeRcl8QXTxjTfn0zCTTI,10143
|
|
7
|
+
os_normalizer/parsers/__init__.py,sha256=-z-iu6os5LWuMUznvmfv_5LIw6Fbb3M1Auq2Wm7Rvfc,325
|
|
8
|
+
os_normalizer/parsers/bsd.py,sha256=Umm7RSXjQfv6pfziJ8BYlmOc80VlLRueTrYw1iR-UjY,2018
|
|
9
|
+
os_normalizer/parsers/linux.py,sha256=dQA0D57agO6g7EqFCRZ2cv6sLoR3jpEJ9onWZFZi35c,3528
|
|
10
|
+
os_normalizer/parsers/macos.py,sha256=fU1YyiijzBdDAxUBSL2EQLhUu3JbOSx-N_KYvOg0XsI,3627
|
|
11
|
+
os_normalizer/parsers/mobile.py,sha256=Ca864JhrO9zW5fs0zbs2VcMypKIkFHqZtxpJDbi12q0,1033
|
|
12
|
+
os_normalizer/parsers/windows.py,sha256=DQtGwOhXqqwvdD_aShAZOiIYZ9hltq-6DwdL5AQjiYw,6589
|
|
13
|
+
os_normalizer/parsers/network/__init__.py,sha256=TvRz08lNDZbr6yG8O3M7cLNu0hWAbtE1y7_9SwhP4g4,1596
|
|
14
|
+
os_normalizer/parsers/network/cisco.py,sha256=ivhw85IHnHVT4sW-65F-ZGCR7yvu0mMMBfXRT4EzUfc,3203
|
|
15
|
+
os_normalizer/parsers/network/fortinet.py,sha256=C-f5DgDS6mvda69vJ5bRM-blEE92E2rAEzYvbHXl2WM,1807
|
|
16
|
+
os_normalizer/parsers/network/huawei.py,sha256=Su3eCRlmOCmpOPA_TGeH8gHY3-ZdXKFW4O3_W0SOPmk,1158
|
|
17
|
+
os_normalizer/parsers/network/juniper.py,sha256=gskbaY4-LYWauM9yrvGMuCxPrNBKmUfIRPd1zsUUY7w,1275
|
|
18
|
+
os_normalizer/parsers/network/netgear.py,sha256=AhgjVlhQiKvzuCHWAGMZCTucdOOSDt7cl9xONpb2aSA,1220
|
|
19
|
+
os_normalizer-0.3.2.dist-info/METADATA,sha256=DugZSc8kZQ9tkKEEHKgIE7OTWJ_8QqlRYB4lk7E5_tg,6421
|
|
20
|
+
os_normalizer-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
21
|
+
os_normalizer-0.3.2.dist-info/licenses/LICENSE,sha256=DN0enoiHxVkJ-hxmIchPaCQWrDsZwva5LY8XvG3UK8w,1083
|
|
22
|
+
os_normalizer-0.3.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 OS Normalizer contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|