Skip to content

Commit 711706c

Browse files
author
Samuel Groß
committed
Rename --inspect=history to just --inspect
As "history" is the only available inspection option.
1 parent 48e2902 commit 711706c

File tree

8 files changed

+20
-30
lines changed

8 files changed

+20
-30
lines changed

Sources/Fuzzilli/Configuration.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ public struct Configuration {
4646
/// Enable the saving of programs that failed or timed-out during execution.
4747
public let enableDiagnostics: Bool
4848

49-
/// Set of enabled inspection features.
50-
public let inspection: InspectionOptions
49+
/// Whether to enable inspection for generated programs. If enabled, a full record
50+
/// of the steps that led to a particular program will be kept. In particular, a programs
51+
/// ancestor chain (the programs that were mutated to arrive at the current program)
52+
/// is recorded as well as the exact list of mutations and code generations, as well
53+
/// as the reductions performed by the minimizer.
54+
public let enableInspection: Bool
5155

5256
public init(timeout: UInt32 = 250,
5357
skipStartupTests: Bool = false,
@@ -58,15 +62,15 @@ public struct Configuration {
5862
dropoutRate: Double = 0,
5963
collectRuntimeTypes: Bool = false,
6064
enableDiagnostics: Bool = false,
61-
inspection: InspectionOptions = []) {
65+
enableInspection: Bool = false) {
6266
self.timeout = timeout
6367
self.logLevel = logLevel
6468
self.crashTests = crashTests
6569
self.isFuzzing = isFuzzing
6670
self.dropoutRate = dropoutRate
6771
self.minimizationLimit = minimizationLimit
6872
self.enableDiagnostics = enableDiagnostics
69-
self.inspection = inspection
73+
self.enableInspection = enableInspection
7074
}
7175
}
7276

Sources/Fuzzilli/Core/FuzzEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension FuzzEngine {
3232
case .succeeded:
3333
fuzzer.dispatchEvent(fuzzer.events.ValidProgramFound, data: program)
3434
if let aspects = fuzzer.evaluator.evaluate(execution) {
35-
if fuzzer.config.inspection.contains(.history) {
35+
if fuzzer.config.enableInspection {
3636
program.comments.add("Program is interesting due to \(aspects)", at: .footer)
3737
}
3838
fuzzer.processInteresting(program, havingAspects: aspects, origin: .local)

Sources/Fuzzilli/Core/ProgramBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public class ProgramBuilder {
140140
/// Add a trace comment to the currently generated program at the current position.
141141
/// This is only done if history inspection is enabled.
142142
public func trace(_ commentGenerator: @autoclosure () -> String) {
143-
if fuzzer.config.inspection.contains(.history) {
143+
if fuzzer.config.enableInspection {
144144
// Use an autoclosure here so that template strings are only evaluated when they are needed.
145145
comments.add(commentGenerator(), at: .instruction(code.count))
146146
}
@@ -149,7 +149,7 @@ public class ProgramBuilder {
149149
/// Add a trace comment at the start of the currently generated program.
150150
/// This is only done if history inspection is enabled.
151151
public func traceHeader(_ commentGenerator: @autoclosure () -> String) {
152-
if fuzzer.config.inspection.contains(.history) {
152+
if fuzzer.config.enableInspection {
153153
comments.add(commentGenerator(), at: .header)
154154
}
155155
}

Sources/Fuzzilli/Corpus/Corpus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension Corpus {
5252
// And programs in the corpus don't keep their comments
5353
program.comments.removeAll()
5454

55-
if fuzzer.config.inspection.contains(.history) {
55+
if fuzzer.config.enableInspection {
5656
// Except for one identifying them as part of the corpus
5757
program.comments.add("Corpus entry #\(index) on instance \(fuzzer.id) with Corpus type \(name)", at: .header)
5858
}

Sources/Fuzzilli/Fuzzer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public class Fuzzer {
542542
public func makeBuilder(forMutating parent: Program? = nil, mode: ProgramBuilder.Mode = .aggressive) -> ProgramBuilder {
543543
dispatchPrecondition(condition: .onQueue(queue))
544544
// Program ancestor chains are only constructed if inspection mode is enabled
545-
let parent = config.inspection.contains(.history) ? parent : nil
545+
let parent = config.enableInspection ? parent : nil
546546
return ProgramBuilder(for: self, parent: parent, mode: mode)
547547
}
548548

Sources/Fuzzilli/Minimization/Minimizer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class Minimizer: ComponentBase {
4444
let minimizedCode = self.internalMinimize(program, withAspects: aspects, limit: minimizationLimit, runningSynchronously: false)
4545
self.fuzzer.async {
4646
let minimizedProgram: Program
47-
if self.fuzzer.config.inspection.contains(.history) {
47+
if self.fuzzer.config.enableInspection {
4848
minimizedProgram = Program(code: minimizedCode, parent: program)
4949
minimizedProgram.comments.add("Minimizing \(program.id)", at: .header)
5050
} else {

Sources/Fuzzilli/Modules/Storage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public class Storage: Module {
139139
}
140140

141141
// If inspection is enabled, we also include the programs ancestor chain in a separate .history file
142-
if fuzzer.config.inspection.contains(.history) && program.parent != nil {
142+
if fuzzer.config.enableInspection && program.parent != nil {
143143
let lifter = FuzzILLifter()
144144

145145
var ancestors: [Program] = []

Sources/FuzzilliCli/main.swift

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ Options:
9292
--diagnostics : Enable saving of programs that failed or timed-out during execution. Also tracks
9393
executions on the current REPRL instance.
9494
--swarmTesting : Enable Swarm Testing mode. The fuzzer will choose random weights for the code generators per process.
95-
--inspect=opt1,opt2,... : Enable inspection options. The following options are currently available:
96-
history: Additional .fuzzil.history files are written to disk for every program.
97-
These describe in detail how the program was generated through mutations,
98-
code generation, and minimization
95+
--inspect : Enable inspection for generated programs. When enabled, additional .fuzzil.history files are written
96+
to disk for every interesting or crashing program. These describe in detail how the program was generated
97+
through mutations, code generation, and minimization.
9998
--argumentRandomization : Enable JS engine argument randomization
10099
""")
101100
exit(0)
@@ -145,7 +144,7 @@ let instanceType = args["--instanceType"] ?? "standalone"
145144
let corpusSyncMode = args["--corpusSyncMode"] ?? "full"
146145
let dontFuzz = args.has("--dontFuzz")
147146
let diagnostics = args.has("--diagnostics")
148-
let inspect = args["--inspect"]
147+
let inspect = args.has("--inspect")
149148
let swarmTesting = args.has("--swarmTesting")
150149
let randomizingArguments = args.has("--argumentRandomization")
151150

@@ -259,19 +258,6 @@ guard let corpusSyncMode = corpusSyncModeByName[corpusSyncMode] else {
259258
configError("Invalid network corpus synchronization mode \(corpusSyncMode)")
260259
}
261260

262-
var inspectionOptions = InspectionOptions()
263-
if let optionList = inspect {
264-
let options = optionList.components(separatedBy: ",")
265-
for option in options {
266-
switch option {
267-
case "history":
268-
inspectionOptions.insert(.history)
269-
default:
270-
configError("Unknown inspection feature: \(option)")
271-
}
272-
}
273-
}
274-
275261
// Make it easy to detect typos etc. in command line arguments
276262
if args.unusedOptionals.count > 0 {
277263
configError("Invalid arguments: \(args.unusedOptionals)")
@@ -408,7 +394,7 @@ let config = Configuration(timeout: UInt32(timeout),
408394
isFuzzing: !dontFuzz,
409395
minimizationLimit: minimizationLimit,
410396
enableDiagnostics: diagnostics,
411-
inspection: inspectionOptions)
397+
enableInspection: inspect)
412398

413399
let fuzzer = makeFuzzer(for: profile, with: config)
414400

0 commit comments

Comments
 (0)