docs: add README, MIT LICENSE, and clippy/linting notes to AGENTS.md

This commit is contained in:
Christopher Williams 2025-08-20 20:39:49 -04:00
parent cd0efc6de6
commit 5877fd91d4
3 changed files with 63 additions and 1 deletions

View File

@ -13,10 +13,14 @@
- Run help: `cargo run -- --help`.
- Parse DER file: `cargo run -- --file tests/data/test.cert.der --input-format der`.
- Parse hex string: `cargo run -- 3082...` (whitespace allowed; auto-detected).
- Lint: `cargo clippy -- -D warnings`.
- Lint: `cargo clippy --all-targets -- -D warnings`.
- Format: `cargo fmt`.
- Tests: `cargo test`.
## Linting & Defaults
- Clippy: configured via `clippy.toml`; we keep warnings at deny to avoid regressions.
- BIT STRINGs: truncated by default for readability (bits: 128, hex bytes: 16). Override with `--bits-truncate` or `--bits-truncate-bytes`.
## Coding Style & Naming Conventions
- Rust 2021; 4-space indent; `rustfmt` defaults (`cargo fmt`).
- Naming: modules `snake_case`; types/enums `CamelCase`; functions `snake_case`; constants `SCREAMING_SNAKE_CASE`.

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 asn1parse contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

37
README.md Normal file
View File

@ -0,0 +1,37 @@
## asn1parse
A tiny Rust CLI to prettyprint DERencoded ASN.1 structures. It uses yasna for DER parsing and prints a readable tree with optional ANSI colors. Helpful for inspecting X.509 certificates and general DER blobs.
### Features
- Generic DER prettyprinter with colorized types.
- Heuristics: decodes nested DER inside OCTET/Bit Strings.
- Friendly outputs for common X.509 bits (SAN names, iPAddress, keyUsage summary).
- Sensible defaults: BIT STRINGs are truncated for readability (bits=128, hex bytes=16) and marked with an ellipsis and “(truncated)”.
### Install
- Build: `cargo build --release`
- Run help: `cargo run -- --help`
### Usage
- Parse DER file: `cargo run -- --file tests/data/test.cert.der --input-format der --color never`
- Parse hex string: `cargo run -- "3006020101020102"`
- Force hex view for bit strings: `cargo run -- 030300DEAD --bits-format hex`
- Override truncation: `--bits-truncate 256` or `--bits-truncate-bytes 32`
### Development
- Lint: `cargo clippy --all-targets -- -D warnings` (configured via `clippy.toml`)
- Format: `cargo fmt`
- Test: `cargo test`
### Generating a sample certificate
- Generate rich test cert (SAN, keyUsage, policies, constraints):
- `openssl req -new -newkey rsa:2048 -nodes -keyout tests/data/rich.key.pem -x509 -days 7 -config tests/data/openssl-rich.cnf -out tests/data/rich.cert.pem`
- `openssl x509 -in tests/data/rich.cert.pem -outform der -out tests/data/rich.cert.der`
- View: `cargo run -- --file tests/data/rich.cert.der --input-format der --color never`
### Notes
- Binary DER via stdin is not supported in text mode; use `--file` or provide hex on stdin.
- Colors autodetect TTY; use `--color always` to force.
### License
MIT — see `LICENSE`.