os-normalizer 0.5.1__tar.gz
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.
- os_normalizer-0.5.1/.gitignore +10 -0
- os_normalizer-0.5.1/.python-version +1 -0
- os_normalizer-0.5.1/.uv-cache/.gitignore +1 -0
- os_normalizer-0.5.1/.uv-cache/.lock +0 -0
- os_normalizer-0.5.1/.uv-cache/CACHEDIR.TAG +1 -0
- os_normalizer-0.5.1/.uv-cache/interpreter-v4/7e11d242fb84b9e8/939db8dea853eb17.msgpack +0 -0
- os_normalizer-0.5.1/.uv-cache/sdists-v9/.git +0 -0
- os_normalizer-0.5.1/.uv-cache/sdists-v9/.gitignore +0 -0
- os_normalizer-0.5.1/CHANGELOG.md +104 -0
- os_normalizer-0.5.1/LICENSE +21 -0
- os_normalizer-0.5.1/PKG-INFO +174 -0
- os_normalizer-0.5.1/README.md +128 -0
- os_normalizer-0.5.1/RELEASING.md +23 -0
- os_normalizer-0.5.1/os_normalizer/__init__.py +10 -0
- os_normalizer-0.5.1/os_normalizer/constants.py +295 -0
- os_normalizer-0.5.1/os_normalizer/cpe.py +357 -0
- os_normalizer-0.5.1/os_normalizer/helpers.py +118 -0
- os_normalizer-0.5.1/os_normalizer/models.py +185 -0
- os_normalizer-0.5.1/os_normalizer/os_normalizer.py +340 -0
- os_normalizer-0.5.1/os_normalizer/parsers/__init__.py +19 -0
- os_normalizer-0.5.1/os_normalizer/parsers/bsd.py +209 -0
- os_normalizer-0.5.1/os_normalizer/parsers/esxi.py +83 -0
- os_normalizer-0.5.1/os_normalizer/parsers/linux.py +132 -0
- os_normalizer-0.5.1/os_normalizer/parsers/macos.py +109 -0
- os_normalizer-0.5.1/os_normalizer/parsers/mobile.py +55 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/__init__.py +65 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/cisco.py +102 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/fortinet.py +64 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/huawei.py +44 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/juniper.py +48 -0
- os_normalizer-0.5.1/os_normalizer/parsers/network/netgear.py +44 -0
- os_normalizer-0.5.1/os_normalizer/parsers/solaris.py +100 -0
- os_normalizer-0.5.1/os_normalizer/parsers/windows.py +317 -0
- os_normalizer-0.5.1/pyproject.toml +85 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Signature: 8a477f597d28d172789f06886806bc55
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
This file adheres to Keep a Changelog and Semantic Versioning.
|
|
5
|
+
|
|
6
|
+
## `v0.5.1` — [Unreleased]
|
|
7
|
+
|
|
8
|
+
- Added BSD parser support for `/etc/os-release` blobs (FreeBSD, OpenBSD, NetBSD) plus fixtures that lock codename/channel/distro handling.
|
|
9
|
+
- Normalized the hyphenated `x86-64` architecture alias to `x86_64` and added regression coverage in the Linux suite.
|
|
10
|
+
- Fixed Windows fallback parsing so bare “Windows” banners no longer crash, now emit family-level `OSData`, and keep kernel metadata unset when unknown.
|
|
11
|
+
|
|
12
|
+
## `v0.5.0` — [2025-10-30]
|
|
13
|
+
|
|
14
|
+
- Update release docs, add 3.14 classifier, sort imports [b7e07de]
|
|
15
|
+
- Add a ton more architectures and extract into constants [bd481f8]
|
|
16
|
+
- Add esxi and solaris support [8c14505]
|
|
17
|
+
- Set the unreleased tag for uv-ship [791361c]
|
|
18
|
+
|
|
19
|
+
## `v0.4.4` — [2025-10-25]
|
|
20
|
+
|
|
21
|
+
- Add uv-ship config [afd3bed]
|
|
22
|
+
- Merge pull request #2 from johnscillieri/codex/refactor-family-strings-into-constants [cf84c0f]
|
|
23
|
+
- Polish enum usage and update changelog [c3fb7f4]
|
|
24
|
+
- Merge pull request #1 from johnscillieri/codex/add-support-for-huawei-harmonyos [45fe0f9]
|
|
25
|
+
- Document HarmonyOS support addition [584ed2f]
|
|
26
|
+
- Added: HarmonyOS detection for Huawei devices, including dedicated parsing and metadata.
|
|
27
|
+
- Added: HarmonyOS normalization captures build identifiers (e.g., `5.0.0.107`) and propagates them into generated CPE data.
|
|
28
|
+
- Changed: Replaced string literals for OS families and precision tiers with shared enums and ordering constants across the normalization pipeline.
|
|
29
|
+
|
|
30
|
+
## [0.4.3] - 2025-10-20
|
|
31
|
+
|
|
32
|
+
- Fixed: Windows build parsing and inconsistent strings
|
|
33
|
+
|
|
34
|
+
## [0.4.2] - 2025-10-20
|
|
35
|
+
|
|
36
|
+
- Fixed: Windows product fingerprinting by build number
|
|
37
|
+
|
|
38
|
+
## [0.4.1] - 2025-09-25
|
|
39
|
+
|
|
40
|
+
- Added: Broadened Windows product aliases (e.g., Win11, Win2k) and recognized the macOS 26 codename `Tahoe`.
|
|
41
|
+
- Changed: Windows normalization now always fills NT version major/minor fields and treats marketing releases (21H2/24H2/etc.) as the kernel version for richer telemetry.
|
|
42
|
+
- Changed: Windows CPE generation derives release-channel tokens from build numbers so clients emit `windows_10_21h2`, `windows_11_24h2`, and similar slugs automatically.
|
|
43
|
+
- Fixed: Windows 11 and Server 2025 inputs no longer fall back to Windows 10 defaults, and legacy server builds keep their correct product names.
|
|
44
|
+
- Fixed: Windows `OSData` string formatting avoids duplicate fragments and skips redundant kernel numbers when printing friendly names.
|
|
45
|
+
|
|
46
|
+
## [0.4.0] - 2025-09-22
|
|
47
|
+
|
|
48
|
+
- Changed: Windows parser now normalizes typoed `windws` tokens, infers server editions from `Windows 2008/2012/2003` strings, and derives build numbers from generic `6.x.yyyy` patterns.
|
|
49
|
+
- Fixed: Windows Server 2012 R2 and older NT-based servers are correctly identified when only kernel/build identifiers are present.
|
|
50
|
+
- Fixed: OSData now always captures `kernel_version`/`version_build` for telemetry-only inputs.
|
|
51
|
+
|
|
52
|
+
## [0.3.4] - 2025-09-21
|
|
53
|
+
|
|
54
|
+
- Added: Extensive Windows kernel/build fixtures (e.g., `Windows 7601 6.1.7601 ...`) to lock in parsing of raw telemetry strings.
|
|
55
|
+
- Added: Coverage for Windows Server kernel identifiers to ensure server products are emitted with matching CPE metadata.
|
|
56
|
+
- Added: Regression tests for Redstone/Windows 10 marketing channels and mixed-case architecture tokens.
|
|
57
|
+
|
|
58
|
+
## [0.3.3] - 2025-09-21
|
|
59
|
+
|
|
60
|
+
- Added: `tests/case_utils.py` to share parametrization helpers across suites.
|
|
61
|
+
- Added: Platform-specific suites for clearer test changes.
|
|
62
|
+
- Removed: Legacy `tests/test_os_normalizer.py` harness now that coverage lives beside each platform.
|
|
63
|
+
|
|
64
|
+
## [0.3.2] - 2025-09-11
|
|
65
|
+
|
|
66
|
+
- Added: More `pyproject.toml` metadata (description, keywords, classifiers, project URLs).
|
|
67
|
+
- Added: `LICENSE` (MIT) and referenced it from project metadata.
|
|
68
|
+
- Added: `RELEASING.md` with step-by-step TestPyPI/PyPI instructions.
|
|
69
|
+
- Changed: Switched to Hatchling build backend via `[build-system]` in `pyproject.toml`.
|
|
70
|
+
- Changed: Exclude dev artifacts from sdist (`tests/`, caches, lockfiles, egg-info).
|
|
71
|
+
|
|
72
|
+
## [0.3.1] - 2025-09-09
|
|
73
|
+
|
|
74
|
+
- Added: Table printing of all OS values.
|
|
75
|
+
|
|
76
|
+
## [0.3.0] - 2025-09-09
|
|
77
|
+
|
|
78
|
+
- Added: Support merging in new data to combine observations.
|
|
79
|
+
- Added: Tests covering merge behavior.
|
|
80
|
+
|
|
81
|
+
## [0.2.0] - 2025-09-09
|
|
82
|
+
|
|
83
|
+
- Added: Additional `os_key` data for broader OS coverage.
|
|
84
|
+
- Changed: Improve Linux and macOS parsing; update BSD product extraction; better Windows version identification; fix Darwin kernel parsing.
|
|
85
|
+
- Changed: Break up network parsing into vendor-specific modules; general code cleanup; repo structure tidy-up.
|
|
86
|
+
- Changed: Rename `OSParse` to `OSData`; project renamed to `os_normalizer`.
|
|
87
|
+
- Changed: Adopt Ruff and reformat codebase; fix linter errors; improve test harness.
|
|
88
|
+
- Fixed: Failing tests (including `tests/test_full.py`).
|
|
89
|
+
- Removed: Old `Observation` class; now parse text and data directly.
|
|
90
|
+
|
|
91
|
+
## [0.1.0] - 2025-09-06
|
|
92
|
+
|
|
93
|
+
- Initial release.
|
|
94
|
+
|
|
95
|
+
[Unreleased]: https://github.com/johnscillieri/os-normalizer/compare/v0.4.1...HEAD
|
|
96
|
+
[0.4.1]: https://github.com/johnscillieri/os-normalizer/compare/v0.4.0...v0.4.1
|
|
97
|
+
[0.4.0]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.4...v0.4.0
|
|
98
|
+
[0.3.4]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.3...v0.3.4
|
|
99
|
+
[0.3.3]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.2...v0.3.3
|
|
100
|
+
[0.3.2]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.1...v0.3.2
|
|
101
|
+
[0.3.1]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.0...v0.3.1
|
|
102
|
+
[0.3.0]: https://github.com/johnscillieri/os-normalizer/compare/v0.2.0...v0.3.0
|
|
103
|
+
[0.2.0]: https://github.com/johnscillieri/os-normalizer/compare/v0.1.0...v0.2.0
|
|
104
|
+
[0.1.0]: https://github.com/johnscillieri/os-normalizer/releases/tag/v0.1.0
|
|
@@ -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.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: os-normalizer
|
|
3
|
+
Version: 0.5.1
|
|
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: Programming Language :: Python :: 3.14
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
43
|
+
Classifier: Topic :: System :: Operating System
|
|
44
|
+
Requires-Python: >=3.11
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# OS Normalizer
|
|
48
|
+
|
|
49
|
+
A Python library for identifying and parsing operating system information from various sources.
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
|
|
53
|
+
The OS Normalizer library parses raw operating system strings and supplimental data to identify the OS family, version, architecture, and other details. It supports parsing of:
|
|
54
|
+
|
|
55
|
+
- Windows (NT builds, versions)
|
|
56
|
+
- macOS (Darwin versions, codenames)
|
|
57
|
+
- Linux distributions (Ubuntu, Debian, Red Hat, etc.)
|
|
58
|
+
- iOS and Android mobile OS
|
|
59
|
+
- BSD variants (FreeBSD, OpenBSD, NetBSD)
|
|
60
|
+
- Network operating systems (Cisco IOS, Junos, FortiOS, etc.)
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install os-normalizer
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
The main entry point is the `normalize_os` function, which takes a string and an optional data dictionary and returns a structured `OSData` result.
|
|
71
|
+
|
|
72
|
+
### Basic Usage
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from os_normalizer import normalize_os
|
|
76
|
+
|
|
77
|
+
# Parse the OS information
|
|
78
|
+
result = normalize_os("Windows NT 10.0 build 22631 Enterprise x64")
|
|
79
|
+
print(result.family) # windows
|
|
80
|
+
print(result.product) # Windows 11
|
|
81
|
+
print(result.version_major) # 11
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Using OS Release Data
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from os_normalizer import normalize_os
|
|
88
|
+
|
|
89
|
+
# Fingerprint with both raw string and contents of os-release file
|
|
90
|
+
raw_os_string="Linux host 5.15.0-122-generic x86_64"
|
|
91
|
+
os_release_data={
|
|
92
|
+
"os_release": 'NAME="Ubuntu"\nID=ubuntu\nVERSION_ID="22.04.4"\nVERSION_CODENAME=jammy\nPRETTY_NAME="Ubuntu 22.04.4 LTS"'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
result = normalize_os(raw_os_string, os_release_data)
|
|
96
|
+
print(result.family) # linux
|
|
97
|
+
print(result.product) # Ubuntu
|
|
98
|
+
print(result.codename) # Jammy
|
|
99
|
+
print(result.arch) # x86_64
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Parsing Network Operating Systems
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from os_normalizer import normalize_os
|
|
106
|
+
|
|
107
|
+
# Parse Cisco IOS XE
|
|
108
|
+
raw_os_string="Cisco IOS XE Software, Version 17.9.4a (Amsterdam) C9300-24T, universalk9, c9300-universalk9.17.09.04a.SPA.bin"
|
|
109
|
+
|
|
110
|
+
result = normalize_os(raw_os_string)
|
|
111
|
+
print(result.family) # network-os
|
|
112
|
+
print(result.vendor) # Cisco
|
|
113
|
+
print(result.product) # IOS XE
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Models
|
|
117
|
+
|
|
118
|
+
### OSData
|
|
119
|
+
|
|
120
|
+
Represents structured operating system information:
|
|
121
|
+
|
|
122
|
+
- `family`: OS family (windows, linux, macos, ios, android, bsd, network-os)
|
|
123
|
+
- `vendor`: Vendor name (Microsoft, Apple, Cisco, etc.)
|
|
124
|
+
- `product`: Product name (Windows 11, Ubuntu, macOS, etc.)
|
|
125
|
+
- `edition`: Edition information (Pro, Enterprise, etc.)
|
|
126
|
+
- `codename`: Release codename (Sequoia, Ventura, etc.)
|
|
127
|
+
- `channel`: Release channel (GA, LTS, etc.)
|
|
128
|
+
- `version_major`, `version_minor`, `version_patch`, `version_build`: Version components
|
|
129
|
+
- `kernel_name`, `kernel_version`: Kernel details
|
|
130
|
+
- `arch`: Architecture (x86_64, arm64, etc.)
|
|
131
|
+
- `distro`: Distribution name
|
|
132
|
+
- `like_distros`: List of similar distributions
|
|
133
|
+
- `pretty_name`: Pretty formatted name
|
|
134
|
+
- `hw_model`, `build_id`: Network device details
|
|
135
|
+
- `precision`: Precision level (family, product, major, minor, patch, build)
|
|
136
|
+
- `confidence`: Confidence score (0.0 to 1.0)
|
|
137
|
+
- `evidence`: Evidence used for parsing decisions
|
|
138
|
+
- `os_key`: Canonical key for deduplication
|
|
139
|
+
|
|
140
|
+
## Architecture
|
|
141
|
+
|
|
142
|
+
The library follows a modular architecture:
|
|
143
|
+
|
|
144
|
+
- **os_normalizer.py**: Main orchestration logic that delegates to appropriate parsers
|
|
145
|
+
- **parsers/**: OS-specific parsers (macOS, Linux, Windows, Network, Mobile, BSD)
|
|
146
|
+
- **models.py**: Data models for parsed results
|
|
147
|
+
- **constants.py**: Static lookup tables (aliases, build maps, codenames)
|
|
148
|
+
- **helpers.py**: Utility functions (architecture extraction, confidence calculation)
|
|
149
|
+
|
|
150
|
+
## Testing
|
|
151
|
+
|
|
152
|
+
You can run tests with uv in a few ways:
|
|
153
|
+
|
|
154
|
+
- Ephemeral runner (downloads pytest if needed):
|
|
155
|
+
- `uvx pytest`
|
|
156
|
+
- Use the project environment and dev dependencies declared in `pyproject.toml`:
|
|
157
|
+
- `uv run --group dev pytest`
|
|
158
|
+
- Optional editable install for import paths:
|
|
159
|
+
- `uv pip install -e .`
|
|
160
|
+
- `uv run pytest`
|
|
161
|
+
|
|
162
|
+
### Using Nox (with nox-uv)
|
|
163
|
+
|
|
164
|
+
If you prefer repeatable sessions, this project includes Nox configured with the `nox-uv` plugin so virtualenvs are created via `uv`:
|
|
165
|
+
|
|
166
|
+
- Run tests: `uv run nox`
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# OS Normalizer
|
|
2
|
+
|
|
3
|
+
A Python library for identifying and parsing operating system information from various sources.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The OS Normalizer library parses raw operating system strings and supplimental data to identify the OS family, version, architecture, and other details. It supports parsing of:
|
|
8
|
+
|
|
9
|
+
- Windows (NT builds, versions)
|
|
10
|
+
- macOS (Darwin versions, codenames)
|
|
11
|
+
- Linux distributions (Ubuntu, Debian, Red Hat, etc.)
|
|
12
|
+
- iOS and Android mobile OS
|
|
13
|
+
- BSD variants (FreeBSD, OpenBSD, NetBSD)
|
|
14
|
+
- Network operating systems (Cisco IOS, Junos, FortiOS, etc.)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install os-normalizer
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
The main entry point is the `normalize_os` function, which takes a string and an optional data dictionary and returns a structured `OSData` result.
|
|
25
|
+
|
|
26
|
+
### Basic Usage
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from os_normalizer import normalize_os
|
|
30
|
+
|
|
31
|
+
# Parse the OS information
|
|
32
|
+
result = normalize_os("Windows NT 10.0 build 22631 Enterprise x64")
|
|
33
|
+
print(result.family) # windows
|
|
34
|
+
print(result.product) # Windows 11
|
|
35
|
+
print(result.version_major) # 11
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Using OS Release Data
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from os_normalizer import normalize_os
|
|
42
|
+
|
|
43
|
+
# Fingerprint with both raw string and contents of os-release file
|
|
44
|
+
raw_os_string="Linux host 5.15.0-122-generic x86_64"
|
|
45
|
+
os_release_data={
|
|
46
|
+
"os_release": 'NAME="Ubuntu"\nID=ubuntu\nVERSION_ID="22.04.4"\nVERSION_CODENAME=jammy\nPRETTY_NAME="Ubuntu 22.04.4 LTS"'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
result = normalize_os(raw_os_string, os_release_data)
|
|
50
|
+
print(result.family) # linux
|
|
51
|
+
print(result.product) # Ubuntu
|
|
52
|
+
print(result.codename) # Jammy
|
|
53
|
+
print(result.arch) # x86_64
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Parsing Network Operating Systems
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from os_normalizer import normalize_os
|
|
60
|
+
|
|
61
|
+
# Parse Cisco IOS XE
|
|
62
|
+
raw_os_string="Cisco IOS XE Software, Version 17.9.4a (Amsterdam) C9300-24T, universalk9, c9300-universalk9.17.09.04a.SPA.bin"
|
|
63
|
+
|
|
64
|
+
result = normalize_os(raw_os_string)
|
|
65
|
+
print(result.family) # network-os
|
|
66
|
+
print(result.vendor) # Cisco
|
|
67
|
+
print(result.product) # IOS XE
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Models
|
|
71
|
+
|
|
72
|
+
### OSData
|
|
73
|
+
|
|
74
|
+
Represents structured operating system information:
|
|
75
|
+
|
|
76
|
+
- `family`: OS family (windows, linux, macos, ios, android, bsd, network-os)
|
|
77
|
+
- `vendor`: Vendor name (Microsoft, Apple, Cisco, etc.)
|
|
78
|
+
- `product`: Product name (Windows 11, Ubuntu, macOS, etc.)
|
|
79
|
+
- `edition`: Edition information (Pro, Enterprise, etc.)
|
|
80
|
+
- `codename`: Release codename (Sequoia, Ventura, etc.)
|
|
81
|
+
- `channel`: Release channel (GA, LTS, etc.)
|
|
82
|
+
- `version_major`, `version_minor`, `version_patch`, `version_build`: Version components
|
|
83
|
+
- `kernel_name`, `kernel_version`: Kernel details
|
|
84
|
+
- `arch`: Architecture (x86_64, arm64, etc.)
|
|
85
|
+
- `distro`: Distribution name
|
|
86
|
+
- `like_distros`: List of similar distributions
|
|
87
|
+
- `pretty_name`: Pretty formatted name
|
|
88
|
+
- `hw_model`, `build_id`: Network device details
|
|
89
|
+
- `precision`: Precision level (family, product, major, minor, patch, build)
|
|
90
|
+
- `confidence`: Confidence score (0.0 to 1.0)
|
|
91
|
+
- `evidence`: Evidence used for parsing decisions
|
|
92
|
+
- `os_key`: Canonical key for deduplication
|
|
93
|
+
|
|
94
|
+
## Architecture
|
|
95
|
+
|
|
96
|
+
The library follows a modular architecture:
|
|
97
|
+
|
|
98
|
+
- **os_normalizer.py**: Main orchestration logic that delegates to appropriate parsers
|
|
99
|
+
- **parsers/**: OS-specific parsers (macOS, Linux, Windows, Network, Mobile, BSD)
|
|
100
|
+
- **models.py**: Data models for parsed results
|
|
101
|
+
- **constants.py**: Static lookup tables (aliases, build maps, codenames)
|
|
102
|
+
- **helpers.py**: Utility functions (architecture extraction, confidence calculation)
|
|
103
|
+
|
|
104
|
+
## Testing
|
|
105
|
+
|
|
106
|
+
You can run tests with uv in a few ways:
|
|
107
|
+
|
|
108
|
+
- Ephemeral runner (downloads pytest if needed):
|
|
109
|
+
- `uvx pytest`
|
|
110
|
+
- Use the project environment and dev dependencies declared in `pyproject.toml`:
|
|
111
|
+
- `uv run --group dev pytest`
|
|
112
|
+
- Optional editable install for import paths:
|
|
113
|
+
- `uv pip install -e .`
|
|
114
|
+
- `uv run pytest`
|
|
115
|
+
|
|
116
|
+
### Using Nox (with nox-uv)
|
|
117
|
+
|
|
118
|
+
If you prefer repeatable sessions, this project includes Nox configured with the `nox-uv` plugin so virtualenvs are created via `uv`:
|
|
119
|
+
|
|
120
|
+
- Run tests: `uv run nox`
|
|
121
|
+
|
|
122
|
+
## Contributing
|
|
123
|
+
|
|
124
|
+
Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Releasing to PyPI
|
|
2
|
+
|
|
3
|
+
This project uses a modern PEP 621 `pyproject.toml` with the Hatchling build backend. Below are the steps to build and publish to PyPI using uv-ship.
|
|
4
|
+
|
|
5
|
+
## Prereqs
|
|
6
|
+
|
|
7
|
+
- Python 3.11+
|
|
8
|
+
- `uv` installed (https://github.com/astral-sh/uv)
|
|
9
|
+
- `uv-ship` installed (via `uv tool install uv-ship`)
|
|
10
|
+
- PyPI accounts and API tokens for TestPyPI and/or PyPI
|
|
11
|
+
|
|
12
|
+
## Run tests and lint
|
|
13
|
+
|
|
14
|
+
- `uv run pytest`
|
|
15
|
+
- Optionally: `uv run nox`
|
|
16
|
+
|
|
17
|
+
## Releasing
|
|
18
|
+
|
|
19
|
+
- `uv-ship next <type>` where type is major|minor|patch
|
|
20
|
+
- Follow the prompts and release the new version to Github
|
|
21
|
+
- `rm -rf dist`
|
|
22
|
+
- `uv build`
|
|
23
|
+
- `uvx twine upload dist/*`
|