Skip to content

Commit 0121ffe

Browse files
fix: Fix broken fixtures (#568)
* fix: fix broken fixtures
1 parent aff2be4 commit 0121ffe

5 files changed

Lines changed: 209 additions & 206 deletions

File tree

fixture/client.html.tee.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"mode": "TEE",
3+
"notary_host": "localhost",
4+
"notary_port": 7443,
5+
"notary_ca_cert": "MIIFszCCA5ugAwIBAgIUeXLQmnjeXsHpGji7xA8oJjjw7WwwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEjAQBgNVBAcMCVBhbG8gQWx0bzEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRowGAYDVQQDDBFMb2NhbGhvc3QgUm9vdCBDQTAeFw0yNDA2MDcyMjUyNDBaFw0yOTA2MDYyMjUyNDBaMGkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlQYWxvIEFsdG8xFTATBgNVBAoMDE9yZ2FuaXphdGlvbjEaMBgGA1UEAwwRTG9jYWxob3N0IFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIHMEL9gVSxT/J0qS4xDkDZs1d1UG0+z6NFLLsGdV7gu0ZJbDPlNd0kpjWsisVNB7TcqWoq5ROK5CR+6lZxXC8nbqr2YAJ2O8mHIXcYv7msAN3UYxtM6v1M7K+vNMJdDjZVAxcOKq5R7uUDUPw1weePz6eVEjntAW8mUjqkfnCqYml943Ud3724SkI5wyUT9rKS3bk6hvneq1ah/b1zRGDF2gp+T/oNe4ieS/LGoIUluE2csGRXtt542gpJnw5L54JASmGgt6hunUSWtoaht7Qxv6hYpieu4iHqZY1kfcFDjDH2WI16g1YqrWHzk1l7vWNLVDEcK3kdSQ1GmYAij8ZjAi0LJizLwtN//EkfxiOPlV435itK3uugY+etxrk77BeA6PmVcpZeLLX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+GVtdRibg8rLBciSm3ERd7gNRqvYP5GrjCtUIbOTEc=",
6+
"target_method": "GET",
7+
"target_url": "https://en.wikipedia.org/wiki/Claude_Shannon",
8+
"target_headers": {},
9+
"target_body": "",
10+
"max_sent_data": 10000,
11+
"max_recv_data": 10000,
12+
"manifest": {
13+
"manifestVersion": "1",
14+
"id": "wikipedia-claude-shannon",
15+
"title": "Wikipedia Claude Shannon",
16+
"description": "Generate a proof that you have visited the Claude Shannon Wikipedia page",
17+
"prepareUrl": "https://en.wikipedia.org/wiki/Claude_Shannon",
18+
"request": {
19+
"method": "GET",
20+
"version": "HTTP/1.1",
21+
"url": "https://en.wikipedia.org/wiki/Claude_Shannon",
22+
"headers": {}
23+
},
24+
"response": {
25+
"status": "200",
26+
"version": "HTTP/1.1",
27+
"message": "OK",
28+
"headers": {
29+
"Content-Type": "text/html; charset=UTF-8"
30+
},
31+
"body": {
32+
"format": "html",
33+
"extractors": [
34+
{
35+
"id": "pageTitle",
36+
"description": "Extract the page title",
37+
"selector": [
38+
"title"
39+
],
40+
"type": "string",
41+
"predicates": [
42+
{
43+
"type": "value",
44+
"comparison": "contains",
45+
"value": "Claude Shannon"
46+
}
47+
]
48+
},
49+
{
50+
"id": "roles",
51+
"description": "Extract his professional roles",
52+
"selector": [
53+
"div#mw-content-text",
54+
"div.mw-parser-output",
55+
"p",
56+
"a"
57+
],
58+
"type": "array",
59+
"predicates": [
60+
{
61+
"type": "value",
62+
"comparison": "contains",
63+
"value": "mathematician",
64+
"case_sensitive": false
65+
},
66+
{
67+
"type": "value",
68+
"comparison": "contains",
69+
"value": "electrical engineer",
70+
"case_sensitive": false
71+
},
72+
{
73+
"type": "value",
74+
"comparison": "contains",
75+
"value": "cryptographer",
76+
"case_sensitive": false
77+
}
78+
]
79+
}
80+
]
81+
}
82+
}
83+
}
84+
}

fixture/client.html.tee_tcp_local.json

Lines changed: 0 additions & 92 deletions
This file was deleted.
Lines changed: 33 additions & 55 deletions
Original file line numberDiff line numberDiff line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KeXZ08Nd+IS1BhGyMgHo6PWMP1fWyfO0DJVUfIqrHqvBy8bW0yNOuhiyU2oeyDRKv75OMxpIrUeX3qvmrVcYUPvfXsVQIDAQABo1MwUTAdBgNVHQ4EFgQUlro6UuKRY+lHZ3T4FQMhoQAJ2a8wHwYDVR0jBBgwFoAUlro6UuKRY+lHZ3T4FQMhoQAJ2a8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEARliSCLdjNI5fFkNwXDK6k6jN5hITrY07XIawUIEwinjQqgLkYFvzXbMtfLwsWmxMPjDVYYDa5Y2NAGcH08b//2z9EuHxMOTOFTKr59BEcVxV1cxV+lspAunH8DLSlLJhf/EeR+MhIIHAfhlE8V7lvlE1EbM+Uj5JYIeefV/4omsGrphyHD3oSJAQDae0su200I/i2yAaTrwXLZ4HtaXsnxKZ4PMPFWaLvMQ8DsLgx2VB3/vQJn74Xepau6mYEWlRnUu90mj79gJOnwBKPlLojF6dJOMIJ2YHr9fI8sUfkVwPFVlkDKJcr0ll5RL3O/naNlLQZuOgijOM5YF5iTrefliVodEHpBPID2mhtq/E+ZIQWLpik8ulsJ8ufN9YfrbjbsiC/KeoMqoFCImRSyMGQDMADo4EV3DNfDFvfrHx0qBMmJ0nkhuGobphegMPCjZ3axvQwQulKuHXmFpAvGYcpK/twBMC1MJkV04tIwVEDZG6id5oKYtrIXHdSFshf6r3z4bbgq6kJnOxZ8Vo4cEw/dgc3hRivr+HnxOJcEk2CTQlCVOiCQAg64OqDEOoswVg6nzoO3RJhFatu+abO22MIXPNGma02zBoQZLYpGzL9z6pMnPKjL15G9H1SYVSTGhmq+GVtdRibg8rLBciSm3ERd7gNRqvYP5GrjCtUIbOTEc=",
55
"target_body": "",
6-
"proving": {
7-
"manifest": {
8-
"manifestVersion": "1",
9-
"id": "reddit-user-karma",
10-
"title": "Total Reddit Karma",
11-
"description": "Generate a proof that you have a certain amount of karma",
12-
"prepareUrl": "https://www.reddit.com/login/",
13-
"request": {
14-
"method": "GET",
15-
"version": "HTTP/1.1",
16-
"url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
17-
"headers": {
18-
},
19-
"body": {
20-
"userId": "<% userId %>"
21-
},
22-
"vars": {
23-
"userId": {
24-
"description": "Reddit username",
25-
"required": true,
26-
"pattern": "^[A-Za-z0-9_-]{3,20}$"
27-
},
28-
"authToken": {
29-
"description": "Authentication token",
30-
"required": false,
31-
"default": "abcdef1234567890abcdef1234567890",
32-
"pattern": "^[A-Za-z0-9]{32}$"
33-
}
34-
},
35-
"extra": {
36-
"headers": {
37-
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36",
38-
"Content-Type": "application/json"
39-
}
40-
}
6+
"target_method": "GET",
7+
"target_url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
8+
"target_headers": {},
9+
"manifest": {
10+
"manifestVersion": "1",
11+
"id": "hello-world",
12+
"title": "Hello World example",
13+
"description": "Prove that a gist contains a hello world message",
14+
"prepareUrl": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
15+
"request": {
16+
"method": "GET",
17+
"version": "HTTP/1.1",
18+
"url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
19+
"headers": {}
20+
},
21+
"response": {
22+
"status": "200",
23+
"version": "HTTP/1.1",
24+
"message": "OK",
25+
"headers": {
26+
"Content-Type": "text/plain; charset=utf-8"
4127
},
42-
"response": {
43-
"status": "200",
44-
"version": "HTTP/1.1",
45-
"message": "OK",
46-
"headers": {
47-
"Content-Type": "text/plain; charset=utf-8"
48-
},
49-
"body": {
50-
"format": "json",
51-
"extractors": [
52-
{
53-
"id": "helloValue",
54-
"description": "Extract the hello value",
55-
"selector": [
56-
"hello"
57-
],
58-
"type": "string"
59-
}
60-
]
61-
}
28+
"body": {
29+
"format": "json",
30+
"extractors": [
31+
{
32+
"id": "helloValue",
33+
"description": "Extract the hello value",
34+
"selector": [
35+
"hello"
36+
],
37+
"type": "string"
38+
}
39+
]
6240
}
6341
}
6442
}

notary/src/proxy.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use axum::{
77
use reqwest::{Request, Response};
88
use serde::Deserialize;
99
use serde_json::Value;
10-
use tracing::info;
10+
use tracing::{debug, info};
1111
use uuid::Uuid;
1212
use web_prover_core::{
1313
hash::keccak_digest,
@@ -19,10 +19,11 @@ use web_prover_core::{
1919
};
2020

2121
use crate::{
22-
error::NotaryServerError,
22+
error::{NotaryServerError, ProxyError},
2323
verifier::{sign_verification, VerifyOutput},
2424
SharedState,
2525
};
26+
2627
#[derive(Deserialize)]
2728
pub struct NotarizeQuery {
2829
session_id: Uuid,
@@ -54,7 +55,7 @@ pub async fn proxy(
5455
let request = from_reqwest_request(&reqwest_request);
5556
// debug!("{:?}", request);
5657

57-
let response = from_reqwest_response(reqwest_response).await;
58+
let response = from_reqwest_response(reqwest_response).await?;
5859
// debug!("{:?}", response);
5960

6061
let tee_proof = create_tee_proof(&payload.manifest, &request, &response, State(state))?;
@@ -64,7 +65,7 @@ pub async fn proxy(
6465

6566
// TODO: This, similarly to other from_* methods, should be a trait
6667
// Requires adding reqwest to proofs crate
67-
async fn from_reqwest_response(response: Response) -> NotaryResponse {
68+
async fn from_reqwest_response(response: Response) -> Result<NotaryResponse, NotaryServerError> {
6869
let status = response.status().as_u16().to_string();
6970
let version = format!("{:?}", response.version());
7071
let message = response.status().canonical_reason().unwrap_or("").to_string();
@@ -73,8 +74,17 @@ async fn from_reqwest_response(response: Response) -> NotaryResponse {
7374
.iter()
7475
.map(|(k, v)| (capitalize_header(k.as_ref()), v.to_str().unwrap_or("").to_string()))
7576
.collect();
76-
let json = response.json().await.ok();
77-
NotaryResponse {
77+
let body = response
78+
.bytes()
79+
.await
80+
.map_err(|_| {
81+
NotaryServerError::ProxyError(ProxyError::Io(std::io::Error::new(
82+
std::io::ErrorKind::Other,
83+
"Failed to read response body",
84+
)))
85+
})?
86+
.to_vec();
87+
Ok(NotaryResponse {
7888
response: ManifestResponse {
7989
status,
8090
version,
@@ -83,8 +93,9 @@ async fn from_reqwest_response(response: Response) -> NotaryResponse {
8393
// TODO: This makes me think that perhaps this should be an optional field or something else
8494
body: ManifestResponseBody::default(),
8595
},
86-
notary_response_body: NotaryResponseBody { body: json },
87-
}
96+
// TODO: Should we remove Option<_> on body?
97+
notary_response_body: NotaryResponseBody { body: Some(body) },
98+
})
8899
}
89100

90101
fn from_reqwest_request(request: &Request) -> ManifestRequest {
@@ -142,6 +153,7 @@ fn validate_notarization_legal(
142153
request: &ManifestRequest,
143154
response: &NotaryResponse,
144155
) -> Result<ManifestValidationResult, NotaryServerError> {
156+
debug!("Validating manifest");
145157
let result = manifest.validate_with(request, response)?;
146158
if !result.is_success() {
147159
info!("Manifest validation failed: {:?}", result.errors());

0 commit comments

Comments
 (0)