Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@ name: Notify owners about new event
on:
pull_request_target:
types: [opened, reopened]

issues:
types: [opened, reopened]

jobs:
build:
if: ${{ github.repository == "aws/aws-nitro-enclaves-cli" }}
if: github.repository == 'aws/aws-nitro-enclaves-cli'
runs-on: ubuntu-latest
steps:
- name: if_pr
if: github.event.pull_request
run: |
echo "EVENT_TYPE=PR" >> $GITHUB_ENV
echo "EVENT_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=PR" >> "$GITHUB_ENV"
echo "EVENT_URL=${{ github.event.pull_request.html_url }}" >> "$GITHUB_ENV"

- name: if_issue
if: github.event.issue
run: |
echo "EVENT_TYPE=issue" >> $GITHUB_ENV
echo "EVENT_URL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=issue" >> "$GITHUB_ENV"
echo "EVENT_URL=${{ github.event.issue.html_url }}" >> "$GITHUB_ENV"

- name: notify
run: |
curl -d '{ "type": "${{ env.EVENT_TYPE }}", "url": "${{ env.EVENT_URL }}" }' ${{ secrets.EVENT_WEBHOOK_URL }}
curl -X POST \
-H "Content-Type: application/json" \
-d '{"type":"${{ env.EVENT_TYPE }}","url":"${{ env.EVENT_URL }}"}' \
"${{ secrets.EVENT_WEBHOOK_URL }}"
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ page_size = "0.6"
signal-hook = "0.3"
ciborium = "0.2"
driver-bindings = { path = "./driver-bindings" }
aws-nitro-enclaves-image-format = "0.4"
aws-nitro-enclaves-image-format = "0.5"
eif_loader = { path = "./eif_loader" }
enclave_build = { path = "./enclave_build" }
openssl = "0.10.66"
Expand Down
2 changes: 1 addition & 1 deletion eif_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rust-version = "1.68"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-nitro-enclaves-image-format = "0.4"
aws-nitro-enclaves-image-format = "0.5"
nix = "0.26"
libc = "0.2"
vsock = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion enclave_build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ url = "2.4"
sha2 = "0.9.5"
futures = "0.3.28"

aws-nitro-enclaves-image-format = "0.4"
aws-nitro-enclaves-image-format = "0.5"
tar = "0.4.40"
flate2 = "1.0.28"
40 changes: 11 additions & 29 deletions enclave_build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ mod yaml_generator;

use aws_nitro_enclaves_image_format::defs::{EifBuildInfo, EifIdentityInfo, EIF_HDR_ARCH_ARM64};
use aws_nitro_enclaves_image_format::utils::identity::parse_custom_metadata;
use aws_nitro_enclaves_image_format::utils::{
EifBuilder, SignKeyData, SignKeyDataInfo, SignKeyInfo,
};
use aws_nitro_enclaves_image_format::utils::{EifBuilder, SignKeyData};
use docker::DockerUtil;
use serde_json::json;
use sha2::Digest;
Expand Down Expand Up @@ -71,9 +69,7 @@ impl<'a> Docker2Eif<'a> {
output: &'a mut File,
artifacts_prefix: String,
certificate_path: &Option<String>,
key_path: &Option<String>,
kms_key_id: &Option<String>,
kms_key_region: &Option<String>,
private_key: &Option<String>,
img_name: Option<String>,
img_version: Option<String>,
metadata_path: Option<String>,
Expand Down Expand Up @@ -102,31 +98,17 @@ impl<'a> Docker2Eif<'a> {
}
}

let sign_key_info = match (kms_key_id, key_path) {
(None, None) => None,
(Some(kms_id), None) => Some(SignKeyInfo::KmsKeyInfo {
id: kms_id.into(),
region: kms_key_region.clone(),
}),
(None, Some(key_path)) => Some(SignKeyInfo::LocalPrivateKeyInfo {
path: key_path.into(),
}),
_ => return Err(Docker2EifError::SignArgsError),
let sign_info = match (private_key, certificate_path) {
(Some(key), Some(cert)) => SignKeyData::new(key, Path::new(&cert)).map_or_else(
|e| {
eprintln!("Could not read signing info: {:?}", e);
None
},
Some,
),
_ => None,
};

let sign_info = sign_key_info
.map(|key_info| {
SignKeyData::new(&SignKeyDataInfo {
cert_path: certificate_path
.as_ref()
.ok_or(Docker2EifError::SignArgsError)?
.into(),
key_info,
})
.map_err(|_| Docker2EifError::SignArgsError)
})
.transpose()?;

Ok(Docker2Eif {
docker_image,
docker,
Expand Down
31 changes: 5 additions & 26 deletions enclave_build/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use clap::{Arg, ArgAction, ArgGroup, Command};
use clap::{Arg, ArgAction, Command};
use std::fs::OpenOptions;

use aws_nitro_enclaves_image_format::generate_build_info;
Expand Down Expand Up @@ -68,29 +68,14 @@ fn main() {
.arg(
Arg::new("signing-certificate")
.long("signing-certificate")
.help("Specify the path to the signing certificate"),
.help("Specify the path to the signing certificate")
.requires("private-key"),
)
.arg(
Arg::new("private-key")
.long("private-key")
.help("Specify the path to the private-key"),
)
.arg(
Arg::new("kms-key-id")
.long("kms-key-id")
.help("Specify unique id of the KMS key")
)
.arg(
Arg::new("kms-key-region")
.long("kms-key-region")
.help("Specify region in which the KMS key resides")
.requires("kms-key-id")
)
.group(
ArgGroup::new("signing-key")
.args(["kms-key-id", "private-key"])
.multiple(false)
.requires("signing-certificate")
.help("Specify KMS key ARN or the path to the private key file")
.requires("signing-certificate"),
)
.arg(
Arg::new("build")
Expand Down Expand Up @@ -139,10 +124,6 @@ fn main() {
let img_name = matches.get_one::<String>("image_name").map(String::from);
let img_version = matches.get_one::<String>("image_version").map(String::from);
let metadata = matches.get_one::<String>("metadata").map(String::from);
let kms_key_id = matches.get_one::<String>("kms-key-id").map(String::from);
let kms_key_region = matches
.get_one::<String>("kms-key-region")
.map(String::from);

let mut output = OpenOptions::new()
.read(true)
Expand All @@ -163,8 +144,6 @@ fn main() {
".".to_string(),
&signing_certificate,
&private_key,
&kms_key_id,
&kms_key_region,
img_name,
img_version,
metadata,
Expand Down
18 changes: 2 additions & 16 deletions src/common/commands_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ pub struct BuildEnclavesArgs {
pub output: String,
/// The path to the signing certificate for signed enclaves.
pub signing_certificate: Option<String>,
/// The path to the private key for signed enclaves.
/// KMS key ARN or path to the private key for signed enclaves.
pub private_key: Option<String>,
/// ID of the KMS key for signed enclaves.
pub kms_key_id: Option<String>,
/// Region of the KMS key for signed enclaves.
pub kms_key_region: Option<String>,
/// The name of the enclave image.
pub img_name: Option<String>,
/// The version of the enclave image.
Expand Down Expand Up @@ -141,8 +137,6 @@ impl BuildEnclavesArgs {
})?,
signing_certificate: parse_signing_certificate(args),
private_key: parse_private_key(args),
kms_key_id: parse_kms_key_id(args),
kms_key_region: parse_kms_key_region(args),
img_name: parse_image_name(args),
img_version: parse_image_version(args),
metadata: parse_metadata(args),
Expand Down Expand Up @@ -528,14 +522,6 @@ fn parse_private_key(args: &ArgMatches) -> Option<String> {
args.get_one::<String>("private-key").map(String::from)
}

fn parse_kms_key_id(args: &ArgMatches) -> Option<String> {
args.get_one::<String>("kms-key-id").map(String::from)
}

fn parse_kms_key_region(args: &ArgMatches) -> Option<String> {
args.get_one::<String>("kms-key-region").map(String::from)
}

fn parse_image_name(args: &ArgMatches) -> Option<String> {
args.get_one::<String>("image_name").map(String::from)
}
Expand Down Expand Up @@ -565,7 +551,7 @@ mod tests {
use crate::common::construct_error_message;
use crate::create_app;

use clap::{Arg, ArgGroup, Command};
use clap::{Arg, Command};

/// Parse the path of the JSON config file
fn parse_config_file(args: &ArgMatches) -> NitroCliResult<String> {
Expand Down
29 changes: 4 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ pub fn build_enclaves(args: BuildEnclavesArgs) -> NitroCliResult<()> {
&args.output,
&args.signing_certificate,
&args.private_key,
&args.kms_key_id,
&args.kms_key_region,
&args.img_name,
&args.img_version,
&args.metadata,
Expand All @@ -75,8 +73,6 @@ pub fn build_from_docker(
output_path: &str,
signing_certificate: &Option<String>,
private_key: &Option<String>,
kms_key_id: &Option<String>,
kms_key_region: &Option<String>,
img_name: &Option<String>,
img_version: &Option<String>,
metadata_path: &Option<String>,
Expand Down Expand Up @@ -140,8 +136,6 @@ pub fn build_from_docker(
artifacts_path()?,
signing_certificate,
private_key,
kms_key_id,
kms_key_region,
img_name.clone(),
img_version.clone(),
metadata_path.clone(),
Expand Down Expand Up @@ -713,29 +707,14 @@ macro_rules! create_app {
.arg(
Arg::new("signing-certificate")
.long("signing-certificate")
.help("Local path to developer's X509 signing certificate."),
.help("Local path to developer's X509 signing certificate.")
.requires("private-key"),
)
.arg(
Arg::new("private-key")
.long("private-key")
.help("Local path to developer's Eliptic Curve private key."),
)
.arg(
Arg::new("kms-key-id")
.long("kms-key-id")
.help("Specify unique id of the KMS key")
)
.arg(
Arg::new("kms-key-region")
.long("kms-key-region")
.help("Specify region in which the KMS key resides")
.requires("kms-key-id")
)
.group(
ArgGroup::new("signing-key")
.args(&["kms-key-id", "private-key"])
.multiple(false)
.requires("signing-certificate")
.help("KMS key ARN or local path to developer's Eliptic Curve private key.")
.requires("signing-certificate"),
)
.arg(
Arg::new("image_name")
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern crate lazy_static;

use clap::{Arg, ArgGroup, Command};
use clap::{Arg, Command};
use log::info;
use std::os::unix::net::UnixStream;

Expand Down
Loading
Loading