fuzz: add ldb ldif fuzzer
[Samba.git] / lib / fuzzing / wscript_build
blobb5d699e4dcdc3e2c753613714742996aebdbeaa3
1 #!/usr/bin/env python
3 from waflib import Build
5 bld.SAMBA_SUBSYSTEM('fuzzing',
6 source='fuzzing.c',
7 deps='talloc')
9 bld.SAMBA_SUBSYSTEM('afl-fuzz-main',
10 source='afl-fuzz-main.c',
11 deps='samba-util',
12 enabled=bld.env.enable_afl_fuzzer
15 bld.SAMBA_BINARY('fuzz_tiniparser',
16 source='fuzz_tiniparser.c',
17 deps='fuzzing tiniparser talloc afl-fuzz-main',
18 fuzzer=True)
20 bld.SAMBA_BINARY('fuzz_oLschema2ldif',
21 source='fuzz_oLschema2ldif.c',
22 deps='fuzzing oLschema2ldif-lib afl-fuzz-main',
23 fuzzer=True)
25 bld.SAMBA_BINARY('fuzz_reg_parse',
26 source='fuzz_reg_parse.c',
27 deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
28 fuzzer=True)
30 bld.SAMBA_BINARY('fuzz_regfio',
31 source='fuzz_regfio.c',
32 deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
33 fuzzer=True)
35 bld.SAMBA_BINARY('fuzz_lzxpress',
36 source='fuzz_lzxpress.c',
37 deps='fuzzing LZXPRESS afl-fuzz-main',
38 fuzzer=True)
40 bld.SAMBA_BINARY('fuzz_ldap_decode',
41 source='fuzz_ldap_decode.c',
42 deps='fuzzing cli-ldap afl-fuzz-main',
43 fuzzer=True)
45 bld.SAMBA_BINARY('fuzz_ldb_parse_control',
46 source='fuzz_ldb_parse_control.c',
47 deps='fuzzing ldb afl-fuzz-main',
48 fuzzer=True)
50 bld.SAMBA_BINARY('fuzz_ldb_dn_explode',
51 source='fuzz_ldb_dn_explode.c',
52 deps='fuzzing ldb afl-fuzz-main',
53 fuzzer=True)
55 bld.SAMBA_BINARY('fuzz_ldb_ldif_read',
56 source='fuzz_ldb_ldif_read.c',
57 deps='fuzzing ldb afl-fuzz-main',
58 fuzzer=True)
60 bld.SAMBA_BINARY('fuzz_ldb_parse_tree',
61 source='fuzz_ldb_parse_tree.c',
62 deps='fuzzing ldb afl-fuzz-main',
63 fuzzer=True)
65 # The fuzz_type and fuzz_function parameters make the built
66 # fuzzer take the same input as ndrdump and so the same that
67 # could be sent to the client or server as the stub data.
69 def SAMBA_NDR_FUZZ(bld, interface, auto_deps=False,
70 fuzz_type=None, fuzz_function=None):
71 name = "fuzz_ndr_%s" % (interface.lower())
72 fuzz_dir = os.path.join(bld.env.srcdir, 'lib/fuzzing')
73 fuzz_reldir = os.path.relpath(fuzz_dir, bld.path.abspath())
74 fuzz_src = os.path.join(fuzz_reldir, 'fuzz_ndr_X.c')
76 cflags = "-D FUZZ_PIPE_TABLE=ndr_table_%s" % interface
77 if fuzz_type:
78 name += "_%s" % (fuzz_type)
79 cflags += " -D FUZZ_TYPE=%s " % (fuzz_type)
80 if fuzz_type and fuzz_function:
81 name += "_%d" % (fuzz_function)
82 cflags += " -D FUZZ_FUNCTION=%d" % (fuzz_function)
84 fuzz_named_src = os.path.join(fuzz_reldir,
85 '%s.c' % (name))
86 # Work around an issue that WAF is invoked from up to 3 different
87 # directories so doesn't create a unique name for the multiple .o
88 # files like it would if called from just one place.
89 bld.SAMBA_GENERATOR(fuzz_named_src,
90 source=fuzz_src,
91 target=fuzz_named_src,
92 rule='cp ${SRC} ${TGT}')
94 if auto_deps:
95 deps = "afl-fuzz-main talloc ndr NDR_%s" % interface.upper()
96 else:
97 deps = "afl-fuzz-main ndr-table NDR_DCERPC"
99 bld.SAMBA_BINARY(name, source=fuzz_named_src,
100 cflags = cflags,
101 deps = deps,
102 fuzzer=True)
104 Build.BuildContext.SAMBA_NDR_FUZZ = SAMBA_NDR_FUZZ
106 # fuzz_ndr_X is generated from the list if IDL fed to PIDL
107 # however there are exceptions to the normal pattern
108 bld.SAMBA_NDR_FUZZ('IOXIDResolver') # oxidresolver.idl
109 bld.SAMBA_NDR_FUZZ('IRemoteActivation') # remact.idl
110 bld.SAMBA_NDR_FUZZ('iremotewinspool') # winspool.idl
111 bld.SAMBA_NDR_FUZZ('FileServerVssAgent') # fsvrp.idl
112 bld.SAMBA_NDR_FUZZ('lsarpc') # lsa.idl
113 bld.SAMBA_NDR_FUZZ('netdfs') # dfs.idl
114 bld.SAMBA_NDR_FUZZ('nfs4acl_interface') # nfs4acl.idl
115 bld.SAMBA_NDR_FUZZ('rpcecho') # echo.idl
117 # quota.idl
118 bld.SAMBA_NDR_FUZZ('file_quota')
119 bld.SAMBA_NDR_FUZZ('smb2_query_quota')
120 bld.SAMBA_NDR_FUZZ('smb1_nt_transact_query_quota')
122 # ioctl.idl
123 bld.SAMBA_NDR_FUZZ('copychunk')
124 bld.SAMBA_NDR_FUZZ('compression')
125 bld.SAMBA_NDR_FUZZ('netinterface')
126 bld.SAMBA_NDR_FUZZ('sparse')
127 bld.SAMBA_NDR_FUZZ('resiliency')
128 bld.SAMBA_NDR_FUZZ('trim')
130 # WMI tables
131 bld.SAMBA_NDR_FUZZ('IWbemClassObject')
132 bld.SAMBA_NDR_FUZZ('IWbemServices')
133 bld.SAMBA_NDR_FUZZ('IEnumWbemClassObject')
134 bld.SAMBA_NDR_FUZZ('IWbemContext')
135 bld.SAMBA_NDR_FUZZ('IWbemLevel1Login')
136 bld.SAMBA_NDR_FUZZ('IWbemWCOSmartEnum')
137 bld.SAMBA_NDR_FUZZ('IWbemFetchSmartEnum')
138 bld.SAMBA_NDR_FUZZ('IWbemCallResult')
139 bld.SAMBA_NDR_FUZZ('IWbemObjectSink')
141 # DCOM tables
142 bld.SAMBA_NDR_FUZZ('dcom_Unknown')
143 bld.SAMBA_NDR_FUZZ('IUnknown')
144 bld.SAMBA_NDR_FUZZ('IClassFactory')
145 bld.SAMBA_NDR_FUZZ('IRemUnknown')
146 bld.SAMBA_NDR_FUZZ('IClassActivator')
147 bld.SAMBA_NDR_FUZZ('ISCMLocalActivator')
148 bld.SAMBA_NDR_FUZZ('IMachineLocalActivator')
149 bld.SAMBA_NDR_FUZZ('ILocalObjectExporter')
150 bld.SAMBA_NDR_FUZZ('ISystemActivator')
151 bld.SAMBA_NDR_FUZZ('IRemUnknown2')
152 bld.SAMBA_NDR_FUZZ('IDispatch')
153 bld.SAMBA_NDR_FUZZ('IMarshal')
154 bld.SAMBA_NDR_FUZZ('ICoffeeMachine')
155 bld.SAMBA_NDR_FUZZ('IStream')
157 # Specific struct or function on the interface
159 bld.SAMBA_NDR_FUZZ('spoolss',
160 auto_deps=True,
161 fuzz_type="TYPE_IN",
162 fuzz_function=65)