matrix-fuzz

git clone git://archive.git.mtrnord.blog/MTRNord/matrix-fuzz.git
Log | Files | Refs | README | LICENSE

createRoom.rs (2646B)


      1 #![allow(non_snake_case)]
      2 //use matrix_fuzz::{client, secrets::ACCESS_TOKEN, types::create_room::CreateRoomMagicJSON};
      3 
      4 fn main() {
      5     /*
      6     afl::fuzz_nohook!(|data: CreateRoomMagicJSON| {
      7         let mut data = data;
      8         // HACK due to https://github.com/matrix-org/synapse/issues/13510
      9         if let Some(room_alias_name) = &data.room_alias_name {
     10             if room_alias_name.contains('\0') {
     11                 data.room_alias_name = None;
     12             }
     13         }
     14 
     15         // HACK due to NUL in type or state_key
     16         if let Some(initial_state) = &mut data.initial_state {
     17             initial_state
     18                 .retain(|state| !(state._type.contains('\0') || state.state_key.contains('\0')));
     19             // for state in initial_state {
     20             //     if state._type.contains('\0') {
     21             //         return;
     22             //     }
     23             //     if state.state_key.contains('\0') {
     24             //         return;
     25             //     }
     26             // }
     27         }
     28 
     29         /*// HACK due to https://github.com/matrix-org/synapse/issues/13511
     30         if let Some(pids) = &data.invite_3pid {
     31             for pid in pids {
     32                 if pid.address.is_empty() {
     33                     return;
     34                 }
     35             }
     36         }*/
     37 
     38         // TODO: Login once and reuse the access token
     39         let access_token = ACCESS_TOKEN;
     40         let client = client();
     41         let resp = client
     42             .post("http://localhost:8008/_matrix/client/v3/createRoom")
     43             .header("Authorization", format!("Bearer {}", access_token))
     44             .json(&data)
     45             .send();
     46         if let Ok(resp) = resp {
     47             let status = resp.status();
     48             if !status.is_success() {
     49                 //println!("Status: {:?}", status);
     50                 let content = resp.text();
     51                 if let Ok(ref content) = content {
     52                     if content.contains("M_ROOM_IN_USE")
     53                         || content.contains("Invalid characters in room alias")
     54                         || content.contains("':' is not permitted in the room alias name. Please note this expects a local part — 'wombat', not '#wombat:example.com'.")
     55                         || content.contains("M_UNSUPPORTED_ROOM_VERSION")
     56                         || content.contains("Invalid user_id")
     57                         || content.contains("is not a valid preset")
     58                         || content.contains("You are not allowed to set others state")
     59                     {
     60                         return;
     61                     }
     62                 }
     63 
     64                 panic!("Content: {:?}", content);
     65             }
     66         }
     67     });*/
     68 }