snmpv3-utils 0.1.0__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.
Files changed (45) hide show
  1. snmpv3_utils-0.1.0/.env.example +13 -0
  2. snmpv3_utils-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  3. snmpv3_utils-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
  4. snmpv3_utils-0.1.0/.github/ISSUE_TEMPLATE/new_operation.md +22 -0
  5. snmpv3_utils-0.1.0/.github/pull_request_template.md +17 -0
  6. snmpv3_utils-0.1.0/.github/workflows/ci.yml +37 -0
  7. snmpv3_utils-0.1.0/.github/workflows/release.yml +59 -0
  8. snmpv3_utils-0.1.0/.gitignore +14 -0
  9. snmpv3_utils-0.1.0/.python-version +1 -0
  10. snmpv3_utils-0.1.0/CHANGELOG.md +22 -0
  11. snmpv3_utils-0.1.0/CLAUDE.md +49 -0
  12. snmpv3_utils-0.1.0/CONTRIBUTING.md +50 -0
  13. snmpv3_utils-0.1.0/PKG-INFO +107 -0
  14. snmpv3_utils-0.1.0/README.md +80 -0
  15. snmpv3_utils-0.1.0/docs/superpowers/plans/2026-03-20-snmpv3-utils.md +2942 -0
  16. snmpv3_utils-0.1.0/docs/superpowers/specs/2026-03-20-snmpv3-utils-design.md +282 -0
  17. snmpv3_utils-0.1.0/pyproject.toml +59 -0
  18. snmpv3_utils-0.1.0/src/snmpv3_utils/__init__.py +0 -0
  19. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/__init__.py +0 -0
  20. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/auth.py +90 -0
  21. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/main.py +46 -0
  22. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/profile.py +91 -0
  23. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/query.py +269 -0
  24. snmpv3_utils-0.1.0/src/snmpv3_utils/cli/trap.py +159 -0
  25. snmpv3_utils-0.1.0/src/snmpv3_utils/config.py +163 -0
  26. snmpv3_utils-0.1.0/src/snmpv3_utils/core/__init__.py +0 -0
  27. snmpv3_utils-0.1.0/src/snmpv3_utils/core/auth.py +80 -0
  28. snmpv3_utils-0.1.0/src/snmpv3_utils/core/query.py +315 -0
  29. snmpv3_utils-0.1.0/src/snmpv3_utils/core/trap.py +135 -0
  30. snmpv3_utils-0.1.0/src/snmpv3_utils/output.py +71 -0
  31. snmpv3_utils-0.1.0/src/snmpv3_utils/security.py +117 -0
  32. snmpv3_utils-0.1.0/tests/__init__.py +0 -0
  33. snmpv3_utils-0.1.0/tests/conftest.py +12 -0
  34. snmpv3_utils-0.1.0/tests/fixtures/.gitkeep +0 -0
  35. snmpv3_utils-0.1.0/tests/test_auth.py +127 -0
  36. snmpv3_utils-0.1.0/tests/test_cli_auth.py +38 -0
  37. snmpv3_utils-0.1.0/tests/test_cli_profile.py +38 -0
  38. snmpv3_utils-0.1.0/tests/test_cli_query.py +128 -0
  39. snmpv3_utils-0.1.0/tests/test_cli_trap.py +57 -0
  40. snmpv3_utils-0.1.0/tests/test_config.py +138 -0
  41. snmpv3_utils-0.1.0/tests/test_output.py +50 -0
  42. snmpv3_utils-0.1.0/tests/test_query.py +99 -0
  43. snmpv3_utils-0.1.0/tests/test_security.py +91 -0
  44. snmpv3_utils-0.1.0/tests/test_trap.py +40 -0
  45. snmpv3_utils-0.1.0/uv.lock +564 -0
@@ -0,0 +1,13 @@
1
+ # .env.example — copy to .env and fill in your values
2
+ # SNMPv3 credentials
3
+ SNMPV3_USERNAME=
4
+ SNMPV3_AUTH_PROTOCOL=SHA256 # MD5 | SHA1 | SHA256 | SHA512
5
+ SNMPV3_AUTH_KEY=
6
+ SNMPV3_PRIV_PROTOCOL=AES128 # DES | AES128 | AES256
7
+ SNMPV3_PRIV_KEY=
8
+ SNMPV3_SECURITY_LEVEL=authPriv # noAuthNoPriv | authNoPriv | authPriv
9
+
10
+ # Connection defaults
11
+ SNMPV3_PORT=161
12
+ SNMPV3_TIMEOUT=5
13
+ SNMPV3_RETRIES=3
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Bug report
3
+ about: Something is not working correctly
4
+ labels: bug
5
+ ---
6
+
7
+ **Describe the bug**
8
+ A clear description of what is wrong.
9
+
10
+ **Command run**
11
+ ```bash
12
+ snmpv3 ...
13
+ ```
14
+
15
+ **Expected behavior**
16
+
17
+ **Actual behavior / error output**
18
+
19
+ **Environment**
20
+ - OS:
21
+ - Python version:
22
+ - snmpv3-utils version: (`snmpv3 --version`)
23
+ - pysnmp version:
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an improvement or new capability
4
+ labels: enhancement
5
+ ---
6
+
7
+ **What would you like to see?**
8
+
9
+ **Why is this useful?**
10
+
11
+ **Any implementation ideas?**
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: New SNMP operation
3
+ about: Propose adding a new SNMP command
4
+ labels: enhancement, new-operation
5
+ ---
6
+
7
+ **Operation name and description**
8
+
9
+ **Which group does it belong to?**
10
+ - [ ] query
11
+ - [ ] trap
12
+ - [ ] auth
13
+ - [ ] new group (describe below)
14
+
15
+ **Proposed command signature**
16
+ ```bash
17
+ snmpv3 <group> <command> ...
18
+ ```
19
+
20
+ **pysnmp API used**
21
+
22
+ **Any edge cases to handle?**
@@ -0,0 +1,17 @@
1
+ ## Summary
2
+
3
+ Closes #
4
+
5
+ ## Changes
6
+
7
+ -
8
+
9
+ ## Checklist
10
+
11
+ - [ ] Tests written before implementation (TDD)
12
+ - [ ] `uv run pytest` passes
13
+ - [ ] `uv run ruff check .` passes
14
+ - [ ] `uv run ruff format --check .` passes
15
+ - [ ] `uv run mypy src/` passes
16
+ - [ ] `CHANGELOG.md` updated (if user-facing change)
17
+ - [ ] `README.md` updated (if new command or changed behavior)
@@ -0,0 +1,37 @@
1
+ # .github/workflows/ci.yml
2
+ name: ci
3
+
4
+ on:
5
+ pull_request:
6
+ branches: [main]
7
+ push:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ ci:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v4
18
+ with:
19
+ version: "latest"
20
+
21
+ - name: Set up Python
22
+ run: uv python install 3.11
23
+
24
+ - name: Install dependencies
25
+ run: uv sync --all-extras
26
+
27
+ - name: Lint (ruff)
28
+ run: uv run ruff check .
29
+
30
+ - name: Format check (ruff)
31
+ run: uv run ruff format --check .
32
+
33
+ - name: Type check (mypy)
34
+ run: uv run mypy src/
35
+
36
+ - name: Tests
37
+ run: uv run pytest --tb=short
@@ -0,0 +1,59 @@
1
+ # .github/workflows/release.yml
2
+ name: release
3
+
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*"
8
+
9
+ jobs:
10
+ release:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write # needed to create GitHub Release
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v4
20
+ with:
21
+ version: "latest"
22
+
23
+ - name: Set up Python
24
+ run: uv python install 3.11
25
+
26
+ - name: Install dependencies
27
+ run: uv sync --all-extras
28
+
29
+ - name: Run full CI suite
30
+ run: |
31
+ uv run ruff check .
32
+ uv run ruff format --check .
33
+ uv run mypy src/
34
+ uv run pytest --tb=short
35
+
36
+ - name: Build package
37
+ run: uv build
38
+
39
+ - name: Publish to PyPI
40
+ env:
41
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
42
+ run: uv publish
43
+
44
+ - name: Extract changelog entry for this tag
45
+ id: changelog
46
+ run: |
47
+ # Extract the section matching the tag version from CHANGELOG.md
48
+ TAG="${GITHUB_REF_NAME}"
49
+ VERSION="${TAG#v}"
50
+ BODY=$(awk "/^## \[${VERSION}\]/{found=1; next} found && /^## /{exit} found{print}" CHANGELOG.md)
51
+ echo "body<<EOF" >> "$GITHUB_OUTPUT"
52
+ echo "$BODY" >> "$GITHUB_OUTPUT"
53
+ echo "EOF" >> "$GITHUB_OUTPUT"
54
+
55
+ - name: Create GitHub Release
56
+ uses: softprops/action-gh-release@v2
57
+ with:
58
+ body: ${{ steps.changelog.outputs.body }}
59
+ files: dist/*
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ *.egg
8
+ .env
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .pytest_cache/
12
+ .coverage
13
+ htmlcov/
14
+ .DS_Store
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-03-20
11
+
12
+ ### Added
13
+ - Initial release with full SNMPv3 query, trap, and credential testing support
14
+ - `snmpv3 query` — GET, GETNEXT, WALK, BULK, SET
15
+ - `snmpv3 trap` — send (trap + inform), listen (stub, asyncio pending)
16
+ - `snmpv3 auth` — single credential check, bulk CSV check
17
+ - `snmpv3 profile` — add, delete, list, show profiles
18
+ - Full SNMPv3 security matrix: noAuthNoPriv, authNoPriv, authPriv
19
+ - Auth protocols: MD5, SHA1, SHA256, SHA512
20
+ - Priv protocols: DES, AES128, AES256
21
+ - Credential resolution: defaults → .env → profile → CLI flags
22
+ - Rich and JSON output via `--format` flag
@@ -0,0 +1,49 @@
1
+ # CLAUDE.md
2
+
3
+ Project instructions for AI assistants working on snmpv3-utils.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ uv sync --all-extras
9
+ ```
10
+
11
+ ## Key Commands
12
+
13
+ | Task | Command |
14
+ |------|---------|
15
+ | Run tests | `uv run pytest` |
16
+ | Lint | `uv run ruff check .` |
17
+ | Format | `uv run ruff format .` |
18
+ | Type check | `uv run mypy src/` |
19
+ | Run CLI | `uv run snmpv3 --help` |
20
+
21
+ ## Architecture Rules
22
+
23
+ - **`cli/`** — thin Typer wrappers only. No SNMP logic, no direct pysnmp imports.
24
+ - **`core/`** — all SNMP operations. Returns `dict` or `list[dict]`. No CLI, no rich.
25
+ - **`security.py`** — the only file that imports pysnmp auth/priv constants.
26
+ - **`output.py`** — the only file that imports rich. Takes dicts, formats for display.
27
+
28
+ ## Adding a New Operation
29
+
30
+ 1. Write the failing test in `tests/test_<module>.py`
31
+ 2. Implement in `core/<module>.py`
32
+ 3. Add the CLI command in `cli/<module>.py`
33
+ 4. Add a CLI test using typer's `CliRunner`
34
+ 5. Open an issue, work in a branch, open a PR
35
+
36
+ ## PR & Issue Workflow
37
+
38
+ - All work starts with a GitHub Issue
39
+ - Branch from `main`, name: `feat/<issue-number>-<short-description>`
40
+ - PRs require CI to pass (ruff, mypy, pytest)
41
+ - Conventional commits required: `feat:`, `fix:`, `docs:`, `chore:`, `test:`
42
+
43
+ ## pysnmp v7 Notes
44
+
45
+ - Import from `pysnmp.hlapi.v3arch.asyncio` (NOT `pysnmp.hlapi` — that's v6)
46
+ - Auth constants: `usmHMACMD5AuthProtocol`, `usmHMACSHAAuthProtocol`, `usmHMAC192SHA256AuthProtocol`, `usmHMAC384SHA512AuthProtocol`
47
+ - Priv constants: `usmDESPrivProtocol`, `usmAesCfb128Protocol`, `usmAesCfb256Protocol`
48
+ - All SNMP operations are async in v7 — core/ wraps them with `asyncio.run()`
49
+ - Trap listener requires asyncio (v7 removed asyncore dispatcher) — see `core/trap.py`
@@ -0,0 +1,50 @@
1
+ # Contributing to snmpv3-utils
2
+
3
+ Thank you for contributing! This guide covers everything you need to get started.
4
+
5
+ ## Prerequisites
6
+
7
+ - Python 3.11+
8
+ - [uv](https://docs.astral.sh/uv/) (`pip install uv` or `brew install uv`)
9
+ - [GitHub CLI](https://cli.github.com/) (`gh`) for issue/PR management
10
+
11
+ ## Dev Setup
12
+
13
+ ```bash
14
+ git clone https://github.com/<your-username>/snmpv3-utils
15
+ cd snmpv3-utils
16
+ uv sync --all-extras
17
+ ```
18
+
19
+ Verify everything works:
20
+ ```bash
21
+ uv run pytest
22
+ uv run snmpv3 --help
23
+ ```
24
+
25
+ ## Workflow
26
+
27
+ 1. **Find or create a GitHub Issue** for the work you want to do
28
+ 2. **Branch:** `git checkout -b feat/<issue-number>-short-description`
29
+ 3. **Write tests first** — we use TDD; tests live in `tests/`
30
+ 4. **Implement** — keep `cli/` thin and business logic in `core/`
31
+ 5. **Run checks locally** before pushing:
32
+ ```bash
33
+ uv run ruff check . && uv run ruff format . && uv run mypy src/ && uv run pytest
34
+ ```
35
+ 6. **Commit** using conventional commits: `feat:`, `fix:`, `docs:`, `chore:`, `test:`
36
+ 7. **Open a PR** and reference the issue with `Closes #<number>`
37
+
38
+ ## Adding a New SNMP Operation
39
+
40
+ 1. Add the core function in `src/snmpv3_utils/core/<module>.py` — return `dict`/`list[dict]`
41
+ 2. Add the CLI command in `src/snmpv3_utils/cli/<module>.py` — thin wrapper only
42
+ 3. Write tests for both in `tests/`
43
+ 4. Update `README.md` with usage example
44
+
45
+ ## Code Style
46
+
47
+ - Formatter + linter: `ruff` (configured in `pyproject.toml`)
48
+ - Type checker: `mypy --strict`
49
+ - No classes unless clearly warranted — prefer functions
50
+ - Docstrings on all public functions (one-liner is fine if self-evident)
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: snmpv3-utils
3
+ Version: 0.1.0
4
+ Summary: SNMPv3 CLI testing utility — GET, WALK, SET, traps, credential testing
5
+ License: MIT
6
+ Keywords: cli,network,snmp,snmpv3,testing
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: System Administrators
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Topic :: System :: Networking :: Monitoring
13
+ Requires-Python: >=3.11
14
+ Requires-Dist: platformdirs>=4.0
15
+ Requires-Dist: pysnmp>=7.0
16
+ Requires-Dist: python-dotenv>=1.0
17
+ Requires-Dist: rich>=13
18
+ Requires-Dist: tomli-w>=1.2
19
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
20
+ Requires-Dist: typer>=0.12
21
+ Provides-Extra: dev
22
+ Requires-Dist: mypy>=1.9; extra == 'dev'
23
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
24
+ Requires-Dist: pytest>=8; extra == 'dev'
25
+ Requires-Dist: ruff>=0.4; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # snmpv3-utils
29
+
30
+ A Python CLI for SNMPv3 testing. Most existing tools only support v1/v2 — this one does v3 properly.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pipx install snmpv3-utils
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ # GET a single OID
42
+ snmpv3 query get 192.168.1.1 1.3.6.1.2.1.1.1.0 \
43
+ --username admin \
44
+ --auth-protocol SHA256 --auth-key myauthpass \
45
+ --priv-protocol AES128 --priv-key myprivpass \
46
+ --security-level authPriv
47
+
48
+ # WALK the system MIB
49
+ snmpv3 query walk 192.168.1.1 1.3.6.1.2.1.1 --profile myrouter
50
+
51
+ # Send a trap
52
+ snmpv3 trap send 192.168.1.1 --profile myrouter
53
+
54
+ # Test credentials
55
+ snmpv3 auth check 192.168.1.1 --profile myrouter
56
+
57
+ # Bulk test from a CSV
58
+ snmpv3 auth bulk 192.168.1.1 --file creds.csv
59
+
60
+ # JSON output (for piping into jq)
61
+ snmpv3 query walk 192.168.1.1 1.3.6.1.2.1.1 --format json | jq '.[] | .value'
62
+ ```
63
+
64
+ ## Configuration
65
+
66
+ Copy `.env.example` to `.env` and fill in your defaults:
67
+
68
+ ```bash
69
+ cp .env.example .env
70
+ ```
71
+
72
+ Or use named profiles:
73
+
74
+ ```bash
75
+ snmpv3 profile add myrouter \
76
+ --username admin \
77
+ --auth-protocol SHA256 --auth-key myauthpass \
78
+ --priv-protocol AES128 --priv-key myprivpass \
79
+ --security-level authPriv
80
+ ```
81
+
82
+ ## Commands
83
+
84
+ | Group | Command | Description |
85
+ |-------|---------|-------------|
86
+ | `query` | `get` | Fetch a single OID |
87
+ | `query` | `getnext` | Single GETNEXT step |
88
+ | `query` | `walk` | Full subtree traversal |
89
+ | `query` | `bulk` | GETBULK retrieval |
90
+ | `query` | `set` | Set an OID value |
91
+ | `trap` | `send` | Send a trap or inform |
92
+ | `trap` | `listen` | Listen for incoming traps |
93
+ | `auth` | `check` | Test a credential set |
94
+ | `auth` | `bulk` | Test many credentials from CSV |
95
+ | `profile` | `add/delete/list/show` | Manage credential profiles |
96
+
97
+ ## Supported Security
98
+
99
+ | Level | Auth | Privacy |
100
+ |-------|------|---------|
101
+ | noAuthNoPriv | — | — |
102
+ | authNoPriv | MD5, SHA1, SHA256, SHA512 | — |
103
+ | authPriv | MD5, SHA1, SHA256, SHA512 | DES, AES128, AES256 |
104
+
105
+ ## License
106
+
107
+ MIT
@@ -0,0 +1,80 @@
1
+ # snmpv3-utils
2
+
3
+ A Python CLI for SNMPv3 testing. Most existing tools only support v1/v2 — this one does v3 properly.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pipx install snmpv3-utils
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # GET a single OID
15
+ snmpv3 query get 192.168.1.1 1.3.6.1.2.1.1.1.0 \
16
+ --username admin \
17
+ --auth-protocol SHA256 --auth-key myauthpass \
18
+ --priv-protocol AES128 --priv-key myprivpass \
19
+ --security-level authPriv
20
+
21
+ # WALK the system MIB
22
+ snmpv3 query walk 192.168.1.1 1.3.6.1.2.1.1 --profile myrouter
23
+
24
+ # Send a trap
25
+ snmpv3 trap send 192.168.1.1 --profile myrouter
26
+
27
+ # Test credentials
28
+ snmpv3 auth check 192.168.1.1 --profile myrouter
29
+
30
+ # Bulk test from a CSV
31
+ snmpv3 auth bulk 192.168.1.1 --file creds.csv
32
+
33
+ # JSON output (for piping into jq)
34
+ snmpv3 query walk 192.168.1.1 1.3.6.1.2.1.1 --format json | jq '.[] | .value'
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ Copy `.env.example` to `.env` and fill in your defaults:
40
+
41
+ ```bash
42
+ cp .env.example .env
43
+ ```
44
+
45
+ Or use named profiles:
46
+
47
+ ```bash
48
+ snmpv3 profile add myrouter \
49
+ --username admin \
50
+ --auth-protocol SHA256 --auth-key myauthpass \
51
+ --priv-protocol AES128 --priv-key myprivpass \
52
+ --security-level authPriv
53
+ ```
54
+
55
+ ## Commands
56
+
57
+ | Group | Command | Description |
58
+ |-------|---------|-------------|
59
+ | `query` | `get` | Fetch a single OID |
60
+ | `query` | `getnext` | Single GETNEXT step |
61
+ | `query` | `walk` | Full subtree traversal |
62
+ | `query` | `bulk` | GETBULK retrieval |
63
+ | `query` | `set` | Set an OID value |
64
+ | `trap` | `send` | Send a trap or inform |
65
+ | `trap` | `listen` | Listen for incoming traps |
66
+ | `auth` | `check` | Test a credential set |
67
+ | `auth` | `bulk` | Test many credentials from CSV |
68
+ | `profile` | `add/delete/list/show` | Manage credential profiles |
69
+
70
+ ## Supported Security
71
+
72
+ | Level | Auth | Privacy |
73
+ |-------|------|---------|
74
+ | noAuthNoPriv | — | — |
75
+ | authNoPriv | MD5, SHA1, SHA256, SHA512 | — |
76
+ | authPriv | MD5, SHA1, SHA256, SHA512 | DES, AES128, AES256 |
77
+
78
+ ## License
79
+
80
+ MIT