Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Merging existing code into new enarx-wasmldr repo #3

Closed
wants to merge 61 commits into from

Conversation

MikeCamel
Copy link

@MikeCamel MikeCamel commented Sep 4, 2020

Was in enarx/enarx/keep-runtime.
Fixes #4
Fixes #5

"filetime",
"libc",
"tracing",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't delete Cargo.lock. We check in the lockfile for binaries but not for libraries.

Copy link
Author

Choose a reason for hiding this comment

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

OK. My bad - could you explain why?

@@ -1,2 +1,4 @@
/target
Cargo.lock


Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add extra lines.

Copy link
Author

Choose a reason for hiding this comment

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

I thought there was a failure due to a lack of carriage return in another Cargo.lock file. I'll trim to just one

Copy link

Choose a reason for hiding this comment

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

Shouldn't the Cargo.lock be removed from .gitignore ??

Copy link
Contributor

Choose a reason for hiding this comment

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

@haraldh Yes, probably.

Cargo.toml Outdated
serde_yaml = "0.8"
serde_json = "1.0"
serde_derive = "1.0"
openssl = { version = "0.10", features = ["vendored"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to only be used for certificate generation. However, warp (above) pulls in the rustls crypto chain. I'd prefer not to have two dependencies that do the same thing. So let's avoid using openssl for now.

Copy link
Author

Choose a reason for hiding this comment

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

I thought we wanted to be using openssl for FIPS futures? The main reason, however, is that I struggled to find instructions for how to generate certificates - the only way I managed to make it work was with openssl. Happy to be given pointers...

Copy link
Contributor

Choose a reason for hiding this comment

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

@MikeCamel warp only currently supports the rustls stack. So while FIPS is definitely a future concern, my more immediate concern is the size bloat of having two separate crypto stacks.

As far as certificate generation... there doesn't seem to be a lot of options. The rustls stack uses webpki which only provides validation. The x509-parser project only appears to deserialize the structures.

I see a couple options:

  1. Accept multiple crypto stacks. I don't love this option.

  2. Use an http framework that supports openssl. There don't seem to be any. One potential route would be to use hyper directly via hyper-tls. However, hyper-tls currently only supports the client side. So we'd have to patch it to support the server side.

Thoughts? @ueno Your input is valued here.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. We could create an X.509 template as bytes that we serialize just key data into. This is lightweight and avoids another crypto library.

Cargo.toml Outdated
serde_json = "1.0"
serde_derive = "1.0"
openssl = { version = "0.10", features = ["vendored"] }
reqwest = { version = "0.10.7", features = ["blocking", "json", "native-tls"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

reqwest appears only to be used bin a test binary. The test binary should be built as a test and then this can become a dev-dependency rather than forcing it to be used for all builds.

Copy link
Author

Choose a reason for hiding this comment

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

It is, yes. Where can I find information on how to do all of this? Agree that it should be changed: are there docs on best practices anywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/rust-by-example/testing.html

You probably want integration tests. But unit tests are also valuable.

[[bin]]
name = "enarx-wasmldr-tester"
path = "src/enarx-wasmldr-tester.rs"

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a test rather than a separate binary.

Copy link
Author

@MikeCamel MikeCamel Sep 10, 2020

Choose a reason for hiding this comment

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

Question: are tests supposed to be stand-alone (to be run by humans) or integrated (to be auto-run)? I've been doing only the former, so that we can do PoCs - if creating tests copes with both of these cases, I'm cool.

Copy link
Contributor

Choose a reason for hiding this comment

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

We always want automated tests. Developers can run them with a simple cargo test. But they also get automatically integrated into our CI.

src/main.rs Outdated
Ok(warp::reply::with_status(
"Payload received",
warp::http::StatusCode::OK,
))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the flow of this function is wrong. If I'm reading it correctly, it won't respond to the client until the wasm code has finished running.

Copy link
Author

Choose a reason for hiding this comment

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

I was designing for the single-threaded case, where this is appropriate, I think (though the Result string isn't helpful). That said, I'm not sure that the main code will work single-threaded. This may be beyond my ken - I'll have a look and see if I can work it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is still wrong even in the single threaded case.

We basically want one set of APIs for adding wasm modules to the Keep and another API to start execution. Adding a module to the keep should parse the modules and make sure they are valid before returning OK. OTOH, the go() API should immediately return OK, tear down all further (external) communication and then start wasm execution.

fn get_credentials_bytes(listen_addr: &str) -> (Vec<u8>, Vec<u8>) {
let (key, cert) = match KEY_SOURCE {
"file-system" => (get_key_bytes_fs(), get_cert_bytes_fs()),
"generate" => (generate_credentials(&listen_addr)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Only generate.

Copy link
Author

Choose a reason for hiding this comment

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

Excellent! I'll remove all of these. Didn't like them, but thought I'd leave them in for safety.

src/main.rs Outdated
}
};
in_contents
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop this function.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

src/main.rs Outdated
}
};
in_contents
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop this function.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

key.private_key_to_pem().unwrap(),
certificate.to_pem().unwrap(),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use something other than openssl in this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

(We already have a crypto stack via warp.)

Copy link
Author

Choose a reason for hiding this comment

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

See comment above.

@enarxbot enarxbot assigned MikeCamel and unassigned ueno, npmccallum and connorkuehl Sep 10, 2020
Note that this is not correctly implemented in terms of
certificates: FIXME needs addressing.
As it's now not in .gitignore
Signed-off-by: MikeCamel <[email protected]>
Signed-off-by: MikeCamel <[email protected]>
Signed-off-by: MikeCamel <[email protected]>
Signed-off-by: MikeCamel <[email protected]>
@MikeCamel
Copy link
Author

Out of date

@MikeCamel MikeCamel closed this Jan 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add systemd unit file Add network loading of wasm over https
8 participants