1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-06-19 22:28:17 +02:00

doc updates

This commit is contained in:
Kelly Brazil
2025-05-27 09:06:26 -07:00
parent f36c713110
commit 3a7ca118ff
12 changed files with 355 additions and 43 deletions
+6 -6
View File
@@ -36,7 +36,7 @@ returned.
Parameters:
documentation: (boolean) include parser docstrings if True
documentation: (boolean) include parser docstrings if `True`
show_hidden: (boolean) also show parsers marked as hidden
in their info metadata.
show_deprecated: (boolean) also show parsers marked as
@@ -172,17 +172,17 @@ Parameters:
variants of the module name.
A Module object can also be passed
directly or via get_parser()
directly or via `get_parser()`
data: (string or data to parse (string or bytes for
bytes or standard parsers, iterable of
iterable) strings for streaming parsers)
raw: (boolean) output preprocessed JSON if True
raw: (boolean) output preprocessed JSON if `True`
quiet: (boolean) suppress warning messages if True
quiet: (boolean) suppress warning messages if `True`
ignore_exceptions: (boolean) ignore parsing exceptions if True
ignore_exceptions: (boolean) ignore parsing exceptions if `True`
(streaming parsers only)
Returns:
@@ -209,7 +209,7 @@ Parameters:
variants of the module name as well
as a parser module object.
documentation: (boolean) include parser docstring if True
documentation: (boolean) include parser docstring if `True`
<a id="jc.lib.parser_mod_list"></a>
+304
View File
@@ -0,0 +1,304 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.x509_crl"></a>
# jc.parsers.x509_crl
jc - JSON Convert X.509 Certificate Revocation List format file parser
This parser will convert DER and PEM encoded X.509 certificate revocation
list files.
Usage (cli):
$ cat certificateRevocationList.pem | jc --x509-crl
$ cat certificateRevocationList.der | jc --x509-crl
Usage (module):
import jc
result = jc.parse('x509_crl', x509_crl_file_output)
Schema:
{
"tbs_cert_list": {
"version": string,
"signature": {
"algorithm": string,
"parameters": string/null
},
"issuer": {
"organization_name": string,
"organizational_unit_name": string,
"common_name": string
},
"this_update": integer, # [1]
"next_update": integer, # [1]
"revoked_certificates": [
{
"user_certificate": integer,
"revocation_date": integer, # [1]
"crl_entry_extensions": [
{
"extn_id": string,
"critical": boolean,
"extn_value": string,
"extn_value_iso": string
},
"revocation_date_iso": string
}
],
"crl_extensions": [
{
"extn_id": string,
"critical": boolean,
"extn_value": array/object/string/integer # [2]
}
],
"this_update_iso": string,
"next_update_iso": string
},
"signature_algorithm": {
"algorithm": string,
"parameters": string/null
},
"signature": string # [0]
}
[0] in colon-delimited hex notation
[1] time-zone-aware (UTC) epoch timestamp
[2] See below for well-known Extension schemas:
Basic Constraints:
{
"extn_id": "basic_constraints",
"critical": boolean,
"extn_value": {
"ca": boolean,
"path_len_constraint": string/null
}
}
Key Usage:
{
"extn_id": "key_usage",
"critical": boolean,
"extn_value": [
string
]
}
Key Identifier:
{
"extn_id": "key_identifier",
"critical": boolean,
"extn_value": string # [0]
}
Authority Key Identifier:
{
"extn_id": "authority_key_identifier",
"critical": boolean,
"extn_value": {
"key_identifier": string, # [0]
"authority_cert_issuer": string/null,
"authority_cert_serial_number": string/null
}
}
Subject Alternative Name:
{
"extn_id": "subject_alt_name",
"critical": boolean,
"extn_value": [
string
]
}
Certificate Policies:
{
"extn_id": "certificate_policies",
"critical": boolean,
"extn_value": [
{
"policy_identifier": string,
"policy_qualifiers": [ array or null
{
"policy_qualifier_id": string,
"qualifier": string
}
]
}
]
}
Signed Certificate Timestamp List:
{
"extn_id": "signed_certificate_timestamp_list",
"critical": boolean,
"extn_value": string # [0]
}
Examples:
$ cat sample-crl.pem | jc --x509-crl -p
{
"tbs_cert_list": {
"version": "v2",
"signature": {
"algorithm": "sha1_rsa",
"parameters": null
},
"issuer": {
"organization_name": "Sample Signer Organization",
"organizational_unit_name": "Sample Signer Unit",
"common_name": "Sample Signer Cert"
},
"this_update": 1361183520,
"next_update": 1361184120,
"revoked_certificates": [
{
"user_certificate": 1341767,
"revocation_date": 1361182932,
"crl_entry_extensions": [
{
"extn_id": "crl_reason",
"critical": false,
"extn_value": "affiliation_changed"
},
{
"extn_id": "invalidity_date",
"critical": false,
"extn_value": 1361182920,
"extn_value_iso": "2013-02-18T10:22:00+00:00"
}
],
"revocation_date_iso": "2013-02-18T10:22:12+00:00"
},
{
"user_certificate": 1341768,
"revocation_date": 1361182942,
"crl_entry_extensions": [
{
"extn_id": "crl_reason",
"critical": false,
"extn_value": "certificate_hold"
},
{
"extn_id": "invalidity_date",
"critical": false,
"extn_value": 1361182920,
"extn_value_iso": "2013-02-18T10:22:00+00:00"
}
],
"revocation_date_iso": "2013-02-18T10:22:22+00:00"
},
{
"user_certificate": 1341769,
"revocation_date": 1361182952,
"crl_entry_extensions": [
{
"extn_id": "crl_reason",
"critical": false,
"extn_value": "superseded"
},
{
"extn_id": "invalidity_date",
"critical": false,
"extn_value": 1361182920,
"extn_value_iso": "2013-02-18T10:22:00+00:00"
}
],
"revocation_date_iso": "2013-02-18T10:22:32+00:00"
},
{
"user_certificate": 1341770,
"revocation_date": 1361182962,
"crl_entry_extensions": [
{
"extn_id": "crl_reason",
"critical": false,
"extn_value": "key_compromise"
},
{
"extn_id": "invalidity_date",
"critical": false,
"extn_value": 1361182920,
"extn_value_iso": "2013-02-18T10:22:00+00:00"
}
],
"revocation_date_iso": "2013-02-18T10:22:42+00:00"
},
{
"user_certificate": 1341771,
"revocation_date": 1361182971,
"crl_entry_extensions": [
{
"extn_id": "crl_reason",
"critical": false,
"extn_value": "cessation_of_operation"
},
{
"extn_id": "invalidity_date",
"critical": false,
"extn_value": 1361182920,
"extn_value_iso": "2013-02-18T10:22:00+00:00"
}
],
"revocation_date_iso": "2013-02-18T10:22:51+00:00"
}
],
"crl_extensions": [
{
"extn_id": "authority_key_identifier",
"critical": false,
"extn_value": {
"key_identifier": "be:12:01:cc:aa:ea:11:80:da:2e:ad:b2...",
"authority_cert_issuer": null,
"authority_cert_serial_number": null
}
},
{
"extn_id": "crl_number",
"critical": false,
"extn_value": 3
}
],
"this_update_iso": "2013-02-18T10:32:00+00:00",
"next_update_iso": "2013-02-18T10:42:00+00:00"
},
"signature_algorithm": {
"algorithm": "sha1_rsa",
"parameters": null
},
"signature": "42:21:be:81:f1:c3:79:76:66:5b:ce:21:13:8a:68:a..."
}
<a id="jc.parsers.x509_crl.parse"></a>
### parse
```python
def parse(data: Union[str, bytes],
raw: bool = False,
quiet: bool = False) -> Dict
```
Main text parsing function
Parameters:
data: (string or bytes) text or binary data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Source: [`jc/parsers/x509_crl.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/x509_crl.py)
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+6 -5
View File
@@ -23,8 +23,9 @@ jc - JSON Convert streaming utils
def add_jc_meta(func: ~F) -> ~F
```
Decorator for streaming parsers to add stream_success and stream_error
objects. This simplifies the yield lines in the streaming parsers.
Decorator for streaming parsers to add `stream_success` and
`stream_error` objects. This simplifies the `yield` lines in the
streaming parsers.
With the decorator on parse():
@@ -58,7 +59,7 @@ In all cases above:
successfully parse.
ignore_exceptions: (bool) continue processing lines and ignore
exceptions if True.
exceptions if `True`.
<a id="jc.streaming.raise_or_yield"></a>
@@ -69,8 +70,8 @@ def raise_or_yield(ignore_exceptions: bool, e: BaseException,
line: str) -> Tuple[BaseException, str]
```
Return the exception object and line string if ignore_exceptions is
True. Otherwise, re-raise the exception from the exception object with
Return the exception object and line string if `ignore_exceptions` is
`True`. Otherwise, re-raise the exception from the exception object with
an annotation.
<a id="jc.streaming.stream_error"></a>
+6 -6
View File
@@ -44,7 +44,7 @@ Parameters:
the parser. compatible options:
linux, darwin, cygwin, win32, aix, freebsd
quiet: (bool) suppress compatibility message if True
quiet: (bool) suppress compatibility message if `True`
Returns:
@@ -181,7 +181,7 @@ Parameters:
Returns:
None - just prints output to STDERR
None - just prints output to `STDERR`
<a id="jc.utils.has_data"></a>
@@ -194,7 +194,7 @@ def has_data(data: Union[str, bytes]) -> bool
Checks if the string input contains data. If there are any
non-whitespace characters then return `True`, else return `False`.
For bytes, returns True if there is any data.
For bytes, returns `True` if there is any data.
Parameters:
@@ -202,9 +202,9 @@ Parameters:
Returns:
Boolean True if input string (data) contains non-whitespace
characters, otherwise False. For bytes data, returns
True if there is any data, otherwise False.
Boolean `True` if input string (data) contains non-whitespace
characters, otherwise `False`. For bytes data, returns
`True` if there is any data, otherwise `False`.
<a id="jc.utils.input_type_check"></a>