Skip to content

Commit 10b88d2

Browse files
committed
fix(sandbox): address PR review feedback for SigV4 signing
- Add signing_region to OPA data JSON alongside signing_service - Add round-trip test for signing_region preservation - Remove access field from Bedrock example (uses rules instead) - Change access: allow to access: full in S3, STS, and region override doc examples Signed-off-by: Jesse Jaggars <[email protected]>
1 parent 6db6ff1 commit 10b88d2

2 files changed

Lines changed: 71 additions & 4 deletions

File tree

‎crates/openshell-supervisor-network/src/opa.rs‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,9 @@ fn proto_to_opa_data_json(proto: &ProtoSandboxPolicy, entrypoint_pid: u32) -> St
11241124
if !e.signing_service.is_empty() {
11251125
ep["signing_service"] = e.signing_service.clone().into();
11261126
}
1127+
if !e.signing_region.is_empty() {
1128+
ep["signing_region"] = e.signing_region.clone().into();
1129+
}
11271130
if !e.persisted_queries.is_empty() {
11281131
ep["persisted_queries"] = e.persisted_queries.clone().into();
11291132
}
@@ -2785,6 +2788,67 @@ network_policies:
27852788
assert_eq!(l7.signing_service, "bedrock");
27862789
}
27872790

2791+
#[test]
2792+
fn l7_endpoint_config_preserves_proto_signing_region() {
2793+
let mut network_policies = std::collections::HashMap::new();
2794+
network_policies.insert(
2795+
"custom_vpc".to_string(),
2796+
NetworkPolicyRule {
2797+
name: "custom_vpc".to_string(),
2798+
endpoints: vec![NetworkEndpoint {
2799+
host: "custom-vpc-endpoint.example.com".to_string(),
2800+
port: 443,
2801+
protocol: "rest".to_string(),
2802+
enforcement: "enforce".to_string(),
2803+
access: "full".to_string(),
2804+
credential_signing: "sigv4".to_string(),
2805+
signing_service: "s3".to_string(),
2806+
signing_region: "us-west-2".to_string(),
2807+
..Default::default()
2808+
}],
2809+
binaries: vec![NetworkBinary {
2810+
path: "/usr/local/bin/aws".to_string(),
2811+
..Default::default()
2812+
}],
2813+
},
2814+
);
2815+
let proto = ProtoSandboxPolicy {
2816+
version: 1,
2817+
filesystem: Some(ProtoFs {
2818+
include_workdir: true,
2819+
read_only: vec![],
2820+
read_write: vec![],
2821+
}),
2822+
landlock: Some(openshell_core::proto::LandlockPolicy {
2823+
compatibility: "best_effort".to_string(),
2824+
}),
2825+
process: Some(ProtoProc {
2826+
run_as_user: "sandbox".to_string(),
2827+
run_as_group: "sandbox".to_string(),
2828+
}),
2829+
network_policies,
2830+
};
2831+
2832+
let engine = OpaEngine::from_proto(&proto).expect("engine from proto");
2833+
let input = NetworkInput {
2834+
host: "custom-vpc-endpoint.example.com".into(),
2835+
port: 443,
2836+
binary_path: PathBuf::from("/usr/local/bin/aws"),
2837+
binary_sha256: "unused".into(),
2838+
ancestors: vec![],
2839+
cmdline_paths: vec![],
2840+
};
2841+
2842+
let config = engine
2843+
.query_endpoint_config(&input)
2844+
.unwrap()
2845+
.expect("endpoint config");
2846+
let l7 = crate::l7::parse_l7_config(&config).unwrap();
2847+
assert_eq!(l7.credential_signing, crate::l7::CredentialSigning::SigV4);
2848+
assert_eq!(l7.signing_service, "s3");
2849+
assert_eq!(l7.signing_region, "us-west-2");
2850+
}
2851+
27882852
#[test]
27892853
fn l7_endpoint_config_preserves_proto_request_body_credential_rewrite() {
27902854
let mut network_policies = std::collections::HashMap::new();

‎docs/providers/aws-sigv4.mdx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ network_policies:
5454
- host: bedrock-runtime.us-east-1.amazonaws.com
5555
port: 443
5656
protocol: rest
57-
access: allow
5857
credential_signing: sigv4
5958
signing_service: bedrock
6059
rules:
@@ -63,6 +62,10 @@ network_policies:
6362
path: /model/*/invoke
6463
```
6564
65+
<Note>
66+
The Bedrock example uses `rules` for fine-grained access control. When `rules` are present, omit the `access` field — they are mutually exclusive.
67+
</Note>
68+
6669
### S3 Example
6770

6871
```yaml
@@ -72,7 +75,7 @@ network_policies:
7275
- host: "*.s3.us-east-1.amazonaws.com"
7376
port: 443
7477
protocol: rest
75-
access: allow
78+
access: full
7679
credential_signing: sigv4
7780
signing_service: s3
7881
```
@@ -86,7 +89,7 @@ network_policies:
8689
- host: sts.us-east-1.amazonaws.com
8790
port: 443
8891
protocol: rest
89-
access: allow
92+
access: full
9093
credential_signing: sigv4
9194
signing_service: sts
9295
```
@@ -123,7 +126,7 @@ endpoints:
123126
- host: custom-vpc-endpoint.example.com
124127
port: 443
125128
protocol: rest
126-
access: allow
129+
access: full
127130
credential_signing: sigv4
128131
signing_service: s3
129132
signing_region: us-west-2

0 commit comments

Comments
 (0)