Skip to content

Commit

Permalink
Allow adding additional ObjectGroups to environment using Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
0xedward authored and carl-smith committed Mar 5, 2024
1 parent db9aa6e commit d4bf44f
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/DuktapeProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ let duktapeProfile = Profile(

],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/JSCProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,7 @@ let jscProfile = Profile(
"ensureArrayStorage" : .function([] => .anything),
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/JerryscriptProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ let jerryscriptProfile = Profile(
"placeholder" : .function([] => .undefined),
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
1 change: 1 addition & 0 deletions Sources/FuzzilliCli/Profiles/Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct Profile {
let disabledMutators: [String]

let additionalBuiltins: [String: ILType]
let additionalObjectGroups: [ObjectGroup]

// An optional post-processor that is executed for every sample generated for fuzzing and can modify it.
let optionalPostProcessor: FuzzingPostProcessor?
Expand Down
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/QjsProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ let qjsProfile = Profile(
"placeholder" : .function([] => .undefined)
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/QtjsProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ let qtjsProfile = Profile(
"gc" : .function([] => .undefined),
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/Serenity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ let serenityProfile = Profile(
"gc": .function([] => .undefined)
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/SpidermonkeyProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,7 @@ let spidermonkeyProfile = Profile(

],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
1 change: 1 addition & 0 deletions Sources/FuzzilliCli/Profiles/V8HoleFuzzingProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@ let v8HoleFuzzingProfile = Profile(
"d8" : .object(),
"Worker" : .constructor([.anything, .object()] => .object(withMethods: ["postMessage","getMessage"])),
],
additionalObjectGroups: [],
optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/V8Profile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -614,5 +614,7 @@ let v8Profile = Profile(
"Worker" : .constructor([.anything, .object()] => .object(withMethods: ["postMessage","getMessage"])),
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
2 changes: 2 additions & 0 deletions Sources/FuzzilliCli/Profiles/XSProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ let xsProfile = Profile(
"placeholder" : .function([] => .undefined),
],

additionalObjectGroups: [],

optionalPostProcessor: nil
)
8 changes: 7 additions & 1 deletion Sources/FuzzilliCli/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,13 @@ func makeFuzzer(with configuration: Configuration) -> Fuzzer {
}

// The environment containing available builtins, property names, and method names.
let environment = JavaScriptEnvironment(additionalBuiltins: profile.additionalBuiltins, additionalObjectGroups: [])
let environment = JavaScriptEnvironment(additionalBuiltins: profile.additionalBuiltins, additionalObjectGroups: profile.additionalObjectGroups)
if !profile.additionalBuiltins.isEmpty {
logger.verbose("Loaded additional builtins from profile: \(profile.additionalBuiltins.map { $0.key })")
}
if !profile.additionalObjectGroups.isEmpty {
logger.verbose("Loaded additional ObjectGroups from profile: \(profile.additionalObjectGroups.map { $0.name })")
}

// A lifter to translate FuzzIL programs to JavaScript.
let lifter = JavaScriptLifter(prefix: profile.codePrefix,
Expand Down
3 changes: 2 additions & 1 deletion Targets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ Once a profile has been made, it also needs to be added to the list in [Profile.
- `additionalProgramTemplates`: Additional [program templates](../Docs/HowFuzzilliWorks.md#program-templates) for the fuzzer to generate programs from. Examples for ProgramTemplates can be found in [ProgramTemplates.swift](../Sources/Fuzzilli/CodeGen/ProgramTemplates.swift)
- `disabledCodeGenerators`: List of code generators to disable. The current list of code generators is in [CodeGenerators.swift](../Sources/Fuzzilli/CodeGen/CodeGenerators.swift) with their respective weights in [CodeGeneratorWeights.swift](../Sources/Fuzzilli/CodeGen/CodeGeneratorsWeights.swift).
- `disabledMutators`: List of mutators to disable, in other words, the mutators in this list will not be selected to mutate input during the fuzzing loop. The current list of enabled mutators is in [FuzzilliCli/main.swift](../Sources/FuzzilliCli/main.swift)
- `additionalBuiltins`: Additional unique builtins for the JS engine. The list does not have to be exhaustive, but should include functionality likely to cause bugs. An example would be a function that triggers garbage collection.
- `additionalBuiltins`: Additional unique builtins for the JS engine. The list does not have to be exhaustive, but should include functionality likely to cause bugs. An example would be a function that triggers garbage collection.
- `additionalObjectGroups`: Additional unique [ObjectGroup](../Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift)s for the JS engine. Examples for ObjectGroups can be found in [JavaScriptEnvironment.swift](../Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift)

0 comments on commit d4bf44f

Please sign in to comment.