BUILD.gn 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. # Copyright 2016 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. # PDFium fuzzers.
  5. # When adding a fuzzer_test target make sure to add it to the group
  6. # 'pdf_fuzzers'
  7. import("//testing/libfuzzer/fuzzer_test.gni")
  8. import("//testing/test.gni")
  9. import("//third_party/pdfium/pdfium.gni")
  10. import("//third_party/protobuf/proto_library.gni")
  11. template("pdfium_fuzzer_test") {
  12. fuzzer_test(target_name) {
  13. forward_variables_from(invoker, "*", [ "deps" ])
  14. sources = []
  15. deps = [ "//third_party/pdfium/testing/fuzzers:${target_name}_src" ]
  16. if (is_component_build) {
  17. deps += [ "//third_party/pdfium/testing/fuzzers:${target_name}_impl" ]
  18. }
  19. if (defined(invoker.deps)) {
  20. deps += invoker.deps
  21. }
  22. }
  23. }
  24. group("fuzzers") {
  25. }
  26. group("pdf_fuzzers") {
  27. testonly = true
  28. deps = [
  29. ":pdf_cmap_fuzzer",
  30. ":pdf_codec_a85_fuzzer",
  31. ":pdf_codec_fax_fuzzer",
  32. ":pdf_codec_icc_fuzzer",
  33. ":pdf_codec_jbig2_fuzzer",
  34. ":pdf_codec_rle_fuzzer",
  35. ":pdf_font_fuzzer",
  36. ":pdf_hint_table_fuzzer",
  37. ":pdf_jpx_fuzzer",
  38. ":pdf_psengine_fuzzer",
  39. ":pdf_scanlinecompositor_fuzzer",
  40. ":pdf_streamparser_fuzzer",
  41. ":pdf_xml_fuzzer",
  42. ":pdfium_fuzzer",
  43. ]
  44. if (pdf_enable_v8) {
  45. deps += [
  46. ":pdf_cjs_util_fuzzer",
  47. ":pdf_fx_date_helpers_fuzzer",
  48. ]
  49. if (pdf_enable_xfa) {
  50. deps += [
  51. ":pdf_bidi_fuzzer",
  52. ":pdf_cfgas_stringformatter_fuzzer",
  53. ":pdf_cfx_barcode_fuzzer",
  54. ":pdf_codec_jpeg_fuzzer",
  55. ":pdf_css_fuzzer",
  56. ":pdf_formcalc_context_fuzzer",
  57. ":pdf_formcalc_fuzzer",
  58. ":pdf_formcalc_translate_fuzzer",
  59. ":pdfium_xfa_fuzzer",
  60. ":pdfium_xfa_lpm_fuzzer",
  61. ]
  62. if (pdf_enable_xfa_bmp) {
  63. deps += [ ":pdf_codec_bmp_fuzzer" ]
  64. }
  65. if (pdf_enable_xfa_gif) {
  66. deps += [
  67. ":pdf_codec_gif_fuzzer",
  68. ":pdf_lzw_fuzzer",
  69. ]
  70. }
  71. if (pdf_enable_xfa_png) {
  72. deps += [ ":pdf_codec_png_fuzzer" ]
  73. }
  74. if (pdf_enable_xfa_tiff) {
  75. deps += [ ":pdf_codec_tiff_fuzzer" ]
  76. }
  77. }
  78. }
  79. if (is_clang) {
  80. deps += [
  81. ":pdf_cpdf_tounicodemap_fuzzer",
  82. ":pdf_nametree_fuzzer",
  83. ]
  84. if (pdf_enable_xfa) {
  85. deps += [
  86. ":pdf_xfa_fdp_fuzzer",
  87. ":pdf_xfa_raw_fuzzer",
  88. ":pdf_xfa_xdp_fdp_fuzzer",
  89. ]
  90. }
  91. }
  92. }
  93. pdfium_fuzzer_test("pdfium_fuzzer") {
  94. dict = "dicts/pdf.dict"
  95. seed_corpus = "//third_party/pdfium/testing/resources"
  96. grammar_options = [ "grammar=PDF" ]
  97. }
  98. pdfium_fuzzer_test("pdf_cmap_fuzzer") {
  99. }
  100. pdfium_fuzzer_test("pdf_codec_a85_fuzzer") {
  101. }
  102. pdfium_fuzzer_test("pdf_codec_fax_fuzzer") {
  103. }
  104. pdfium_fuzzer_test("pdf_codec_rle_fuzzer") {
  105. }
  106. pdfium_fuzzer_test("pdf_codec_icc_fuzzer") {
  107. dict = "dicts/pdf_codec_icc.dict"
  108. }
  109. pdfium_fuzzer_test("pdf_codec_jbig2_fuzzer") {
  110. }
  111. pdfium_fuzzer_test("pdf_font_fuzzer") {
  112. }
  113. pdfium_fuzzer_test("pdf_hint_table_fuzzer") {
  114. }
  115. pdfium_fuzzer_test("pdf_jpx_fuzzer") {
  116. seed_corpus = "corpora/pdf_jpx"
  117. }
  118. pdfium_fuzzer_test("pdf_psengine_fuzzer") {
  119. }
  120. pdfium_fuzzer_test("pdf_scanlinecompositor_fuzzer") {
  121. }
  122. pdfium_fuzzer_test("pdf_streamparser_fuzzer") {
  123. }
  124. pdfium_fuzzer_test("pdf_xml_fuzzer") {
  125. dict = "dicts/pdf_xml.dict"
  126. seed_corpus = "//third_party/libxml/fuzz/seed_corpus"
  127. }
  128. if (pdf_enable_v8) {
  129. pdfium_fuzzer_test("pdf_cjs_util_fuzzer") {
  130. }
  131. pdfium_fuzzer_test("pdf_fx_date_helpers_fuzzer") {
  132. }
  133. if (pdf_enable_xfa) {
  134. if (pdf_enable_xfa_bmp) {
  135. pdfium_fuzzer_test("pdf_codec_bmp_fuzzer") {
  136. seed_corpus = "corpora/pdf_codec_bmp"
  137. }
  138. }
  139. if (pdf_enable_xfa_gif) {
  140. pdfium_fuzzer_test("pdf_codec_gif_fuzzer") {
  141. dict = "dicts/pdf_codec_gif.dict"
  142. seed_corpus = "corpora/pdf_codec_gif"
  143. }
  144. }
  145. pdfium_fuzzer_test("pdf_codec_jpeg_fuzzer") {
  146. dict = "dicts/pdf_codec_jpeg.dict"
  147. seed_corpus = "corpora/pdf_codec_jpeg"
  148. }
  149. if (pdf_enable_xfa_png) {
  150. pdfium_fuzzer_test("pdf_codec_png_fuzzer") {
  151. dict = "dicts/pdf_codec_png.dict"
  152. seed_corpuses = [
  153. "corpora/pdf_codec_png",
  154. "//components/viz/test/data",
  155. "//third_party/blink/web_tests/images/png-suite/samples",
  156. "//third_party/blink/web_tests/images/resources/pngfuzz",
  157. ]
  158. }
  159. }
  160. if (pdf_enable_xfa_tiff) {
  161. pdfium_fuzzer_test("pdf_codec_tiff_fuzzer") {
  162. dict = "dicts/pdf_codec_tiff.dict"
  163. seed_corpus = "corpora/pdf_codec_tiff"
  164. }
  165. }
  166. pdfium_fuzzer_test("pdf_css_fuzzer") {
  167. dict = "dicts/pdf_css.dict"
  168. }
  169. pdfium_fuzzer_test("pdf_formcalc_context_fuzzer") {
  170. dict = "dicts/pdf_xfa_js.dict"
  171. }
  172. pdfium_fuzzer_test("pdf_formcalc_fuzzer") {
  173. dict = "dicts/pdf_formcalc.dict"
  174. }
  175. pdfium_fuzzer_test("pdf_formcalc_translate_fuzzer") {
  176. dict = "dicts/pdf_formcalc.dict"
  177. }
  178. if (pdf_enable_xfa_gif) {
  179. pdfium_fuzzer_test("pdf_lzw_fuzzer") {
  180. }
  181. }
  182. pdfium_fuzzer_test("pdf_bidi_fuzzer") {
  183. }
  184. pdfium_fuzzer_test("pdf_cfx_barcode_fuzzer") {
  185. }
  186. pdfium_fuzzer_test("pdf_cfgas_stringformatter_fuzzer") {
  187. }
  188. pdfium_fuzzer_test("pdfium_xfa_fuzzer") {
  189. dict = "dicts/pdf.dict"
  190. seed_corpus = "corpora/xfa"
  191. grammar_options = [ "grammar=PDF" ]
  192. }
  193. static_library("proto_to_xfa") {
  194. sources = [
  195. "pdfium_xfa_lpm_fuzzer/proto_to_xfa.cc",
  196. "pdfium_xfa_lpm_fuzzer/proto_to_xfa.h",
  197. "pdfium_xfa_lpm_fuzzer/simple_xfa_pdf.cc",
  198. "pdfium_xfa_lpm_fuzzer/simple_xfa_pdf.h",
  199. ]
  200. deps = [ "//base" ]
  201. public_deps = [ ":xfa_proto" ]
  202. }
  203. fuzzer_test("pdfium_xfa_lpm_fuzzer") {
  204. sources = [ "pdfium_xfa_lpm_fuzzer/fuzzer.cc" ]
  205. deps = [
  206. ":proto_to_xfa",
  207. "//base",
  208. "//third_party/libprotobuf-mutator",
  209. "//third_party/pdfium",
  210. "//third_party/pdfium/testing/fuzzers:fuzzer_init_public",
  211. ]
  212. if (is_component_build) {
  213. deps += [
  214. "//third_party/pdfium/testing/fuzzers:pdfium_xfa_lpm_fuzzer_impl",
  215. ]
  216. } else {
  217. deps +=
  218. [ "//third_party/pdfium/testing/fuzzers:pdfium_xfa_lpm_fuzzer_src" ]
  219. }
  220. include_dirs = [ "//third_party/pdfium" ]
  221. # Don't build the fuzzer while it isn't actually producing XFA.
  222. # TODO(metzman): Remove this once the fuzzer actually fuzzes XFA.
  223. additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
  224. }
  225. test("pdfium_xfa_lpm_unittest") {
  226. sources = [ "pdfium_xfa_lpm_fuzzer/simple_xfa_pdf_unittest.cc" ]
  227. deps = [
  228. ":proto_to_xfa",
  229. "//base/test:run_all_unittests",
  230. "//testing/gtest",
  231. ]
  232. }
  233. }
  234. }
  235. if (is_clang) {
  236. pdfium_fuzzer_test("pdf_cpdf_tounicodemap_fuzzer") {
  237. }
  238. pdfium_fuzzer_test("pdf_nametree_fuzzer") {
  239. }
  240. if (pdf_enable_xfa) {
  241. pdfium_fuzzer_test("pdf_xfa_fdp_fuzzer") {
  242. }
  243. pdfium_fuzzer_test("pdf_xfa_raw_fuzzer") {
  244. dict = "dicts/pdf_xfa_raw_fuzzer.dict"
  245. }
  246. pdfium_fuzzer_test("pdf_xfa_xdp_fdp_fuzzer") {
  247. dict = "dicts/pdf_xfa_raw_fuzzer.dict"
  248. }
  249. }
  250. }
  251. proto_library("xfa_proto") {
  252. sources = [ "pdfium_xfa_lpm_fuzzer/xfa.proto" ]
  253. }