os-normalizer 0.3.2__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.
Potentially problematic release.
This version of os-normalizer might be problematic. Click here for more details.
- os_normalizer-0.3.2/.gitignore +10 -0
- os_normalizer-0.3.2/.python-version +1 -0
- os_normalizer-0.3.2/CHANGELOG.md +35 -0
- os_normalizer-0.3.2/LICENSE +21 -0
- os_normalizer-0.3.2/PKG-INFO +172 -0
- os_normalizer-0.3.2/README.md +127 -0
- os_normalizer-0.3.2/RELEASING.md +71 -0
- os_normalizer-0.3.2/os_normalizer/__init__.py +10 -0
- os_normalizer-0.3.2/os_normalizer/constants.py +87 -0
- os_normalizer-0.3.2/os_normalizer/cpe.py +265 -0
- os_normalizer-0.3.2/os_normalizer/helpers.py +107 -0
- os_normalizer-0.3.2/os_normalizer/models.py +159 -0
- os_normalizer-0.3.2/os_normalizer/os_normalizer.py +313 -0
- os_normalizer-0.3.2/os_normalizer/parsers/__init__.py +16 -0
- os_normalizer-0.3.2/os_normalizer/parsers/bsd.py +69 -0
- os_normalizer-0.3.2/os_normalizer/parsers/linux.py +121 -0
- os_normalizer-0.3.2/os_normalizer/parsers/macos.py +111 -0
- os_normalizer-0.3.2/os_normalizer/parsers/mobile.py +37 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/__init__.py +61 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/cisco.py +96 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/fortinet.py +56 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/huawei.py +38 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/juniper.py +42 -0
- os_normalizer-0.3.2/os_normalizer/parsers/network/netgear.py +41 -0
- os_normalizer-0.3.2/os_normalizer/parsers/windows.py +197 -0
- os_normalizer-0.3.2/pyproject.toml +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.3.1] - 2025-09-09
|
|
9
|
+
|
|
10
|
+
- Added: Table printing of all OS values.
|
|
11
|
+
|
|
12
|
+
## [0.3.0] - 2025-09-09
|
|
13
|
+
|
|
14
|
+
- Added: Support merging in new data to combine observations.
|
|
15
|
+
- Added: Tests covering merge behavior.
|
|
16
|
+
|
|
17
|
+
## [0.2.0] - 2025-09-09
|
|
18
|
+
|
|
19
|
+
- Added: Additional `os_key` data for broader OS coverage.
|
|
20
|
+
- Changed: Improve Linux and macOS parsing; update BSD product extraction; better Windows version identification; fix Darwin kernel parsing.
|
|
21
|
+
- Changed: Break up network parsing into vendor-specific modules; general code cleanup; repo structure tidy-up.
|
|
22
|
+
- Changed: Rename `OSParse` to `OSData`; project renamed to `os_normalizer`.
|
|
23
|
+
- Changed: Adopt Ruff and reformat codebase; fix linter errors; improve test harness.
|
|
24
|
+
- Fixed: Failing tests (including `tests/test_full.py`).
|
|
25
|
+
- Removed: Old `Observation` class; now parse text and data directly.
|
|
26
|
+
|
|
27
|
+
## [0.1.0] - 2025-09-06
|
|
28
|
+
|
|
29
|
+
- Initial release.
|
|
30
|
+
|
|
31
|
+
[Unreleased]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.1...HEAD
|
|
32
|
+
[0.3.1]: https://github.com/johnscillieri/os-normalizer/compare/v0.3.0...v0.3.1
|
|
33
|
+
[0.3.0]: https://github.com/johnscillieri/os-normalizer/compare/v0.2.0...v0.3.0
|
|
34
|
+
[0.2.0]: https://github.com/johnscillieri/os-normalizer/compare/v0.1.0...v0.2.0
|
|
35
|
+
[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,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,127 @@
|
|
|
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 JSON 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 Raw OS JSON Data
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from os_normalizer import normalize_os
|
|
42
|
+
|
|
43
|
+
# Fingerprint with both raw string and JSON data
|
|
44
|
+
raw_os_string="Linux host 5.15.0-122-generic x86_64"
|
|
45
|
+
raw_os_json={
|
|
46
|
+
"os_release": 'NAME="Ubuntu"\nID=ubuntu\nVERSION_ID="22.04.4"\nVERSION_CODENAME=jammy\nPRETTY_NAME="Ubuntu 22.04.4 LTS"'}
|
|
47
|
+
|
|
48
|
+
result = normalize_os(raw_os_string, raw_os_json)
|
|
49
|
+
print(result.family) # linux
|
|
50
|
+
print(result.product) # Ubuntu
|
|
51
|
+
print(result.codename) # Jammy
|
|
52
|
+
print(result.arch) # x86_64
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Parsing Network Operating Systems
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from os_normalizer import normalize_os
|
|
59
|
+
|
|
60
|
+
# Parse Cisco IOS XE
|
|
61
|
+
raw_os_string="Cisco IOS XE Software, Version 17.9.4a (Amsterdam) C9300-24T, universalk9, c9300-universalk9.17.09.04a.SPA.bin"
|
|
62
|
+
|
|
63
|
+
result = normalize_os(raw_os_string)
|
|
64
|
+
print(result.family) # network-os
|
|
65
|
+
print(result.vendor) # Cisco
|
|
66
|
+
print(result.product) # IOS XE
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Models
|
|
70
|
+
|
|
71
|
+
### OSData
|
|
72
|
+
|
|
73
|
+
Represents structured operating system information:
|
|
74
|
+
|
|
75
|
+
- `family`: OS family (windows, linux, macos, ios, android, bsd, network-os)
|
|
76
|
+
- `vendor`: Vendor name (Microsoft, Apple, Cisco, etc.)
|
|
77
|
+
- `product`: Product name (Windows 11, Ubuntu, macOS, etc.)
|
|
78
|
+
- `edition`: Edition information (Pro, Enterprise, etc.)
|
|
79
|
+
- `codename`: Release codename (Sequoia, Ventura, etc.)
|
|
80
|
+
- `channel`: Release channel (GA, LTS, etc.)
|
|
81
|
+
- `version_major`, `version_minor`, `version_patch`, `version_build`: Version components
|
|
82
|
+
- `kernel_name`, `kernel_version`: Kernel details
|
|
83
|
+
- `arch`: Architecture (x86_64, arm64, etc.)
|
|
84
|
+
- `distro`: Distribution name
|
|
85
|
+
- `like_distros`: List of similar distributions
|
|
86
|
+
- `pretty_name`: Pretty formatted name
|
|
87
|
+
- `hw_model`, `build_id`: Network device details
|
|
88
|
+
- `precision`: Precision level (family, product, major, minor, patch, build)
|
|
89
|
+
- `confidence`: Confidence score (0.0 to 1.0)
|
|
90
|
+
- `evidence`: Evidence used for parsing decisions
|
|
91
|
+
- `os_key`: Canonical key for deduplication
|
|
92
|
+
|
|
93
|
+
## Architecture
|
|
94
|
+
|
|
95
|
+
The library follows a modular architecture:
|
|
96
|
+
|
|
97
|
+
- **os_normalizer.py**: Main orchestration logic that delegates to appropriate parsers
|
|
98
|
+
- **parsers/**: OS-specific parsers (macOS, Linux, Windows, Network, Mobile, BSD)
|
|
99
|
+
- **models.py**: Data models for parsed results
|
|
100
|
+
- **constants.py**: Static lookup tables (aliases, build maps, codenames)
|
|
101
|
+
- **helpers.py**: Utility functions (architecture extraction, confidence calculation)
|
|
102
|
+
|
|
103
|
+
## Testing
|
|
104
|
+
|
|
105
|
+
You can run tests with uv in a few ways:
|
|
106
|
+
|
|
107
|
+
- Ephemeral runner (downloads pytest if needed):
|
|
108
|
+
- `uvx pytest`
|
|
109
|
+
- Use the project environment and dev dependencies declared in `pyproject.toml`:
|
|
110
|
+
- `uv run --group dev pytest`
|
|
111
|
+
- Optional editable install for import paths:
|
|
112
|
+
- `uv pip install -e .`
|
|
113
|
+
- `uv run pytest`
|
|
114
|
+
|
|
115
|
+
### Using Nox (with nox-uv)
|
|
116
|
+
|
|
117
|
+
If you prefer repeatable sessions, this project includes Nox configured with the `nox-uv` plugin so virtualenvs are created via `uv`:
|
|
118
|
+
|
|
119
|
+
- Run tests: `uv run nox`
|
|
120
|
+
|
|
121
|
+
## Contributing
|
|
122
|
+
|
|
123
|
+
Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
@@ -0,0 +1,71 @@
|
|
|
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 TestPyPI and PyPI using uv (recommended) or Twine.
|
|
4
|
+
|
|
5
|
+
## Prereqs
|
|
6
|
+
|
|
7
|
+
- Python 3.11+
|
|
8
|
+
- `uv` installed (https://github.com/astral-sh/uv)
|
|
9
|
+
- PyPI accounts and API tokens for TestPyPI and/or PyPI
|
|
10
|
+
|
|
11
|
+
## Project metadata checklist
|
|
12
|
+
|
|
13
|
+
- Verify `pyproject.toml` fields:
|
|
14
|
+
- `name`, `version`, `description`, `readme`, `requires-python`
|
|
15
|
+
- `classifiers`, `keywords`, `license`
|
|
16
|
+
- `project.urls` (Homepage/Repository/Issues/Changelog)
|
|
17
|
+
- Ensure `LICENSE` exists and matches the license in `pyproject.toml`.
|
|
18
|
+
- Ensure `README.md` renders nicely on PyPI (use Markdown; referenced images should be absolute URLs).
|
|
19
|
+
- Update `CHANGELOG.md` with the release version and date.
|
|
20
|
+
- Optionally add `__version__` if you want a runtime version attribute.
|
|
21
|
+
|
|
22
|
+
## Run tests and lint
|
|
23
|
+
|
|
24
|
+
- `uv run --group dev pytest -q`
|
|
25
|
+
- Optionally: `uv run --group dev ruff check .`
|
|
26
|
+
|
|
27
|
+
## Build distributions
|
|
28
|
+
|
|
29
|
+
Using uv’s build:
|
|
30
|
+
|
|
31
|
+
- `uv build` # builds both sdist and wheel into `dist/`
|
|
32
|
+
|
|
33
|
+
Alternatively using `build`:
|
|
34
|
+
|
|
35
|
+
- `uvx build` # ephemeral install of the build frontend
|
|
36
|
+
|
|
37
|
+
## Verify distributions locally
|
|
38
|
+
|
|
39
|
+
- `uvx twine check dist/*`
|
|
40
|
+
|
|
41
|
+
## Publish to TestPyPI first (recommended)
|
|
42
|
+
|
|
43
|
+
1) Create a TestPyPI API token (https://test.pypi.org/manage/account/token/).
|
|
44
|
+
2) Upload:
|
|
45
|
+
- `uvx twine upload --repository testpypi dist/*`
|
|
46
|
+
3) Install and smoke test from TestPyPI in a clean env:
|
|
47
|
+
- `uv venv -p 3.11 .release-test`
|
|
48
|
+
- `uv run --python .release-test/bin/python -m pip install -U pip`
|
|
49
|
+
- `uv run --python .release-test/bin/python -m pip install -i https://test.pypi.org/simple/ os-normalizer`
|
|
50
|
+
- `uv run --python .release-test/bin/python -c "import os_normalizer as m; print(m.__all__)"`
|
|
51
|
+
|
|
52
|
+
## Publish to PyPI
|
|
53
|
+
|
|
54
|
+
1) Create a PyPI API token (https://pypi.org/manage/account/token/).
|
|
55
|
+
2) Upload:
|
|
56
|
+
- `uvx twine upload dist/*`
|
|
57
|
+
|
|
58
|
+
## Versioning and tagging
|
|
59
|
+
|
|
60
|
+
- Update `version` in `pyproject.toml` following SemVer (e.g., 0.3.2) by running
|
|
61
|
+
- `uv version --bump <major|minor|patch> --dry-run` <- confirm that's what you want
|
|
62
|
+
- `uv version --bump <major|minor|patch>`
|
|
63
|
+
|
|
64
|
+
- Tag the release in git once published:
|
|
65
|
+
- `git tag -a v0.3.2 -m "Release 0.3.2"`
|
|
66
|
+
- `git push origin v0.3.2`
|
|
67
|
+
|
|
68
|
+
## Post-release
|
|
69
|
+
|
|
70
|
+
- Bump to the next dev version if desired (e.g. `0.3.3.dev0`).
|
|
71
|
+
- Open an issue for any follow-ups or hotfixes discovered after release.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Constants and static lookup tables for the OS fingerprinting package."""
|
|
2
|
+
|
|
3
|
+
# Architecture synonyms
|
|
4
|
+
ARCH_SYNONYMS = {
|
|
5
|
+
"x64": "x86_64",
|
|
6
|
+
"x86_64": "x86_64",
|
|
7
|
+
"amd64": "x86_64",
|
|
8
|
+
"x86": "x86",
|
|
9
|
+
"i386": "x86",
|
|
10
|
+
"i686": "x86",
|
|
11
|
+
"aarch64": "arm64",
|
|
12
|
+
"arm64": "arm64",
|
|
13
|
+
"armv8": "arm64",
|
|
14
|
+
"armv7": "arm",
|
|
15
|
+
"armv7l": "arm",
|
|
16
|
+
"ppc64le": "ppc64le",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Windows build map (build number range -> product name, marketing channel)
|
|
20
|
+
WINDOWS_BUILD_MAP = [
|
|
21
|
+
# Windows 10
|
|
22
|
+
(10240, 10240, "Windows 10", "1507"),
|
|
23
|
+
(10586, 10586, "Windows 10", "1511"),
|
|
24
|
+
(14393, 14393, "Windows 10", "1607"),
|
|
25
|
+
(15063, 15063, "Windows 10", "1703"),
|
|
26
|
+
(16299, 16299, "Windows 10", "1709"),
|
|
27
|
+
(17134, 17134, "Windows 10", "1803"),
|
|
28
|
+
(17763, 17763, "Windows 10", "1809"),
|
|
29
|
+
(18362, 18363, "Windows 10", "1903/1909"),
|
|
30
|
+
(19041, 19045, "Windows 10", "2004/20H2/21H1/21H2/22H2"),
|
|
31
|
+
# Windows 11
|
|
32
|
+
(22000, 22000, "Windows 11", "21H2"),
|
|
33
|
+
(22621, 22630, "Windows 11", "22H2"),
|
|
34
|
+
(22631, 25999, "Windows 11", "23H2"),
|
|
35
|
+
(26100, 26199, "Windows 11", "24H2"),
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
# Windows NT version tuple -> client product (ambiguous NT 6.x split out)
|
|
39
|
+
WINDOWS_NT_CLIENT_MAP = {
|
|
40
|
+
(4, 0): "Windows NT 4.0",
|
|
41
|
+
(5, 0): "Windows 2000",
|
|
42
|
+
(5, 1): "Windows XP",
|
|
43
|
+
(5, 2): "Windows XP x64/Server 2003", # NT 5.2 often maps to XP x64 on client
|
|
44
|
+
(6, 0): "Windows Vista",
|
|
45
|
+
(6, 1): "Windows 7",
|
|
46
|
+
(6, 2): "Windows 8",
|
|
47
|
+
(6, 3): "Windows 8.1",
|
|
48
|
+
(10, 0): "Windows 10/11",
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Windows NT version tuple -> server product
|
|
52
|
+
WINDOWS_NT_SERVER_MAP = {
|
|
53
|
+
(4, 0): "Windows NT 4.0 Server",
|
|
54
|
+
(5, 0): "Windows 2000 Server",
|
|
55
|
+
(5, 1): "Windows XP/Server 2003", # rarely used for server detection
|
|
56
|
+
(5, 2): "Windows Server 2003",
|
|
57
|
+
(6, 0): "Windows Server 2008",
|
|
58
|
+
(6, 1): "Windows Server 2008 R2",
|
|
59
|
+
(6, 2): "Windows Server 2012",
|
|
60
|
+
(6, 3): "Windows Server 2012 R2",
|
|
61
|
+
# NT 10.0: Server 2016/2019/2022 detected via explicit names, not NT mapping
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Human readable aliases (macOS codenames)
|
|
65
|
+
MACOS_ALIASES = {
|
|
66
|
+
"sonoma": "macOS 14",
|
|
67
|
+
"sequoia": "macOS 15",
|
|
68
|
+
"ventura": "macOS 13",
|
|
69
|
+
"monterey": "macOS 12",
|
|
70
|
+
"big sur": "macOS 11",
|
|
71
|
+
"bigsur": "macOS 11",
|
|
72
|
+
"catalina": "macOS 10.15",
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# macOS Darwin major version -> (product name, product version, codename)
|
|
76
|
+
MACOS_DARWIN_MAP = {
|
|
77
|
+
19: ("macOS", "10.15", "Catalina"),
|
|
78
|
+
20: ("macOS", "11", "Big Sur"),
|
|
79
|
+
21: ("macOS", "12", "Monterey"),
|
|
80
|
+
22: ("macOS", "13", "Ventura"),
|
|
81
|
+
23: ("macOS", "14", "Sonoma"),
|
|
82
|
+
24: ("macOS", "15", "Sequoia"),
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Cisco train names (used for codename detection)
|
|
86
|
+
CISCO_TRAIN_NAMES = {"Everest", "Fuji", "Gibraltar", "Amsterdam", "Denali"}
|
|
87
|
+
|