@@ -96,10 +96,13 @@ impl WireMessage for w::ProcessIdentityWire {
9696 name : self . name . clone ( ) ,
9797 pid : self . pid ,
9898 uid : self . uid . clone ( ) ,
99- created_time_ms : self . created_time_ms ,
99+ created_time : self . created_time_ms . map ( timestamp_i64_ms ) . transpose ( ) ? ,
100100 parent_pid : self . parent_pid ,
101101 parent_uid : self . parent_uid . clone ( ) ,
102- parent_created_time_ms : self . parent_created_time_ms ,
102+ parent_created_time : self
103+ . parent_created_time_ms
104+ . map ( timestamp_i64_ms)
105+ . transpose ( ) ?,
103106 } )
104107 }
105108
@@ -108,10 +111,10 @@ impl WireMessage for w::ProcessIdentityWire {
108111 name : value. name ,
109112 pid : value. pid ,
110113 uid : value. uid ,
111- created_time_ms : value. created_time_ms ,
114+ created_time_ms : value. created_time . map ( millis_i64 ) . transpose ( ) ? ,
112115 parent_pid : value. parent_pid ,
113116 parent_uid : value. parent_uid ,
114- parent_created_time_ms : value. parent_created_time_ms ,
117+ parent_created_time_ms : value. parent_created_time . map ( millis_i64 ) . transpose ( ) ? ,
115118 } )
116119 }
117120}
@@ -491,6 +494,14 @@ fn millis(v: prost_types::Timestamp) -> Result<u64, FrameError> {
491494 Ok ( u64:: try_from ( v. seconds ) . map_err ( invalid) ? * 1000
492495 + u64:: try_from ( v. nanos ) . map_err ( invalid) ? / 1_000_000 )
493496}
497+ fn timestamp_i64_ms ( value : i64 ) -> Result < prost_types:: Timestamp , FrameError > {
498+ timestamp ( u64:: try_from ( value) . map_err ( invalid) ?)
499+ }
500+
501+ fn millis_i64 ( value : prost_types:: Timestamp ) -> Result < i64 , FrameError > {
502+ i64:: try_from ( millis ( value) ?) . map_err ( invalid)
503+ }
504+
494505impl WireMessage for w:: RequestEnvelope {
495506 type Proto = p:: RequestEnvelope ;
496507 fn to_proto ( & self ) -> Result < Self :: Proto , FrameError > {
@@ -909,6 +920,42 @@ mod tests {
909920 assert ! ( decoded. audit_paths. is_empty( ) ) ;
910921 }
911922
923+ #[ test]
924+ fn process_identity_uses_well_known_timestamps ( ) {
925+ let identity = w:: ProcessIdentityWire {
926+ name : "/bin/true" . to_string ( ) ,
927+ pid : 42 ,
928+ uid : None ,
929+ created_time_ms : Some ( 1_793_620_000_123 ) ,
930+ parent_pid : Some ( 1 ) ,
931+ parent_uid : None ,
932+ parent_created_time_ms : Some ( 1_793_619_999_456 ) ,
933+ } ;
934+ let encoded = identity. to_proto ( ) . unwrap ( ) ;
935+ assert_eq ! (
936+ encoded. created_time,
937+ Some ( prost_types:: Timestamp {
938+ seconds: 1_793_620_000 ,
939+ nanos: 123_000_000 ,
940+ } )
941+ ) ;
942+ assert_eq ! (
943+ encoded. parent_created_time,
944+ Some ( prost_types:: Timestamp {
945+ seconds: 1_793_619_999 ,
946+ nanos: 456_000_000 ,
947+ } )
948+ ) ;
949+ assert_eq ! (
950+ w:: ProcessIdentityWire :: from_proto( encoded. clone( ) ) . unwrap( ) ,
951+ identity
952+ ) ;
953+
954+ let mut invalid_time = encoded;
955+ invalid_time. created_time . as_mut ( ) . unwrap ( ) . nanos = 123_000_001 ;
956+ assert ! ( w:: ProcessIdentityWire :: from_proto( invalid_time) . is_err( ) ) ;
957+ }
958+
912959 #[ test]
913960 fn process_identity_survives_start_exec_and_legacy_responses ( ) {
914961 let identity = w:: ProcessIdentityWire {
0 commit comments