MCPcopy Create free account
hub / github.com/nodejs/node / mutate

Method mutate

deps/v8/tools/clusterfuzz/js_fuzzer/script_mutator.js:205–242  ·  view source on GitHub ↗
(source, context)

Source from the content-addressed store, hash-verified

203 }
204
205 mutate(source, context) {
206 let mutators = this.mutators.slice();
207 let annotations = [];
208 if (random.choose(this.settings.SCRIPT_MUTATOR_SHUFFLE)){
209 annotations.push(' Script mutator: using shuffled mutators');
210 random.shuffle(mutators);
211 }
212
213 if (random.choose(this.settings.SCRIPT_MUTATOR_EXTRA_MUTATIONS)){
214 for (let i = random.randInt(1, MAX_EXTRA_MUTATIONS); i > 0; i--) {
215 let mutator = random.single(this.mutators);
216 mutators.push(mutator);
217 annotations.push(` Script mutator: extra ${mutator.constructor.name}`);
218 }
219 }
220
221 // We always remove certain closures first.
222 mutators.unshift(this.closures);
223
224 // Try-catch wrapping should follow after error-prone mutations.
225 mutators.push(this.trycatch);
226
227 // Non-error-prone mutations that should not get further arbitrarily mutated.
228 // It is ok to unicode escape, as we do next.
229 mutators.push(this.timeout);
230
231 // This shouldn't get further mutated, because Babel functionality gets broken
232 // when identifier names are changed.
233 mutators.push(this.unicode);
234
235 for (const mutator of mutators) {
236 mutator.mutate(source, context);
237 }
238
239 for (const annotation of annotations.reverse()) {
240 sourceHelpers.annotateWithComment(source.ast, annotation);
241 }
242 }
243
244 /**
245 * Particular dependencies have precedence over others due to duplicate

Callers 2

mutateInputsMethod · 0.95
analyzeContextFunction · 0.45

Calls 4

shuffleMethod · 0.80
unshiftMethod · 0.80
sliceMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected