Repository navigation
docs: add Rustdoc comments and CI support for documentation generation - #151
hyperfinitism wants to merge 2 commits into
Conversation
8d724ac to
8b3f29e
Compare
Add module-level documentation (//!) and doc comments (///) to all source files to support `cargo doc` and prepare for `cargo rdme` README generation. Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
8b3f29e to
25965cc
Compare
|
@hyperfinitism is the pr still in draft? |
|
Yes. As mentioned in #152, I recognized that this method also has some flaws. In that issue, I proposed several possible approaches. |
| //! ## [Extended Attestation Workflow](#extended-attestation-flowchart) | ||
| //! | ||
| //!  | ||
| //! | ||
| //! **Step 1.** Request the attestation report by providing the two mandatory | ||
| //! parameters - `$ATT_REPORT_PATH` which is the path pointing to where the | ||
| //! user wishes to store the attestation report and `$REQUEST_FILE` which is | ||
| //! the path pointing to where the request file used to request the attestation | ||
| //! report is stored. The optional parameter `-v, --vmpl` specifies the vmpl | ||
| //! level for the attestation report and is set to 1 by default. The flag | ||
| //! `-r, --random` generates random data to be used as request data for the | ||
| //! attestation report. Lastly, the flag `-p, --platform` obtains both the | ||
| //! attestation report and the request data from the platform (only available | ||
| //! for a Microsoft Azure CVM where Hyper-V guest is enabled). | ||
| //! | ||
| //! ```bash | ||
| //! snpguest report $ATT_REPORT_PATH $REQUEST_FILE [-v, --vmpl] $VMPL [-r, --random] [-p, --platform] | ||
| //! ``` | ||
| //! | ||
| //! **Step 2.** Request certificates from the extended memory by providing the | ||
| //! two mandatory parameters - `$ENCODING` which specifies whether to use PEM | ||
| //! or DER encoding to store the certificates and $CERTS_DIR which specifies | ||
| //! the path in the user's directory where the certificates will be saved. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest certificates $ENCODING $CERTS_DIR | ||
| //! ``` | ||
| //! | ||
| //! In some environments, only the VCEK/VLEK certificate can be obtained. In | ||
| //! this case, you must follow the procedure described in | ||
| //! [Regular Attestation Workflow](#regular-attestation-workflow) to obtain an | ||
| //! AMD CA certificates. | ||
| //! | ||
| //! **Step 3.** Verify the certificates obtained from the extended memory by | ||
| //! providing `$CERTS_DIR` which specifies the path in the user's directory | ||
| //! where the certificates were saved from Step 2. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest verify certs $CERTS_DIR | ||
| //! ``` | ||
| //! | ||
| //! **Step 4.** Verify the attestation by providing the two mandatory | ||
| //! parameters - `$CERTS_DIR` which specifies the path in the user's directory | ||
| //! where the certificates were saved from Step 2 and `$ATT_REPORT_PATH` which | ||
| //! is the path pointing to the stored attestation report which the user | ||
| //! wishes to verify. The optional parameters `-t, --tcb` is used to verify | ||
| //! just the Reported TCB contents of the attestaion report and | ||
| //! `-s, --signature` is used to verify just the signature of the attestaion | ||
| //! report. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest verify attestation $CERTS_DIR $ATT_REPORT_PATH [-t, --tcb] [-s, --signature] | ||
| //! ``` | ||
| //! | ||
| //! ## [Regular Attestation Workflow](#regular-attestation-flowchart) | ||
| //! | ||
| //!  | ||
| //! | ||
| //! **Step 1.** Request the attestation report by providing the two mandatory | ||
| //! parameters - `$ATT_REPORT_PATH` which is the path pointing to where the | ||
| //! user wishes to store the attestation report and `$REQUEST_FILE` which is | ||
| //! the path pointing to where the request file used to request the attestation | ||
| //! report is stored. The optional parameter `-v, --vmpl` specifies the vmpl | ||
| //! level for the attestation report and is set to 1 by default. The flag | ||
| //! `-r, --random` generates random data to be used as request data for the | ||
| //! attestation report. Lastly, the flag `-p, --platform` obtains both the | ||
| //! attestation report and the request data from the platform (only available | ||
| //! for a Microsoft Azure CVM where Hyper-V guest is enabled). | ||
| //! | ||
| //! ```bash | ||
| //! snpguest report $ATT_REPORT_PATH $REQUEST_FILE [-v, --vmpl] $VMPL [-r, --random] [-p, --platform] | ||
| //! ``` | ||
| //! | ||
| //! **Step 2.** Request AMD Root Key (ARK) and AMD SEV Key (ASK) (or AMD | ||
| //! SEV-VLEK Key (ASVK) for VLEK) from the AMD Key Distribution Service (KDS) | ||
| //! by providing the three mandatory parameters - `$ENCODING` which specifies | ||
| //! whether to use PEM or DER encoding to store the certificates, `$CERTS_DIR` | ||
| //! which specifies the path in the user's directory where the certificates | ||
| //! will be saved, and `$PROCESSOR_MODEL` - which specifies the AMD Processor | ||
| //! model for which the certificates are to be fetched. The optional | ||
| //! `-e, --endorser` argument specifies the type of attestation signing key | ||
| //! (defaults to VCEK). | ||
| //! | ||
| //! ```bash | ||
| //! snpguest fetch ca $ENCODING $CERTS_DIR $PROCESSOR_MODEL [-e, --endorser] $ENDORSER | ||
| //! ``` | ||
| //! | ||
| //! **Step 3.** Request the Versioned Chip Endorsement Key (VCEK) from the AMD | ||
| //! Key Distribution Service (KDS) by providing the three mandatory | ||
| //! parameters - `$ENCODING` which specifies whether to use PEM or DER | ||
| //! encoding to store the certificates, `$CERTS_DIR` which specifies the path | ||
| //! in the user's directory where the certificates will be saved, and | ||
| //! `$ATT_REPORT_PATH` which is the path pointing to the stored attestation | ||
| //! report for detecting Chip ID and Reported TCB Version. The optional | ||
| //! `-p, --processor-model` argument specifies the AMD Processor model for | ||
| //! which the certificates are to be fetched. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest fetch vcek $ENCODING $CERTS_DIR $ATT_REPORT_PATH [-p, --processor-model] $PROCESSOR_MODEL | ||
| //! ``` | ||
| //! | ||
| //! **Step 4.** Verify the certificates obtained by providing `$CERTS_DIR` | ||
| //! which specifies the path in the user's directory where the certificates | ||
| //! were saved from Step 2. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest verify certs $CERTS_DIR | ||
| //! ``` | ||
| //! | ||
| //! **Step 5.** Verify the attestation by providing the two mandatory | ||
| //! parameters - `$CERTS_DIR` which specifies the path in the user's directory | ||
| //! where the certificates were saved from Step 2 and `$ATT_REPORT_PATH` which | ||
| //! is the path pointing to the stored attestation report which the user | ||
| //! wishes to verify. The optional parameters `-t, --tcb` is used to verify | ||
| //! just the Reported TCB contents of the attestaion report and | ||
| //! `-s, --signature` is used to verify just the signature of the attestaion | ||
| //! report. | ||
| //! | ||
| //! ```bash | ||
| //! snpguest verify attestation $CERTS_DIR $ATT_REPORT_PATH [-t, --tcb] [-s, --signature] | ||
| //! ``` | ||
| //! |
There was a problem hiding this comment.
I think these workflow guides can be a separate document in the docs as you suggested in the issue.
|
Hey @hyperfinitism I have a quick question related to this approach. So in you suggestion, we will no longer have a documentation similar to that of the .adoc that shows how the cli commands are supposed to be used? Or when you run cargo doc then that guide would be generated for you? I'm thinking maybe I would like a document similar to the adoc as reference for users, but I maybe I'm confused as to what would replace it here on this pr. Or it's not being replaced? |
|
With this approach, the adoc file will be replaced by Rustdoc pages corresponding to each module (which describe how to use the CLI). However, as I mentioned in the issue cited above, I currently do not consider this approach to be a clean solution. |
|
So this is the equivalent to option B in your issue? |
|
I'm really not a huge fan of polluting the source code with documentation. I think these should be separate. |
|
@DGonzalezVillal @tylerfanelli |
This PR replaces #139.
//!) and item-level (///) Rustdoc comments across all source files, socargo docproduces a complete API reference and the crate-level documentation can drive acargo rdme-generatedREADME.md.README.mdfromsrc/main.rs's crate-level doc viacargo rdme. The handwritten sections (overview, basic usage, subcommand table, build/install instructions, reporting bugs) now live as the crate-level doc, keepingcargo docoutput and the rendered README in sync.RustdocCI workflow (.github/workflows/docs.yml) that runs on push and pull request:cargo rdme --check: fails ifREADME.mddiffers from the crate-level doc.cargo doc --no-deps --all-features: fails on broken intra-doc links or other doc-build errors.Build
# cargo install cargo-rdme cargo rdme cargo doc --all-features --no-depsNote
I have left the Asciidoc files as they were. The changes to the adoc files from the preceding PR are not included in this PR.