Projects/Reporting-friendly KDB dump format

From K5Wiki
< Projects(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
This is split from [[Projects/KDB reporting and bulk operations]].
This is split from [[Projects/KDB reporting and bulk operations]]. Release 1.14 contains the initial implementation described below. Further improvements, mostly consisting of additional output tables, are at [[Projects/Reporting-friendly KDB dump format improvements]].
Line 111: Line 111:
;key: Attribute name
;key: Attribute name
;value: Attribute value
;value: Attribute value
===Principal key history===
This is very similar to the keyinfo/keydata table. There is some weird ring buffer stuff that we may or may not want to reflect in the dump.
* Principal name
* Key index
* Key version number (kvno)
* Enctype
* Salt type
* Salt data as hex string (might be "-1" to denote no salt or normal/default salt)
===Password policy===
* Policy name
* Min password life
* Max password life
* Min password length
* Min password character classes
* Password history length
===Lockout policy===
* Policy name
* Max failures
* Failure count reset interval
* Lockout duration
===Ticket policy===
* Policy name
* Max ticket lifetime
* Max renewable ticket lifetime
===Policy boolean attributes===
As for principal boolean attributes
===Policy allowed keysalts===
(Is this an ordered list?)
* Policy name
* Enctype
* Salt type
==C structure cross reference==
;magic: (not encoded)
;mask: (not encoded?)
;attributes: princ_flags
;max_life: princ_tktpolicy
;max_renewable_life: princ_tktpolicy
;expiration: princ_tktpolicy
;pw_expiration: princ_tktpolicy
;last_success: princ_lockout
;last_failed: princ_lockout
;fail_auth_count: princ_lockout
;n_tl_data: (tl_data)
;n_key_data: keyinfo/keydata
;e_length: (implicit)
;e_data: princ_edata
;princ: (everywhere)
;tl_data: (tl_data)
;key_data: keyinfo/keydata
;policy: princ_meta
;old_key_len: (implicit in oldkeyinfo/oldkeydata)
;old_key_next: (implicit in oldkeyinfo/oldkeydata)
;old_keys: oldkeyinfo/oldkeydata
;admin_history_kvno: princ_meta
==tl_data cross reference==
;KRB5_TL_LAST_PWD_CHANGE: princ_meta
;KRB5_TL_MOD_PRINC: princ_meta
;KRB5_TL_KADM_DATA: (see osa_princ_ent_rec)
;KRB5_TL_MKVNO: princ_meta

Latest revision as of 15:11, 14 September 2015

This project was completed in release 1.14.

This is split from Projects/KDB reporting and bulk operations. Release 1.14 contains the initial implementation described below. Further improvements, mostly consisting of additional output tables, are at Projects/Reporting-friendly KDB dump format improvements.


[edit] Background

Operators often want to perform reporting operations on KDB data, but the dump format is optimized for loading by kdb5_util, not human reading or reporting using simple scripts. For example, the number of columns on each principal dump line depends on the number of keydata entries associated with that principal. Also, some useful metadata such as modification date are only present in a human-unfriendly hexadecimal format, as an artifact of being stored in the tl_data of the principal.

[edit] Format choice

Tab-separated value formats are probably acceptable to the largest variety of tools. These tools range from simple awk scripts to SQL databases. Comma-separated values are easy to add. Various quoting and escaping options exist in various dialects of CSV format. Opinions vary on whether tab-separated formats can use quoting, but in any case, most of the fields will not require quoting if tab-separated.

There are several conceptual database tables, each of which will have a different set of columns. To allow a single combined dump format, each dump line will have a first column that indicates the conceptual table to which it belongs. Another option is to provide command line options to select an individual conceptual table to dump, in which case the table name prefix would be omitted from each line. Headers should be optional, because some tools work better without them.

[edit] Examples

These are some examples of how commonly available tools could be used to manipulate output from one of these dumps.

$ cat keyinfo.txt
name	keyindex	kvno	enctype	salttype	salt
foo@EXAMPLE.COM	0	1	aes128-cts-hmac-sha1-96	normal	-1
bar@EXAMPLE.COM	0	1	aes128-cts-hmac-sha1-96	normal	-1
bar@EXAMPLE.COM	1	1	des-cbc-crc	normal	-1
$ sqlite3
sqlite> .mode tabs
sqlite> .import keyinfo.txt keyinfo
sqlite> select * from keyinfo where enctype like 'des-cbc-%';
bar@EXAMPLE.COM	1	1	des-cbc-crc	normal	-1
sqlite> .quit
$ awk -F'\t' '$4 ~ /des-cbc-/ { print }' keyinfo.txt
bar@EXAMPLE.COM	1	1	des-cbc-crc	normal	-1

[edit] Formatting options

[edit] Symbolic names

Some values such as enctypes and salttypes can be printed numerically or using symbolic names. The default will be for symbolic names.

[edit] Date/time

Time stamps print as ISO 8601 UTC date and time. Numeric output is decimal POSIX time_t values.

Durations can print as decimal seconds. Later options could include ISO 8601 durations (although technically ISO 8601 duration representations are only supposed to designate intervals by context, and not pure durations).

[edit] Conceptual tables

This is an attempt to split KDB data fields into a somewhat more normalized schema that is somewhat easier to manipulate for reporting purposes. The rectype is the string used to request a specific conceptual table. Initially, only one table can print at a time. Eventually, there will be a combined output format where each line is prefixed with the rectype. Additional possibilities include outputting a directory with one file per table.

[edit] Principal metadata

Principal name (krb5_kdb_entry)
Last modified by (principal name) (KRB5_TL_MOD_PRINC)
Last modification date (KRB5_TL_MOD_PRINC)
Last password change (KRB5_TL_LAST_PWD_CHANGE)
Policy object name (osa_princ_ent_rec)
Master key version used for this principal's key data (KRB5_TL_MKVNO)
kadmin history principal kvno for this principal's key history (osa_princ_ent_rec)

[edit] Principal keys

There will generally be multiple dump key data dump lines per principal. The order is significant (though typically it's only important within the active kvno), so there will need to be a key index number in case the user imports the dump into a data store that doesn't preserve the ordering of input lines (such as most relational databases).

keyinfo (or keydata)
Principal name (krb5_kdb_entry)
Key index
Key version number
hex string (only for keydata rectype)
Salt type
Salt data as hex string (might be "-1" to denote no salt or normal/default salt)

A sample implementation of a "keyinfo" dump format is at https://github.com/tlyu/krb5/tree/keyinfo

[edit] Per-principal policy data

Principal name
Principal expiration date
Password expiration date
Max ticket lifetime
Max renewable ticket lifetime

[edit] Per-principal lockout data

These are the per-KDC (non-replicated) data that track failed logins due to incorrect passwords.

Principal name
Last success
Last failure
Count of failed attempts

[edit] Principal boolean attributes

Principal name
Attribute name (string form, or hexadecimal if numeric is requested)
Boolean value (1 or 0)

Feedback from operators indicates that having a row for each attribute, regardless of whether or not it's set, can be useful to satisfy auditors.

Unknown attributes print as hexadecimal numbers, if set. If the user requests numeric output, output all flag settings, including unset flags, as hexadecimal.

[edit] Principal string attributes

Principal name
Attribute name
Attribute value
Personal tools