sh1k4ku commited on
Commit
69619e7
·
verified ·
1 Parent(s): 02e79bb

Include Q5 fuzz.py code and crash bytes in the JSON export

Browse files
Files changed (2) hide show
  1. assignment3.html +13 -0
  2. coverage_fuzzing/app.js +2 -0
assignment3.html CHANGED
@@ -454,6 +454,18 @@ const Q44_ASSERT_TEXT = `assert parking_fee(@1@, @2@, @3@) == @4@`;
454
  buildBlanks(document.getElementById("q44assert"), Q44_ASSERT_TEXT, answers.q44assert, "short");
455
 
456
  // ============ JSON export ============
 
 
 
 
 
 
 
 
 
 
 
 
457
  function buildJSON(){
458
  return {
459
  assignment: "Assignment 3: Software Testing",
@@ -477,6 +489,7 @@ function buildJSON(){
477
  regression_assert: Object.assign({1:"",2:"",3:"",4:""}, answers.q44assert),
478
  },
479
  },
 
480
  }
481
  };
482
  }
 
454
  buildBlanks(document.getElementById("q44assert"), Q44_ASSERT_TEXT, answers.q44assert, "short");
455
 
456
  // ============ JSON export ============
457
+ function getQ5State(){
458
+ try {
459
+ const win = document.querySelector('iframe[title="Q5 Coverage-Guided Fuzzing"]').contentWindow;
460
+ return {
461
+ fuzz_py: win.__editor ? win.__editor.getValue() : "",
462
+ crash_bug1_hex: (win.__crashes && win.__crashes.bug1) || "",
463
+ crash_bug2_hex: (win.__crashes && win.__crashes.bug2) || "",
464
+ };
465
+ } catch (_) {
466
+ return { fuzz_py: "", crash_bug1_hex: "", crash_bug2_hex: "" };
467
+ }
468
+ }
469
  function buildJSON(){
470
  return {
471
  assignment: "Assignment 3: Software Testing",
 
489
  regression_assert: Object.assign({1:"",2:"",3:"",4:""}, answers.q44assert),
490
  },
491
  },
492
+ q5: getQ5State(),
493
  }
494
  };
495
  }
coverage_fuzzing/app.js CHANGED
@@ -41,6 +41,7 @@ function renderEdges(numEdges, covered) {
41
  }
42
 
43
  const CRASH_KINDS = ["bug1", "bug2"];
 
44
 
45
  function resetDashboard() {
46
  $("s-execs").textContent = "0";
@@ -90,6 +91,7 @@ function spawnWorker() {
90
  const blob = new Blob([bytes], { type: "application/octet-stream" });
91
  $(`crash-${kind}-dl`).href = URL.createObjectURL(blob);
92
  $(`crash-${kind}`).style.display = "block";
 
93
  print(`💥 crash saved [${kind}] (` + hex + ")", "#ff9aa2");
94
  break;
95
  }
 
41
  }
42
 
43
  const CRASH_KINDS = ["bug1", "bug2"];
44
+ window.__crashes = { bug1: null, bug2: null }; // exposed for the parent page's JSON export
45
 
46
  function resetDashboard() {
47
  $("s-execs").textContent = "0";
 
91
  const blob = new Blob([bytes], { type: "application/octet-stream" });
92
  $(`crash-${kind}-dl`).href = URL.createObjectURL(blob);
93
  $(`crash-${kind}`).style.display = "block";
94
+ window.__crashes[kind] = hex;
95
  print(`💥 crash saved [${kind}] (` + hex + ")", "#ff9aa2");
96
  break;
97
  }