Skip to content

Commit 98929d9

Browse files
authored
Added constructables function and probabilistic selection of object groups (googleprojectzero#168)
1 parent c0c7f0f commit 98929d9

File tree

4 files changed

+111
-95
lines changed

4 files changed

+111
-95
lines changed

Sources/Fuzzilli/Core/CodeTemplate.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public class CodeTemplate {
7272
var properties: [String] = []
7373
var methods: [String] = []
7474

75-
// TODO: add group with probability here as well?
75+
var group: String? = nil
76+
if probability(0.2) {
77+
group = chooseUniform(from: fuzzer.environment.constructables)
78+
}
7679

7780
// Generate random properties.
7881
// We filter the candidates to avoid cycles in our objects.
@@ -90,9 +93,8 @@ public class CodeTemplate {
9093
methods.append(chooseUniform(from: fuzzer.environment.customMethodNames))
9194
}
9295

93-
return .object(withProperties: properties, withMethods: methods)
96+
return .object(ofGroup: group, withProperties: properties, withMethods: methods)
9497
})
95-
// TODO: emit functions here as well?
9698
}
9799

98100
/// Generate a random function signature.

Sources/Fuzzilli/Core/Environment.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public protocol Environment: Component {
7272
/// The type representing arrays in the target environment.
7373
/// Used e.g. for arrays created through a literal.
7474
var arrayType: Type { get }
75+
76+
/// Returns an array of constructable types
77+
var constructables: [String] { get }
7578

7679
/// Retuns the type representing a function with the given signature.
7780
func functionType(forSignature signature: FunctionSignature) -> Type

0 commit comments

Comments
 (0)