@@ -36,6 +36,8 @@ struct Args {
3636#[ derive( Debug , Clone , Deserialize ) ]
3737struct SimulatorSettings {
3838 attestation_file : String ,
39+ #[ serde( default = "default_patch_report_data" ) ]
40+ patch_report_data : bool ,
3941}
4042
4143#[ derive( Debug , Clone , Deserialize ) ]
@@ -47,14 +49,22 @@ struct SimulatorCoreConfig {
4749
4850struct SimulatorPlatform {
4951 attestation : VersionedAttestation ,
52+ patch_report_data : bool ,
5053}
5154
5255impl SimulatorPlatform {
53- fn new ( attestation : VersionedAttestation ) -> Self {
54- Self { attestation }
56+ fn new ( attestation : VersionedAttestation , patch_report_data : bool ) -> Self {
57+ Self {
58+ attestation,
59+ patch_report_data,
60+ }
5561 }
5662}
5763
64+ fn default_patch_report_data ( ) -> bool {
65+ true
66+ }
67+
5868impl PlatformBackend for SimulatorPlatform {
5969 fn attestation_for_info ( & self ) -> Result < Attestation > {
6070 Ok ( simulator:: simulated_info_attestation ( & self . attestation ) )
@@ -64,17 +74,24 @@ impl PlatformBackend for SimulatorPlatform {
6474 Ok ( simulator:: simulated_certificate_attestation (
6575 & self . attestation ,
6676 pubkey,
77+ self . patch_report_data ,
6778 ) )
6879 }
6980
7081 fn quote_response ( & self , report_data : [ u8 ; 64 ] , vm_config : & str ) -> Result < GetQuoteResponse > {
71- simulator:: simulated_quote_response ( & self . attestation , report_data, vm_config)
82+ simulator:: simulated_quote_response (
83+ & self . attestation ,
84+ report_data,
85+ vm_config,
86+ self . patch_report_data ,
87+ )
7288 }
7389
7490 fn attest_response ( & self , report_data : [ u8 ; 64 ] ) -> Result < AttestResponse > {
7591 Ok ( simulator:: simulated_attest_response (
7692 & self . attestation ,
7793 report_data,
94+ self . patch_report_data ,
7895 ) )
7996 }
8097
@@ -96,12 +113,24 @@ async fn main() -> Result<()> {
96113 . focus ( "core" )
97114 . extract ( )
98115 . context ( "Failed to extract simulator core config" ) ?;
99- warn ! ( attestation_file = %sim_config. simulator. attestation_file, "starting dstack guest-agent simulator" ) ;
116+ warn ! (
117+ attestation_file = %sim_config. simulator. attestation_file,
118+ patch_report_data = sim_config. simulator. patch_report_data,
119+ "starting dstack guest-agent simulator"
120+ ) ;
121+ if sim_config. simulator . patch_report_data {
122+ warn ! ( "simulator will rewrite report_data to match requests; quote verification may fail against the original fixture signature" ) ;
123+ } else {
124+ warn ! ( "simulator will preserve fixture report_data; cert/key binding and requested report_data may not match" ) ;
125+ }
100126 let attestation =
101127 simulator:: load_versioned_attestation ( & sim_config. simulator . attestation_file ) ?;
102128 let state = AppState :: new (
103129 sim_config. core ,
104- Arc :: new ( SimulatorPlatform :: new ( attestation) ) ,
130+ Arc :: new ( SimulatorPlatform :: new (
131+ attestation,
132+ sim_config. simulator . patch_report_data ,
133+ ) ) ,
105134 )
106135 . await
107136 . context ( "Failed to create simulator app state" ) ?;
@@ -118,7 +147,7 @@ mod tests {
118147 . join ( "../guest-agent/fixtures/attestation.bin" ) ,
119148 )
120149 . expect ( "fixture attestation should load" ) ;
121- SimulatorPlatform :: new ( fixture)
150+ SimulatorPlatform :: new ( fixture, true )
122151 }
123152
124153 #[ test]
@@ -147,4 +176,21 @@ mod tests {
147176 let VersionedAttestation :: V0 { attestation } = patched;
148177 assert_eq ! ( attestation. report_data, report_data) ;
149178 }
179+
180+ #[ test]
181+ fn simulator_can_preserve_fixture_report_data ( ) {
182+ let fixture = simulator:: load_versioned_attestation (
183+ std:: path:: Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) )
184+ . join ( "../guest-agent/fixtures/attestation.bin" ) ,
185+ )
186+ . expect ( "fixture attestation should load" ) ;
187+ let original = fixture. clone ( ) . into_inner ( ) . report_data ;
188+ let platform = SimulatorPlatform :: new ( fixture, false ) ;
189+ let report_data = [ 0x5a ; 64 ] ;
190+ let response = platform. attest_response ( report_data) . unwrap ( ) ;
191+ let patched = VersionedAttestation :: from_scale ( & response. attestation ) . unwrap ( ) ;
192+ let VersionedAttestation :: V0 { attestation } = patched;
193+ assert_eq ! ( attestation. report_data, original) ;
194+ assert_ne ! ( attestation. report_data, report_data) ;
195+ }
150196}
0 commit comments