35 KiB
ct_usage_assessment.py
Source file: ct_usage_assessment.py
Certificate-purpose analyzer. This file looks at EKU and KeyUsage to decide what each certificate is technically allowed to do.
Main flow in one line: certificate bytes -> EKU and KeyUsage -> purpose label -> summary counts
How to read this page:
- left side: the actual source code block
- right side: a plain-English explanation for a beginner
- read from top to bottom because later blocks depend on earlier ones
Module setup
|
What this block is doing Purpose-analysis constants and small data shapes for EKU and KeyUsage classification. Flow arrows Earlier blocks or operator input feed this block. → Module setup → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
PurposeClassification
|
What this block is doing One certificate plus the usage label assigned to it. Flow arrows Earlier blocks or operator input feed this block. → PurposeClassification → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
AssessmentSummary
|
What this block is doing The roll-up numbers that power the purpose chapter. Flow arrows Earlier blocks or operator input feed this block. → AssessmentSummary → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
utc_now_iso
|
What this block is doing This function is one of the building blocks inside `ct_usage_assessment.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → utc_now_iso → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
parse_args
|
What this block is doing This block defines the command-line knobs for the file: input paths, cache settings, output paths, and other runtime switches. Flow arrows Earlier blocks or operator input feed this block. → parse_args → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
load_records
|
What this block is doing This block loads data from disk, cache, or an earlier stage so later code can work with it. Flow arrows Earlier blocks or operator input feed this block. → load_records → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
extract_eku_oids
|
What this block is doing This block pulls one specific piece of information out of a larger object. Flow arrows One certificate object. → extract_eku_oids → `classify_purpose` uses these OIDs to decide the category. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
extract_key_usage_flags
|
What this block is doing This block pulls one specific piece of information out of a larger object. Flow arrows One certificate object. → extract_key_usage_flags → `build_classifications` stores these flags as supporting evidence. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
classify_purpose
|
What this block is doing This block applies rules and chooses a category label. Flow arrows The EKU OID list from one certificate. → classify_purpose → `build_classifications` turns that decision into a per-certificate record. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
format_eku_template
|
What this block is doing This function is one of the building blocks inside `ct_usage_assessment.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → format_eku_template → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
format_key_usage_template
|
What this block is doing This function is one of the building blocks inside `ct_usage_assessment.py`. It exists so the file can do one narrow job at a time instead of one giant unreadable routine. Flow arrows Earlier blocks or operator input feed this block. → format_key_usage_template → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
build_classifications
|
What this block is doing Walks through all current certificates and labels them by intended usage. Flow arrows The cleaned current hits plus raw records. → build_classifications → `summarize` compresses these rows into report-level counts. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
summarize
|
What this block is doing Compresses the per-certificate labels into counts, templates, and issuer breakdowns. Flow arrows The per-certificate purpose labels. → summarize → Current-state and monograph chapters use the summary counts and templates. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
render_markdown
|
What this block is doing Writes the standalone purpose report. Flow arrows Earlier blocks or operator input feed this block. → render_markdown → Later blocks in the same file or in the next analytical stage consume its output. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |
main
|
What this block is doing The standalone command-line entrypoint for the purpose analyzer. Flow arrows CLI arguments from the operator. → main → Runs the standalone purpose analysis end to end. How to think about it Treat this block as one small station in a pipeline. Ask: what comes in here, what gets changed here, and what comes out for the next block? |