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.5.1.tar.gz (28.5 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.5.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for os_normalizer-0.5.1.tar.gz
Algorithm Hash digest
SHA256 0974d3f427d555d5c212e628ec3eaa6386bdc938b9565c97089b6262af984864
MD5 9806d3ea7b2728a9a65b5f8dd8227ce0
BLAKE2b-256 7c79f5c91cbdd98d064016e7532945c35d383c850e50886f4f03827939d4bee7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for os_normalizer-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c5d550d8f772010c93a7687e57e20d9acd35abf76d0de0641829f8616f1562a
MD5 e3b2ea943077c0fba42e76330f1d4730
BLAKE2b-256 629e02d1e671f9bc43849c4b13934599bfa67a04381ea58f343e324cf6417fd3

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