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

WIP: split veracruz-server and runtime-manager into platform-specific crates #112

Closed

Conversation

gbryant-arm
Copy link
Contributor

@gbryant-arm gbryant-arm commented Mar 24, 2021

This PR aims at splitting platform-specific code (backend) from the runtime and the rest of the codebase (#81).
The goal is to make the codebase more modular and in particular to simplify the process of adding support for another platform.

Todo:

  • Create veracruz-server-sgx crate
  • Reusing structures and functions from the parent crate (veracruz-server)

WIP: Reuse structures and functions from the parent crate (veracruz-server)
@dominic-mulligan-arm dominic-mulligan-arm added always-refactoring A refactoring/code quality change to the Veracruz codebase build-process Something related to the Veracruz build process repository Something related to management of the repository trusted-veracruz-runtime Something related to the trusted Veracruz runtime labels Mar 24, 2021
@dominic-mulligan-arm dominic-mulligan-arm added this to the Split Veracruz runtime from isolation/attestation code milestone Mar 24, 2021
@@ -0,0 +1,133 @@
//! The Veracruz server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is very little in this file that is SGX-specific, and this file is likely to appear in all platform-specific servers.
Is there a way that we can use this code across all platforms instead of duplicating it?

@@ -0,0 +1,35 @@
//! Veracruz server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment in this one. As far as I can tell, there is no SGX-specific code in this one.

# See the `LICENSE.markdown` file in the Veracruz root director for licensing
# and copyright information.

.PHONY: all policy-files sgx trustzone deprecated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trustzone build target is now redundant here, I think.

webpki-roots = "0.16"


[dependencies.veracruz-server-sgx]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use [dependencies.veracruz-server-sgx] here?

));
rustls::ClientSession::new(&std::sync::Arc::new(client_config), dns_name)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous newlines, here.

let rst = client_tls_send(&client_tls_tx, &client_tls_rx, &mut client_session, &request).unwrap();
let rst = protobuf::parse_from_bytes::<transport_protocol::RuntimeManagerResponse>(&rst);
assert!(rst.is_ok());
//let response = rst.unwrap();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code should be deleted.

Ok(_) => (),
Err(err) => return Err(format!("Error in tx.send() {:?}", err)),
};
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trailing else can be deleted.

@veracruz-project-owner
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: Veracruz
  • Commit ID: d5e8a3a
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dominic-mulligan-arm dominic-mulligan-arm changed the title Platform splitting WIP: split veracruz-server and runtime-manager into platform-specific crates Mar 31, 2021
@veracruz-project-owner
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: Veracruz
  • Commit ID: 90e9aad
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dominic-mulligan-arm
Copy link
Member

@gbryant-arm, the changes you made to the VeracruzServerError type look correct to me. What errors are you getting, and on what lines?

@dominic-mulligan-arm
Copy link
Member

BTW, you should probably also rebase sooner rather than later, as there have been some fairly extensive changes in veracruz-utils that may affect you. Also, there was recently some oddity with the Docker submodule in the repository that should now be fixed, though I notice your Codebuild CI runs are failing because of that.

[package]
name = "veracruz-server-sgx-fuzz"
version = "0.0.0"
authors = ["Shale Xiong"]
Copy link
Member

@ShaleXIONG ShaleXIONG Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably forgot to change here on authorship since the first initial commit and this fuzz test is no longer valid.


match res {
Ok(_) => (),
Err(err) => return Err(format!("Error in tx.send() {:?}", err)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_err in Result type and ok_or in Option type, together with the ? operator, can be useful in term of propagating Error, e.g.

let res = tx.send(output).map_err(|err|format!("Error in tx.send() {:?}", err))?;

In fact here if you never want to use the Ok(_) case, you could try

tx.send(output).map_err(|err| format!("Error in tx.send() {:?}", err))?;

Just to say, there is no problem of use match. However, these two functions can help you to write less code, especially less indentation for readability.

@dominic-mulligan-arm
Copy link
Member

Are you still making progress, @gbryant-arm, or are you stuck?

@@ -0,0 +1,40 @@
[package]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs the copyright/licensing header at the top that all other Cargo.toml files have.

@gbryant-arm
Copy link
Contributor Author

gbryant-arm commented Apr 20, 2021

Thanks @dreemkiller @dominic-mulligan-arm @ShaleXIONG for your feedback. I will address the comments soon, but first I'd like to focus on splitting veracruz-server (that's my first MVP)

@veracruz-project-owner
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: Veracruz
  • Commit ID: 2a8004b
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@veracruz-project-owner
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: Veracruz
  • Commit ID: 2592959
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@veracruz-project-owner
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: Veracruz
  • Commit ID: 935ea78
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dominic-mulligan-arm
Copy link
Member

Closing this as I have taken over the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
always-refactoring A refactoring/code quality change to the Veracruz codebase build-process Something related to the Veracruz build process repository Something related to management of the repository trusted-veracruz-runtime Something related to the trusted Veracruz runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants