Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate oak containers protos into one ergonomic file for customer teams, and add relevant build targets #4663

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 0 additions & 2 deletions Cargo.lock

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

5 changes: 0 additions & 5 deletions oak_containers/README.md

This file was deleted.

67 changes: 7 additions & 60 deletions oak_containers/proto/interfaces.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,12 @@

syntax = "proto3";

package oak.containers;

import "google/protobuf/empty.proto";
import "oak_crypto/proto/v1/crypto.proto";
import "proto/attestation/endorsement.proto";
import "proto/attestation/evidence.proto";
import "proto/session/messages.proto";

// As images can be large (hundreds of megabytes), the launcher chunks up the response into smaller
// pieces to respect proto/gRPC limits. The image needs to be reassembled in the stage1 or the
// orchestrator.
message GetImageResponse {
bytes image_chunk = 1;
}

message GetApplicationConfigResponse {
// Arbitrary config that the container can retrieve from the orchestrator.
// Included in the attestation measurements conducted by the orchestrator.
bytes config = 1;
}

message SendAttestationEvidenceRequest {
oak.session.v1.AttestationEvidence evidence = 1 [deprecated = true];
oak.attestation.v1.Evidence dice_evidence = 2;
}

// Defines the service exposed by the launcher, that can be invoked by the stage1 and the
// orchestrator.
service Launcher {
// Provides stage1 with the Oak system image (which contains the Linux distribution and the
// orchestrator binary).
rpc GetOakSystemImage(google.protobuf.Empty) returns (stream GetImageResponse) {}
// TODO(#4392): Remove this file once the migration is complete.
// This file is deprecated. The relevant functionality is available in the
// publicly imported protos instead. Do not add new dependencies on this file.

// Provides orchestrator with the trusted container image.
rpc GetContainerBundle(google.protobuf.Empty) returns (stream GetImageResponse) {}

// This method is used by the orchestrator to load and measure the trusted
// application config. The orchestrator will later, separately expose this
// config to the application.
rpc GetApplicationConfig(google.protobuf.Empty) returns (GetApplicationConfigResponse) {}

// Sends Attestation Evidence containing the Attestation Report with corresponding measurements
// and public keys to the Launcher.
// This API is called exactly once after the Attestation Evidence is generated. Calling this API
// a second time will result in an error.
rpc SendAttestationEvidence(SendAttestationEvidenceRequest) returns (google.protobuf.Empty) {}

// Notifies the launcher that the trusted app is ready to serve requests and listening on the
// pre-arranged port (8080).
rpc NotifyAppReady(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}

// Defines the service exposed by the orchestrator, that can be invoked by the application.
service Orchestrator {
// Exposes the previously loaded trusted application config to the application,
// which may choose to retrieve it.
rpc GetApplicationConfig(google.protobuf.Empty) returns (GetApplicationConfigResponse) {}
package oak.containers;

// Notifies the orchestrator that the trusted app is ready to serve requests and listening on the
// pre-arranged port (8080).
rpc NotifyAppReady(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
import public "proto/containers/common.proto";
import public "proto/containers/launcher.proto";
import public "proto/containers/application_interfaces.proto";
2 changes: 1 addition & 1 deletion oak_containers_launcher/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for connecting to the launcher.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../proto/containers/launcher.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/key_provisioning/key_provisioning.proto",
"../proto/containers/hostlib_key_provisioning.proto",
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_launcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
pub mod proto {
pub mod oak {
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
Expand Down
12 changes: 4 additions & 8 deletions oak_containers_launcher/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ use tokio_stream::wrappers::TcpListenerStream;
use tonic::{transport::Server, Request, Response, Status};

use crate::proto::oak::{
containers::{
containers::v1::{
hostlib_key_provisioning_server::{HostlibKeyProvisioning, HostlibKeyProvisioningServer},
launcher_server::{Launcher, LauncherServer},
v1::{
hostlib_key_provisioning_server::{
HostlibKeyProvisioning, HostlibKeyProvisioningServer,
},
GetGroupKeysResponse, GetKeyProvisioningRoleResponse, KeyProvisioningRole,
},
GetApplicationConfigResponse, GetImageResponse, SendAttestationEvidenceRequest,
GetApplicationConfigResponse, GetGroupKeysResponse, GetImageResponse,
GetKeyProvisioningRoleResponse, KeyProvisioningRole, SendAttestationEvidenceRequest,
},
session::v1::AttestationEvidence,
};
Expand Down
4 changes: 2 additions & 2 deletions oak_containers_orchestrator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for Orchestrator services.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../proto/key_provisioning/key_provisioning.proto",
"../proto/containers/orchestrator_crypto.proto",
"../proto/containers/application_interfaces.proto",
"../proto/containers/launcher.proto",
"../proto/containers/hostlib_key_provisioning.proto",
"../proto/session/messages.proto",
],
Expand Down
4 changes: 2 additions & 2 deletions oak_containers_orchestrator/src/ipc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use tonic::{transport::Server, Request, Response};
use crate::{
crypto::{CryptoService, KeyStore},
launcher_client::LauncherClient,
proto::oak::containers::{
proto::oak::containers::v1::{
orchestrator_crypto_server::OrchestratorCryptoServer,
orchestrator_server::{Orchestrator, OrchestratorServer},
v1::orchestrator_crypto_server::OrchestratorCryptoServer,
GetApplicationConfigResponse,
},
};
Expand Down
6 changes: 3 additions & 3 deletions oak_containers_orchestrator/src/launcher_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use tonic::transport::Channel;

use crate::proto::oak::{
attestation::v1::Evidence,
containers::{
launcher_client::LauncherClient as GrpcLauncherClient,
v1::{hostlib_key_provisioning_client::HostlibKeyProvisioningClient, KeyProvisioningRole},
containers::v1::{
hostlib_key_provisioning_client::HostlibKeyProvisioningClient,
launcher_client::LauncherClient as GrpcLauncherClient, KeyProvisioningRole,
SendAttestationEvidenceRequest,
},
key_provisioning::v1::GroupKeys,
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
pub mod proto {
pub mod oak {
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
Expand Down
1 change: 0 additions & 1 deletion oak_containers_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ oak_grpc_utils = { workspace = true }
[dependencies]
anyhow = "*"
async-trait = { version = "*", default-features = false }
oak_attestation = { workspace = true }
oak_crypto = { workspace = true }
prost = "*"
prost-types = "*"
Expand Down
3 changes: 1 addition & 2 deletions oak_containers_sdk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for connecting to the Orchestrator.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/session/messages.proto",
"../proto/containers/orchestrator_crypto.proto",
"../proto/containers/application_interfaces.proto",
],
"..",
CodegenOptions {
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
mod proto {
pub mod oak {
pub mod containers {
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
pub use oak_crypto::proto::oak::crypto;
}
}
Expand Down
2 changes: 1 addition & 1 deletion oak_containers_sdk/src/orchestrator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use anyhow::{Context, Result};
use tonic::transport::{Endpoint, Uri};
use tower::service_fn;

use crate::proto::oak::containers::orchestrator_client::OrchestratorClient as GrpcOrchestratorClient;
use crate::proto::oak::containers::v1::orchestrator_client::OrchestratorClient as GrpcOrchestratorClient;

// Unix Domain Sockets do not use URIs, hence this URI will never be used.
// It is defined purely since in order to create a channel, since a URI has to
Expand Down
1 change: 0 additions & 1 deletion oak_containers_stage1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ clap = { version = "*", features = ["derive"] }
coset = { version = "*", features = ["std"] }
futures-util = "*"
oak_attestation = { workspace = true }
oak_crypto = { workspace = true }
oak_dice = { workspace = true }
nix = { version = "*", features = ["mman"] }
p256 = { version = "*" }
Expand Down
2 changes: 1 addition & 1 deletion oak_containers_stage1/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for loading the system image.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/session/messages.proto",
"../proto/containers/launcher.proto",
],
"..",
CodegenOptions {
Expand Down
7 changes: 5 additions & 2 deletions oak_containers_stage1/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
mod proto {
pub mod oak {
pub mod containers {
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
}
}

use anyhow::{Context, Result};
use proto::oak::containers::launcher_client::LauncherClient as GrpcLauncherClient;
use proto::oak::containers::v1::launcher_client::LauncherClient as GrpcLauncherClient;
use tonic::transport::{Channel, Uri};

pub struct LauncherClient {
Expand Down
3 changes: 2 additions & 1 deletion oak_functions_containers_app/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/containers/application_interfaces.proto",
"../proto/session/messages.proto",
],
"..",
Expand Down
6 changes: 4 additions & 2 deletions oak_functions_containers_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ pub mod proto {
tonic::include_proto!("oak.functions");
}
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
pub use oak_crypto::proto::oak::crypto;
Expand Down
57 changes: 54 additions & 3 deletions proto/containers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

Expand All @@ -25,10 +26,50 @@ package(
)

proto_library(
name = "orchestrator_crypto_proto",
srcs = ["orchestrator_crypto.proto"],
name = "common_proto",
srcs = ["common.proto"],
)

proto_library(
name = "application_interfaces_proto",
srcs = ["application_interfaces.proto"],
deps = [
":common_proto",
"//oak_crypto/proto/v1:crypto_proto",
"//oak_remote_attestation/proto/v1:messages_proto",
"@com_google_protobuf//:empty_proto",
],
)

cc_proto_library(
name = "application_interfaces_cc_proto",
deps = [":application_interfaces_proto"],
)

cc_grpc_library(
jul-sh marked this conversation as resolved.
Show resolved Hide resolved
name = "application_interfaces_cc_grpc",
srcs = [":application_interfaces_proto"],
grpc_only = True,
generate_mocks = True,
deps = [":application_interfaces_proto"],
)

py_proto_library(
name = "application_interfaces_py_proto",
deps = [":application_interfaces_proto"],
)

py_grpc_library(
name = "application_interfaces_py_grpc",
srcs = [":application_interfaces_proto"],
deps = [":application_interfaces_py_proto"],
)

proto_library(
name = "launcher_proto",
srcs = ["launcher.proto"],
deps = [
":common_proto",
],
)

Expand All @@ -52,10 +93,20 @@ proto_library(
],
)

# TODO(#4392): Remove once the migration is complete.
proto_library(
name = "orchestrator_crypto_proto",
srcs = ["orchestrator_crypto.proto"],
deps = [
"//oak_crypto/proto/v1:crypto_proto",
],
)

build_test(
name = "build_test",
targets = [
":hostlib_key_provisioning_proto",
":orchestrator_crypto_proto",
":application_interfaces_proto",
":launcher_proto",
],
)
Loading
Loading