Skip to main content

Normalize raw OS strings/metadata into structured data (family, product, version, arch).

Project description

OS Normalizer

A Python library for identifying and parsing operating system information from various sources.

Overview

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.)

Installation

pip install os-normalizer

Usage

The main entry point is the normalize_os function, which takes a string and an optional data dictionary and returns a structured OSData result.

Basic Usage

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)  # 11

Using OS Release Data

from 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_64

Parsing Network Operating Systems

from 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 XE

Models

OSData

Represents 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 components
  • kernel_name, kernel_version: Kernel details
  • arch: Architecture (x86_64, arm64, etc.)
  • distro: Distribution name
  • like_distros: List of similar distributions
  • pretty_name: Pretty formatted name
  • hw_model, build_id: Network device details
  • precision: Precision level (family, product, major, minor, patch, build)
  • confidence: Confidence score (0.0 to 1.0)
  • evidence: Evidence used for parsing decisions
  • os_key: Canonical key for deduplication

Architecture

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)

Testing

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

Using Nox (with nox-uv)

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

Contributing

Contributions are welcome! Please ensure that any new parsers or improvements follow the existing code patterns and include appropriate tests.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

os_normalizer-0.4.1.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

os_normalizer-0.4.1-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file os_normalizer-0.4.1.tar.gz.

File metadata

  • Download URL: os_normalizer-0.4.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for os_normalizer-0.4.1.tar.gz
Algorithm Hash digest
SHA256 f037ac9922f05b762f0bf54f528ffe5fa2f78f868bab5905a793b2cae36bac6e
MD5 3551b57390147a569d0a8b6a19d3c1b6
BLAKE2b-256 5eea312ffb2619f920781e79d0dac0fd031023fb8eed67726fba2aa5d1c8f16c

See more details on using hashes here.

File details

Details for the file os_normalizer-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: os_normalizer-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for os_normalizer-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e2ea3b0785e55f38fec7a5fa31aa668e62f4643f0d25075853c60c2e572a438
MD5 b54175b2bf4083302b07e8b591d21e9a
BLAKE2b-256 089094b5f38f8672db72ccab044947f541770a26c4e76f77353bf2adba7824fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page