diff --git a/README.md b/README.md index 1dc58033..8f1cbb5b 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,7 @@ option. | ` --wc` | `wc` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/wc) | | ` --who` | `who` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/who) | | ` --xml` | XML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xml) | +| ` --x509-cert` | X.509 PEM and DER certificate file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/x509_cert) | | ` --xrandr` | `xrandr` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/xrandr) | | ` --yaml` | YAML file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml) | | ` --zipinfo` | `zipinfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo) | diff --git a/docs/parsers/x509_cert.md b/docs/parsers/x509_cert.md new file mode 100644 index 00000000..bb8d1ffa --- /dev/null +++ b/docs/parsers/x509_cert.md @@ -0,0 +1,62 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.x509\_cert + +jc - JSON Convert X.509 Certificate format file parser + +This parser will convert DER and PEM encoded X.509 certificates. + +Usage (cli): + + $ cat certificate.pem | jc --x509-cert + +Usage (module): + + import jc + result = jc.parse('x509_cert', x509_cert_file_output) + +Schema: + + [ + { + "x509_cert": string, + "bar": boolean, + "baz": integer + } + ] + +Examples: + + $ cat certificate.pem | jc --x509-cert -p + [] + + $ cat certificate.der | jc --x509-cert -p -r + [] + + + +### parse + +```python +def parse(data: Union[str, bytes], + raw: bool = False, + quiet: bool = False) -> List[Dict] +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of Dictionaries. Raw or processed structured data. + +### Parser Information +Compatibility: linux, darwin, cygwin, win32, aix, freebsd + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/utils.md b/docs/utils.md index 7dac5f2e..0004f63f 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -102,20 +102,23 @@ Returns: ### has\_data ```python -def has_data(data: str) -> bool +def has_data(data: Union[str, bytes]) -> bool ``` -Checks if the input contains data. If there are any non-whitespace -characters then return `True`, else return `False`. +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. Parameters: - data: (string) input to check whether it contains data + data: (string, bytes) input to check whether it contains data Returns: Boolean True if input string (data) contains non-whitespace - characters, otherwise False + characters, otherwise False. For bytes data, returns + True if there is any data, otherwise False. diff --git a/jc/parsers/x509_cert.py b/jc/parsers/x509_cert.py index 70f3bd34..91b7d08c 100644 --- a/jc/parsers/x509_cert.py +++ b/jc/parsers/x509_cert.py @@ -1,6 +1,6 @@ """jc - JSON Convert X.509 Certificate format file parser -This parser will convert DER, PEM, and PKCS#12 encoded X.509 certificates. +This parser will convert DER and PEM encoded X.509 certificates. Usage (cli): @@ -40,7 +40,7 @@ from jc.parsers.asn1crypto import pem, x509 class info(): """Provides parser metadata (version, author, etc.)""" version = '1.0' - description = 'X.509 certificate file parser' + description = 'X.509 PEM and DER certificate file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Using the asn1crypto library at https://github.com/wbond/asn1crypto/releases/tag/1.5.1' diff --git a/man/jc.1 b/man/jc.1 index 26a57544..072cc9ed 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2022-06-30 1.20.1 "JSON Convert" +.TH jc 1 2022-07-05 1.20.1 "JSON Convert" .SH NAME \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -522,6 +522,11 @@ Key/Value file parser \fB--xml\fP XML file parser +.TP +.B +\fB--x509-cert\fP +X.509 PEM and DER certificate file parser + .TP .B \fB--xrandr\fP