-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaaf_mutator_ext.h
More file actions
50 lines (43 loc) · 1.99 KB
/
Copy pathlaaf_mutator_ext.h
File metadata and controls
50 lines (43 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef LAAF_MUTATOR_EXT_H_
#define LAAF_MUTATOR_EXT_H_
#include "laaf_mutator.h"
// ============================================================
// M9: Token-Level Mutation (byte mutation alongside AST)
// ============================================================
class TokenMutator : public Mutator {
public:
const char* name() const override { return "token"; }
bool can_mutate(const Slot& slot) const override;
bool mutate(re2::Regexp* root, const std::vector<Slot>& slots, RNG& rng) override;
};
// ============================================================
// M10: Fragment Recombination (LangFuzz-style)
// ============================================================
class FragmentMutator : public Mutator {
public:
const char* name() const override { return "fragment"; }
bool can_mutate(const Slot& slot) const override;
bool mutate(re2::Regexp* root, const std::vector<Slot>& slots, RNG& rng) override;
// Maintain a fragment pool across calls
static std::vector<std::string>& fragment_pool();
static void add_fragment(const std::string& s);
};
// ============================================================
// M11: Error-Injection Mutator (deliberately create malformed patterns)
// ============================================================
class ErrorInjectMutator : public Mutator {
public:
const char* name() const override { return "error_inject"; }
bool can_mutate(const Slot& slot) const override;
bool mutate(re2::Regexp* root, const std::vector<Slot>& slots, RNG& rng) override;
};
// ============================================================
// M12: Deep Combine (chain 3 mutations via dump→reparse→remutate)
// ============================================================
class DeepCombineMutator : public Mutator {
public:
const char* name() const override { return "deep_combine"; }
bool can_mutate(const Slot& slot) const override;
bool mutate(re2::Regexp* root, const std::vector<Slot>& slots, RNG& rng) override;
};
#endif