Skip to content

Commit

Permalink
AA: add built-in plugin information in --help
Browse files Browse the repository at this point in the history
Signed-off-by: Xynnn007 <[email protected]>
  • Loading branch information
Xynnn007 committed Apr 7, 2024
1 parent 4182e8c commit 3b28c8a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
12 changes: 6 additions & 6 deletions attestation-agent/attestation-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ kbs = ["kbs_protocol/background_check", "token"]
# CoCoAS Attestation Token
coco_as = ["reqwest", "token"]

all-attesters = ["kbs_protocol?/all-attesters", "attester/all-attesters"]
tdx-attester = ["kbs_protocol/tdx-attester", "attester/tdx-attester"]
sgx-attester = ["kbs_protocol/sgx-attester", "attester/sgx-attester"]
az-snp-vtpm-attester = ["kbs_protocol/az-snp-vtpm-attester", "attester/az-snp-vtpm-attester"]
az-tdx-vtpm-attester = ["kbs_protocol/az-tdx-vtpm-attester", "attester/az-tdx-vtpm-attester"]
snp-attester = ["kbs_protocol/snp-attester", "attester/snp-attester"]
all-attesters = ["tdx-attester", "sgx-attester", "az-snp-vtpm-attester", "az-tdx-vtpm-attester", "snp-attester"]
tdx-attester = ["kbs_protocol?/tdx-attester", "attester/tdx-attester"]
sgx-attester = ["kbs_protocol?/sgx-attester", "attester/sgx-attester"]
az-snp-vtpm-attester = ["kbs_protocol?/az-snp-vtpm-attester", "attester/az-snp-vtpm-attester"]
az-tdx-vtpm-attester = ["kbs_protocol?/az-tdx-vtpm-attester", "attester/az-tdx-vtpm-attester"]
snp-attester = ["kbs_protocol?/snp-attester", "attester/snp-attester"]

# Either `rust-crypto` or `openssl` should be enabled to work as underlying crypto module
rust-crypto = ["kbs_protocol?/rust-crypto"]
Expand Down
41 changes: 41 additions & 0 deletions attestation-agent/attestation-agent/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,46 @@ fn main() -> std::io::Result<()> {
.expect("Generate ttrpc protocol code failed.");
}

#[cfg(feature = "bin")]
{
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;

// generate an `intro` file that includes the feature information of the build
fn feature_list(features: Vec<&str>) -> String {
let enabled_features: Vec<&str> = features
.into_iter()
.filter(|&feature| env::var(format!("CARGO_FEATURE_{}", feature)).is_ok())
.collect();

enabled_features.join(", ")
}

let token_plugins = feature_list(vec!["KBS", "COCO_AS"]);
let attester = feature_list(vec![
"TDX_ATTESTER",
"SGX_ATTESTER",
"AZ_SNP_VTPM_ATTESTER",
"AZ_TDX_VTPM_ATTESTER",
"SNP_ATTESTER",
]);

let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("intro");
let mut f = File::create(&dest_path).unwrap();

writeln!(
f,
"Attestation Agent (AA for short) is a service function set for attestation procedure in Confidential Containers. It provides kinds of service APIs related to attestation.\n\n",
)
.unwrap();

writeln!(f, "Supported Attesters: {}", attester).unwrap();

writeln!(f, "Token plugins: {}", token_plugins).unwrap();
}

Ok(())
}
4 changes: 3 additions & 1 deletion attestation-agent/attestation-agent/src/bin/grpc-aa/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ use std::net::SocketAddr;

const DEFAULT_ATTESTATION_AGENT_ADDR: &str = "127.0.0.1:50002";

const ABOUT: &str = include_str!(concat!(env!("OUT_DIR"), "/intro"));

#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
#[command(author, version, about, long_about = Some(ABOUT))]
struct Cli {
/// Attestation gRPC Unix socket addr.
///
Expand Down
4 changes: 3 additions & 1 deletion attestation-agent/attestation-agent/src/bin/ttrpc-aa/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const DEFAULT_ATTESTATION_SOCKET_ADDR: &str = concatcp!(
"attestation-agent.sock"
);

const ABOUT: &str = include_str!(concat!(env!("OUT_DIR"), "/intro"));

#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
#[command(author, version, about, long_about = Some(ABOUT))]
struct Cli {
/// Attestation ttRPC Unix socket addr.
///
Expand Down

0 comments on commit 3b28c8a

Please sign in to comment.