A Python library for identifying and parsing operating system information from various sources.
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:
- Windows (NT builds, versions)
- macOS (Darwin versions, codenames)
- Linux distributions (Ubuntu, Debian, Red Hat, etc.)
- iOS and Android mobile OS
- BSD variants (FreeBSD, OpenBSD, NetBSD)
- Network operating systems (Cisco IOS, Junos, FortiOS, etc.)
pip install os-normalizerThe main entry point is the normalize_os function, which takes a string and an optional data dictionary and returns a structured OSData result.
from os_normalizer import normalize_os
# Parse the OS information
result = normalize_os("Windows NT 10.0 build 22631 Enterprise x64")
print(result.family) # windows
print(result.product) # Windows 11
print(result.version_major) # 11from os_normalizer import normalize_os
# Fingerprint with both raw string and contents of os-release file
raw_os_string="Linux host 5.15.0-122-generic x86_64"
os_release_data={
"os_release": 'NAME="Ubuntu"\nID=ubuntu\nVERSION_ID="22.04.4"\nVERSION_CODENAME=jammy\nPRETTY_NAME="Ubuntu 22.04.4 LTS"'
}
result = normalize_os(raw_os_string, os_release_data)
print(result.family) # linux
print(result.product) # Ubuntu
print(result.codename) # Jammy
print(result.arch) # x86_64from os_normalizer import normalize_os
# Parse Cisco IOS XE
raw_os_string="Cisco IOS XE Software, Version 17.9.4a (Amsterdam) C9300-24T, universalk9, c9300-universalk9.17.09.04a.SPA.bin"
result = normalize_os(raw_os_string)
print(result.family) # network-os
print(result.vendor) # Cisco
print(result.product) # IOS XERepresents structured operating system information:
family: OS family (windows, linux, macos, ios, android, bsd, network-os)vendor: Vendor name (Microsoft, Apple, Cisco, etc.)product: Product name (Windows 11, Ubuntu, macOS, etc.)edition: Edition information (Pro, Enterprise, etc.)codename: Release codename (Sequoia, Ventura, etc.)channel: Release channel (GA, LTS, etc.)version_major,version_minor,version_patch,version_build: Version componentskernel_name,kernel_version: Kernel detailsarch: Architecture (x86_64, arm64, etc.)distro: Distribution namelike_distros: List of similar distributionspretty_name: Pretty formatted namehw_model,build_id: Network device detailsprecision: Precision level (family, product, major, minor, patch, build)confidence: Confidence score (0.0 to 1.0)evidence: Evidence used for parsing decisionsos_key: Canonical key for deduplication
The library follows a modular architecture:
- os_normalizer.py: Main orchestration logic that delegates to appropriate parsers
- parsers/: OS-specific parsers (macOS, Linux, Windows, Network, Mobile, BSD)
- models.py: Data models for parsed results
- constants.py: Static lookup tables (aliases, build maps, codenames)
- helpers.py: Utility functions (architecture extraction, confidence calculation)
You can run tests with uv in a few ways:
- Ephemeral runner (downloads pytest if needed):
uvx pytest
- Use the project environment and dev dependencies declared in
pyproject.toml:uv run --group dev pytest
- Optional editable install for import paths:
uv pip install -e .uv run pytest
If you prefer repeatable sessions, this project includes Nox configured with the nox-uv plugin so virtualenvs are created via uv:
- Run tests:
uv run nox
Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.
MIT