Kitxuuu commited on
Commit
da49467
·
verified ·
1 Parent(s): 18d62df

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-tika-delta-03/afc-tika/tika-parsers/tika-parsers-extended/tika-parser-scientific-package/src/test/resources/2.4.0-tesseract.txt +358 -0
  2. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder-python/Dockerfile +20 -0
  3. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/bash_parser.py +235 -0
  4. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_fuzztests.sh +126 -0
  5. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_go_fuzzer +69 -0
  6. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz +33 -0
  7. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/debug_afl +40 -0
  8. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/detect_repo_test.py +121 -0
  9. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_go.sh +43 -0
  10. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_rust.sh +22 -0
  11. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_swift.sh +67 -0
  12. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/ossfuzz_coverage_runner.go +69 -0
  13. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/precompile_afl +35 -0
  14. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/precompile_honggfuzz +45 -0
  15. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/write_labels.py +40 -0
  16. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/bad_build_check +494 -0
  17. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/install_deps.sh +37 -0
  18. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/install_go.sh +41 -0
  19. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/nyc_report_converter.py +80 -0
  20. local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/parse_options.py +58 -0
local-test-tika-delta-03/afc-tika/tika-parsers/tika-parsers-extended/tika-parser-scientific-package/src/test/resources/2.4.0-tesseract.txt ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ application/aaigrid class org.apache.tika.parser.gdal.GDALParser
2
+ application/aig class org.apache.tika.parser.gdal.GDALParser
3
+ application/applefile class org.apache.tika.parser.apple.AppleSingleFileParser
4
+ application/atom+xml class org.apache.tika.parser.feed.FeedParser
5
+ application/chm class org.apache.tika.parser.microsoft.chm.ChmParser
6
+ application/deflate64 class org.apache.tika.parser.pkg.CompressorParser
7
+ application/dif+xml class org.apache.tika.parser.dif.DIFParser
8
+ application/dted class org.apache.tika.parser.gdal.GDALParser
9
+ application/elas class org.apache.tika.parser.gdal.GDALParser
10
+ application/envi.hdr class org.apache.tika.parser.envi.EnviHeaderParser
11
+ application/epub+zip class org.apache.tika.parser.epub.EpubParser
12
+ application/fits class org.apache.tika.parser.gdal.GDALParser
13
+ application/gff class org.apache.tika.parser.gdal.GDALParser
14
+ application/grass-ascii-grid class org.apache.tika.parser.gdal.GDALParser
15
+ application/gzip class org.apache.tika.parser.pkg.CompressorParser
16
+ application/java-archive class org.apache.tika.parser.pkg.PackageParser
17
+ application/java-vm class org.apache.tika.parser.asm.ClassParser
18
+ application/jaxa-pal-sar class org.apache.tika.parser.gdal.GDALParser
19
+ application/jdem class org.apache.tika.parser.gdal.GDALParser
20
+ application/kate class org.gagravarr.tika.OggParser
21
+ application/leveller class org.apache.tika.parser.gdal.GDALParser
22
+ application/mbox class org.apache.tika.parser.mbox.MboxParser
23
+ application/mock+xml class org.apache.tika.parser.mock.MockParser
24
+ application/mp4 class org.apache.tika.parser.mp4.MP4Parser
25
+ application/msword class org.apache.tika.parser.microsoft.OfficeParser
26
+ application/ogg class org.gagravarr.tika.OggParser
27
+ application/onenote; format=one class org.apache.tika.parser.microsoft.onenote.OneNoteParser
28
+ application/pcisdk class org.apache.tika.parser.gdal.GDALParser
29
+ application/pdf class org.apache.tika.parser.pdf.PDFParser
30
+ application/pkcs7-mime class org.apache.tika.parser.crypto.Pkcs7Parser
31
+ application/pkcs7-signature class org.apache.tika.parser.crypto.Pkcs7Parser
32
+ application/rss+xml class org.apache.tika.parser.feed.FeedParser
33
+ application/rtf class org.apache.tika.parser.microsoft.rtf.RTFParser
34
+ application/sdts-raster class org.apache.tika.parser.gdal.GDALParser
35
+ application/sldworks class org.apache.tika.parser.microsoft.OfficeParser
36
+ application/terragen class org.apache.tika.parser.gdal.GDALParser
37
+ application/timestamped-data class org.apache.tika.parser.crypto.TSDParser
38
+ application/vnd.adobe.indesign-idml-package class org.apache.tika.parser.indesign.IDMLParser
39
+ application/vnd.apple.iwork class org.apache.tika.parser.iwork.IWorkPackageParser
40
+ application/vnd.apple.keynote class org.apache.tika.parser.iwork.IWorkPackageParser
41
+ application/vnd.apple.keynote.13 class org.apache.tika.parser.iwork.iwana.IWork13PackageParser
42
+ application/vnd.apple.keynote.18 class org.apache.tika.parser.iwork.iwana.IWork18PackageParser
43
+ application/vnd.apple.numbers class org.apache.tika.parser.iwork.IWorkPackageParser
44
+ application/vnd.apple.numbers.13 class org.apache.tika.parser.iwork.iwana.IWork13PackageParser
45
+ application/vnd.apple.numbers.18 class org.apache.tika.parser.iwork.iwana.IWork18PackageParser
46
+ application/vnd.apple.pages class org.apache.tika.parser.iwork.IWorkPackageParser
47
+ application/vnd.apple.pages.13 class org.apache.tika.parser.iwork.iwana.IWork13PackageParser
48
+ application/vnd.apple.pages.18 class org.apache.tika.parser.iwork.iwana.IWork18PackageParser
49
+ application/vnd.apple.unknown.13 class org.apache.tika.parser.iwork.iwana.IWork13PackageParser
50
+ application/vnd.mif class org.apache.tika.parser.mif.MIFParser
51
+ application/vnd.ms-excel class org.apache.tika.parser.microsoft.OfficeParser
52
+ application/vnd.ms-excel.addin.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
53
+ application/vnd.ms-excel.sheet.2 class org.apache.tika.parser.microsoft.OldExcelParser
54
+ application/vnd.ms-excel.sheet.3 class org.apache.tika.parser.microsoft.OldExcelParser
55
+ application/vnd.ms-excel.sheet.4 class org.apache.tika.parser.microsoft.OldExcelParser
56
+ application/vnd.ms-excel.sheet.binary.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
57
+ application/vnd.ms-excel.sheet.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
58
+ application/vnd.ms-excel.template.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
59
+ application/vnd.ms-excel.workspace.3 class org.apache.tika.parser.microsoft.OldExcelParser
60
+ application/vnd.ms-excel.workspace.4 class org.apache.tika.parser.microsoft.OldExcelParser
61
+ application/vnd.ms-htmlhelp class org.apache.tika.parser.microsoft.chm.ChmParser
62
+ application/vnd.ms-outlook class org.apache.tika.parser.microsoft.OfficeParser
63
+ application/vnd.ms-outlook-pst class org.apache.tika.parser.microsoft.pst.OutlookPSTParser
64
+ application/vnd.ms-powerpoint class org.apache.tika.parser.microsoft.OfficeParser
65
+ application/vnd.ms-powerpoint.addin.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
66
+ application/vnd.ms-powerpoint.presentation.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
67
+ application/vnd.ms-powerpoint.slide.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
68
+ application/vnd.ms-powerpoint.slideshow.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
69
+ application/vnd.ms-powerpoint.template.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
70
+ application/vnd.ms-project class org.apache.tika.parser.microsoft.OfficeParser
71
+ application/vnd.ms-spreadsheetml class org.apache.tika.parser.microsoft.xml.SpreadsheetMLParser
72
+ application/vnd.ms-tnef class org.apache.tika.parser.microsoft.TNEFParser
73
+ application/vnd.ms-visio.drawing class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
74
+ application/vnd.ms-visio.drawing.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
75
+ application/vnd.ms-visio.stencil class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
76
+ application/vnd.ms-visio.stencil.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
77
+ application/vnd.ms-visio.template class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
78
+ application/vnd.ms-visio.template.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
79
+ application/vnd.ms-word.document.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
80
+ application/vnd.ms-word.template.macroenabled.12 class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
81
+ application/vnd.ms-word2006ml class org.apache.tika.parser.microsoft.ooxml.xwpf.ml2006.Word2006MLParser
82
+ application/vnd.ms-wordml class org.apache.tika.parser.microsoft.xml.WordMLParser
83
+ application/vnd.ms-xpsdocument class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
84
+ application/vnd.oasis.opendocument.chart class org.apache.tika.parser.odf.OpenDocumentParser
85
+ application/vnd.oasis.opendocument.chart-template class org.apache.tika.parser.odf.OpenDocumentParser
86
+ application/vnd.oasis.opendocument.flat.presentation class org.apache.tika.parser.odf.FlatOpenDocumentParser
87
+ application/vnd.oasis.opendocument.flat.spreadsheet class org.apache.tika.parser.odf.FlatOpenDocumentParser
88
+ application/vnd.oasis.opendocument.flat.text class org.apache.tika.parser.odf.FlatOpenDocumentParser
89
+ application/vnd.oasis.opendocument.formula class org.apache.tika.parser.odf.OpenDocumentParser
90
+ application/vnd.oasis.opendocument.formula-template class org.apache.tika.parser.odf.OpenDocumentParser
91
+ application/vnd.oasis.opendocument.graphics class org.apache.tika.parser.odf.OpenDocumentParser
92
+ application/vnd.oasis.opendocument.graphics-template class org.apache.tika.parser.odf.OpenDocumentParser
93
+ application/vnd.oasis.opendocument.image class org.apache.tika.parser.odf.OpenDocumentParser
94
+ application/vnd.oasis.opendocument.image-template class org.apache.tika.parser.odf.OpenDocumentParser
95
+ application/vnd.oasis.opendocument.presentation class org.apache.tika.parser.odf.OpenDocumentParser
96
+ application/vnd.oasis.opendocument.presentation-template class org.apache.tika.parser.odf.OpenDocumentParser
97
+ application/vnd.oasis.opendocument.spreadsheet class org.apache.tika.parser.odf.OpenDocumentParser
98
+ application/vnd.oasis.opendocument.spreadsheet-template class org.apache.tika.parser.odf.OpenDocumentParser
99
+ application/vnd.oasis.opendocument.text class org.apache.tika.parser.odf.OpenDocumentParser
100
+ application/vnd.oasis.opendocument.text-master class org.apache.tika.parser.odf.OpenDocumentParser
101
+ application/vnd.oasis.opendocument.text-template class org.apache.tika.parser.odf.OpenDocumentParser
102
+ application/vnd.oasis.opendocument.text-web class org.apache.tika.parser.odf.OpenDocumentParser
103
+ application/vnd.oasis.opendocument.tika.flat.document class org.apache.tika.parser.odf.FlatOpenDocumentParser
104
+ application/vnd.openxmlformats-officedocument.presentationml.presentation class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
105
+ application/vnd.openxmlformats-officedocument.presentationml.slide class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
106
+ application/vnd.openxmlformats-officedocument.presentationml.slideshow class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
107
+ application/vnd.openxmlformats-officedocument.presentationml.template class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
108
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
109
+ application/vnd.openxmlformats-officedocument.spreadsheetml.template class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
110
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
111
+ application/vnd.openxmlformats-officedocument.wordprocessingml.template class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
112
+ application/vnd.sun.xml.writer class org.apache.tika.parser.odf.OpenDocumentParser
113
+ application/vnd.visio class org.apache.tika.parser.microsoft.OfficeParser
114
+ application/vnd.wap.xhtml+xml class org.apache.tika.parser.html.JSoupParser
115
+ application/vnd.wordperfect; version=5.0 class org.apache.tika.parser.wordperfect.WordPerfectParser
116
+ application/vnd.wordperfect; version=5.1 class org.apache.tika.parser.wordperfect.WordPerfectParser
117
+ application/vnd.wordperfect; version=6.x class org.apache.tika.parser.wordperfect.WordPerfectParser
118
+ application/vrt class org.apache.tika.parser.gdal.GDALParser
119
+ application/warc class org.apache.tika.parser.warc.WARCParser
120
+ application/x-7z-compressed class org.apache.tika.parser.pkg.PackageParser
121
+ application/x-ace2 class org.apache.tika.parser.gdal.GDALParser
122
+ application/x-archive class org.apache.tika.parser.pkg.PackageParser
123
+ application/x-arj class org.apache.tika.parser.pkg.PackageParser
124
+ application/x-asp class org.apache.tika.parser.html.JSoupParser
125
+ application/x-bag class org.apache.tika.parser.gdal.GDALParser
126
+ application/x-blx class org.apache.tika.parser.gdal.GDALParser
127
+ application/x-bplist class org.apache.tika.parser.apple.PListParser
128
+ application/x-bplist-itunes class org.apache.tika.parser.apple.PListParser
129
+ application/x-bplist-memgraph class org.apache.tika.parser.apple.PListParser
130
+ application/x-bplist-webarchive class org.apache.tika.parser.apple.PListParser
131
+ application/x-brotli class org.apache.tika.parser.pkg.CompressorParser
132
+ application/x-bt class org.apache.tika.parser.gdal.GDALParser
133
+ application/x-bzip class org.apache.tika.parser.pkg.CompressorParser
134
+ application/x-bzip2 class org.apache.tika.parser.pkg.CompressorParser
135
+ application/x-cappi class org.apache.tika.parser.gdal.GDALParser
136
+ application/x-chm class org.apache.tika.parser.microsoft.chm.ChmParser
137
+ application/x-coasp class org.apache.tika.parser.gdal.GDALParser
138
+ application/x-compress class org.apache.tika.parser.pkg.CompressorParser
139
+ application/x-coredump class org.apache.tika.parser.executable.ExecutableParser
140
+ application/x-cosar class org.apache.tika.parser.gdal.GDALParser
141
+ application/x-cpg class org.apache.tika.parser.gdal.GDALParser
142
+ application/x-cpio class org.apache.tika.parser.pkg.PackageParser
143
+ application/x-ctable2 class org.apache.tika.parser.gdal.GDALParser
144
+ application/x-ctg class org.apache.tika.parser.gdal.GDALParser
145
+ application/x-dbf class org.apache.tika.parser.dbf.DBFParser
146
+ application/x-dipex class org.apache.tika.parser.gdal.GDALParser
147
+ application/x-dods class org.apache.tika.parser.gdal.GDALParser
148
+ application/x-doq1 class org.apache.tika.parser.gdal.GDALParser
149
+ application/x-doq2 class org.apache.tika.parser.gdal.GDALParser
150
+ application/x-e00-grid class org.apache.tika.parser.gdal.GDALParser
151
+ application/x-ecrg-toc class org.apache.tika.parser.gdal.GDALParser
152
+ application/x-elf class org.apache.tika.parser.executable.ExecutableParser
153
+ application/x-envi class org.apache.tika.parser.gdal.GDALParser
154
+ application/x-envi-hdr class org.apache.tika.parser.gdal.GDALParser
155
+ application/x-epsilon class org.apache.tika.parser.gdal.GDALParser
156
+ application/x-ers class org.apache.tika.parser.gdal.GDALParser
157
+ application/x-executable class org.apache.tika.parser.executable.ExecutableParser
158
+ application/x-fast class org.apache.tika.parser.gdal.GDALParser
159
+ application/x-fictionbook+xml class org.apache.tika.parser.xml.FictionBookParser
160
+ application/x-font-adobe-metric class org.apache.tika.parser.font.AdobeFontMetricParser
161
+ application/x-font-ttf class org.apache.tika.parser.font.TrueTypeParser
162
+ application/x-generic-bin class org.apache.tika.parser.gdal.GDALParser
163
+ application/x-geo-pdf class org.apache.tika.parser.gdal.GDALParser
164
+ application/x-gmt class org.apache.tika.parser.gdal.GDALParser
165
+ application/x-grib class org.apache.tika.parser.gdal.GDALParser
166
+ application/x-grib2 class org.apache.tika.parser.grib.GribParser
167
+ application/x-gs7bg class org.apache.tika.parser.gdal.GDALParser
168
+ application/x-gsag class org.apache.tika.parser.gdal.GDALParser
169
+ application/x-gsbg class org.apache.tika.parser.gdal.GDALParser
170
+ application/x-gsc class org.apache.tika.parser.gdal.GDALParser
171
+ application/x-gtx class org.apache.tika.parser.gdal.GDALParser
172
+ application/x-gxf class org.apache.tika.parser.gdal.GDALParser
173
+ application/x-hdf class org.apache.tika.parser.hdf.HDFParser
174
+ application/x-http class org.apache.tika.parser.gdal.GDALParser
175
+ application/x-httpresponse class org.apache.tika.parser.http.HttpParser
176
+ application/x-hwp-v5 class org.apache.tika.parser.hwp.HwpV5Parser
177
+ application/x-ibooks+zip class org.apache.tika.parser.epub.EpubParser
178
+ application/x-ingr class org.apache.tika.parser.gdal.GDALParser
179
+ application/x-isatab class org.apache.tika.parser.isatab.ISArchiveParser
180
+ application/x-isis2 class org.apache.tika.parser.gdal.GDALParser
181
+ application/x-isis3 class org.apache.tika.parser.gdal.GDALParser
182
+ application/x-java-pack200 class org.apache.tika.parser.pkg.CompressorParser
183
+ application/x-kml class org.apache.tika.parser.gdal.GDALParser
184
+ application/x-kro class org.apache.tika.parser.gdal.GDALParser
185
+ application/x-l1b class org.apache.tika.parser.gdal.GDALParser
186
+ application/x-lan class org.apache.tika.parser.gdal.GDALParser
187
+ application/x-lcp class org.apache.tika.parser.gdal.GDALParser
188
+ application/x-los-las class org.apache.tika.parser.gdal.GDALParser
189
+ application/x-lz4 class org.apache.tika.parser.pkg.CompressorParser
190
+ application/x-lzma class org.apache.tika.parser.pkg.CompressorParser
191
+ application/x-maker class org.apache.tika.parser.mif.MIFParser
192
+ application/x-map class org.apache.tika.parser.gdal.GDALParser
193
+ application/x-matlab-data class org.apache.tika.parser.mat.MatParser
194
+ application/x-mbtiles class org.apache.tika.parser.gdal.GDALParser
195
+ application/x-midi class org.apache.tika.parser.audio.MidiParser
196
+ application/x-ms-owner class org.apache.tika.parser.microsoft.MSOwnerFileParser
197
+ application/x-msaccess class org.apache.tika.parser.microsoft.JackcessParser
198
+ application/x-msdownload class org.apache.tika.parser.executable.ExecutableParser
199
+ application/x-msgn class org.apache.tika.parser.gdal.GDALParser
200
+ application/x-mspublisher class org.apache.tika.parser.microsoft.OfficeParser
201
+ application/x-ndf class org.apache.tika.parser.gdal.GDALParser
202
+ application/x-netcdf class org.apache.tika.parser.netcdf.NetCDFParser
203
+ application/x-ngs-geoid class org.apache.tika.parser.gdal.GDALParser
204
+ application/x-ntv2 class org.apache.tika.parser.gdal.GDALParser
205
+ application/x-nwt-grc class org.apache.tika.parser.gdal.GDALParser
206
+ application/x-nwt-grd class org.apache.tika.parser.gdal.GDALParser
207
+ application/x-object class org.apache.tika.parser.executable.ExecutableParser
208
+ application/x-p-aux class org.apache.tika.parser.gdal.GDALParser
209
+ application/x-pcidsk class org.apache.tika.parser.gdal.GDALParser
210
+ application/x-pds class org.apache.tika.parser.gdal.GDALParser
211
+ application/x-plist class org.apache.tika.parser.apple.PListParser
212
+ application/x-pnm class org.apache.tika.parser.gdal.GDALParser
213
+ application/x-ppi class org.apache.tika.parser.gdal.GDALParser
214
+ application/x-prt class org.apache.tika.parser.prt.PRTParser
215
+ application/x-quattro-pro; version=9 class org.apache.tika.parser.wordperfect.QuattroProParser
216
+ application/x-r class org.apache.tika.parser.gdal.GDALParser
217
+ application/x-rar-compressed class org.apache.tika.parser.pkg.RarParser
218
+ application/x-rasterlite class org.apache.tika.parser.gdal.GDALParser
219
+ application/x-rik class org.apache.tika.parser.gdal.GDALParser
220
+ application/x-rmf class org.apache.tika.parser.gdal.GDALParser
221
+ application/x-rpf-toc class org.apache.tika.parser.gdal.GDALParser
222
+ application/x-rs2 class org.apache.tika.parser.gdal.GDALParser
223
+ application/x-rst class org.apache.tika.parser.gdal.GDALParser
224
+ application/x-sas-data class org.apache.tika.parser.sas.SAS7BDATParser
225
+ application/x-sdat class org.apache.tika.parser.gdal.GDALParser
226
+ application/x-sharedlib class org.apache.tika.parser.executable.ExecutableParser
227
+ application/x-snappy class org.apache.tika.parser.pkg.CompressorParser
228
+ application/x-snodas class org.apache.tika.parser.gdal.GDALParser
229
+ application/x-srtmhgt class org.apache.tika.parser.gdal.GDALParser
230
+ application/x-tar class org.apache.tika.parser.pkg.PackageParser
231
+ application/x-tika-msoffice class org.apache.tika.parser.microsoft.OfficeParser
232
+ application/x-tika-msoffice-embedded; format=ole10_native class org.apache.tika.parser.microsoft.OfficeParser
233
+ application/x-tika-msworks-spreadsheet class org.apache.tika.parser.microsoft.OfficeParser
234
+ application/x-tika-ole-drm-encrypted class org.apache.tika.parser.microsoft.OfficeParser
235
+ application/x-tika-ooxml-protected class org.apache.tika.parser.microsoft.OfficeParser
236
+ application/x-tika-unix-dump class org.apache.tika.parser.pkg.PackageParser
237
+ application/x-til class org.apache.tika.parser.gdal.GDALParser
238
+ application/x-tmx class org.apache.tika.parser.tmx.TMXParser
239
+ application/x-tnef class org.apache.tika.parser.microsoft.TNEFParser
240
+ application/x-tsx class org.apache.tika.parser.gdal.GDALParser
241
+ application/x-usgs-dem class org.apache.tika.parser.gdal.GDALParser
242
+ application/x-wacz class org.apache.tika.parser.wacz.WACZParser
243
+ application/x-wcs class org.apache.tika.parser.gdal.GDALParser
244
+ application/x-webp class org.apache.tika.parser.gdal.GDALParser
245
+ application/x-wms class org.apache.tika.parser.gdal.GDALParser
246
+ application/x-xliff+xml class org.apache.tika.parser.xliff.XLIFF12Parser
247
+ application/x-xliff+zip class org.apache.tika.parser.xliff.XLZParser
248
+ application/x-xyz class org.apache.tika.parser.gdal.GDALParser
249
+ application/x-xz class org.apache.tika.parser.pkg.CompressorParser
250
+ application/x-zmap class org.apache.tika.parser.gdal.GDALParser
251
+ application/xhtml+xml class org.apache.tika.parser.html.JSoupParser
252
+ application/xml class org.apache.tika.parser.xml.DcXMLParser
253
+ application/xpm class org.apache.tika.parser.gdal.GDALParser
254
+ application/zip class org.apache.tika.parser.pkg.PackageParser
255
+ application/zlib class org.apache.tika.parser.pkg.CompressorParser
256
+ audio/basic class org.apache.tika.parser.audio.AudioParser
257
+ audio/midi class org.apache.tika.parser.audio.MidiParser
258
+ audio/mp4 class org.apache.tika.parser.mp4.MP4Parser
259
+ audio/mpeg class org.apache.tika.parser.mp3.Mp3Parser
260
+ audio/ogg class org.gagravarr.tika.OggParser
261
+ audio/ogg; codecs=opus class org.gagravarr.tika.OpusParser
262
+ audio/ogg; codecs=speex class org.gagravarr.tika.SpeexParser
263
+ audio/opus class org.gagravarr.tika.OpusParser
264
+ audio/speex class org.gagravarr.tika.SpeexParser
265
+ audio/vnd.wave class org.apache.tika.parser.audio.AudioParser
266
+ audio/vorbis class org.gagravarr.tika.VorbisParser
267
+ audio/x-aiff class org.apache.tika.parser.audio.AudioParser
268
+ audio/x-flac class org.gagravarr.tika.FlacParser
269
+ audio/x-oggflac class org.gagravarr.tika.FlacParser
270
+ audio/x-oggpcm class org.gagravarr.tika.OggParser
271
+ image/adrg class org.apache.tika.parser.gdal.GDALParser
272
+ image/arg class org.apache.tika.parser.gdal.GDALParser
273
+ image/big-gif class org.apache.tika.parser.gdal.GDALParser
274
+ image/bmp class org.apache.tika.parser.image.ImageParser
275
+ image/bpg class org.apache.tika.parser.image.BPGParser
276
+ image/bsb class org.apache.tika.parser.gdal.GDALParser
277
+ image/ceos class org.apache.tika.parser.gdal.GDALParser
278
+ image/eir class org.apache.tika.parser.gdal.GDALParser
279
+ image/emf class org.apache.tika.parser.microsoft.EMFParser
280
+ image/envisat class org.apache.tika.parser.gdal.GDALParser
281
+ image/fit class org.apache.tika.parser.gdal.GDALParser
282
+ image/fits class org.apache.tika.parser.gdal.GDALParser
283
+ image/geotiff class org.apache.tika.parser.gdal.GDALParser
284
+ image/gif class org.apache.tika.parser.image.ImageParser
285
+ image/heic class org.apache.tika.parser.image.HeifParser
286
+ image/heic-sequence class org.apache.tika.parser.image.HeifParser
287
+ image/heif class org.apache.tika.parser.image.HeifParser
288
+ image/heif-sequence class org.apache.tika.parser.image.HeifParser
289
+ image/hfa class org.apache.tika.parser.gdal.GDALParser
290
+ image/icns class org.apache.tika.parser.image.ICNSParser
291
+ image/ida class org.apache.tika.parser.gdal.GDALParser
292
+ image/ilwis class org.apache.tika.parser.gdal.GDALParser
293
+ image/jp2 class org.apache.tika.parser.ocr.TesseractOCRParser
294
+ image/jpeg class org.apache.tika.parser.image.JpegParser
295
+ image/jpx class org.apache.tika.parser.ocr.TesseractOCRParser
296
+ image/jxl class org.apache.tika.parser.image.JXLParser
297
+ image/nitf class org.apache.tika.parser.gdal.GDALParser
298
+ image/ocr-bmp class org.apache.tika.parser.ocr.TesseractOCRParser
299
+ image/ocr-gif class org.apache.tika.parser.ocr.TesseractOCRParser
300
+ image/ocr-jp2 class org.apache.tika.parser.ocr.TesseractOCRParser
301
+ image/ocr-jpeg class org.apache.tika.parser.ocr.TesseractOCRParser
302
+ image/ocr-jpx class org.apache.tika.parser.ocr.TesseractOCRParser
303
+ image/ocr-png class org.apache.tika.parser.ocr.TesseractOCRParser
304
+ image/ocr-tiff class org.apache.tika.parser.ocr.TesseractOCRParser
305
+ image/ocr-x-portable-pixmap class org.apache.tika.parser.ocr.TesseractOCRParser
306
+ image/png class org.apache.tika.parser.image.ImageParser
307
+ image/raster class org.apache.tika.parser.gdal.GDALParser
308
+ image/sar-ceos class org.apache.tika.parser.gdal.GDALParser
309
+ image/sgi class org.apache.tika.parser.gdal.GDALParser
310
+ image/svg+xml class org.apache.tika.parser.xml.DcXMLParser
311
+ image/tiff class org.apache.tika.parser.image.TiffParser
312
+ image/vnd.adobe.photoshop class org.apache.tika.parser.image.PSDParser
313
+ image/vnd.dgn; version=8 class org.apache.tika.parser.dgn.DGN8Parser
314
+ image/vnd.dwg class org.apache.tika.parser.dwg.DWGParser
315
+ image/vnd.microsoft.icon class org.apache.tika.parser.image.ImageParser
316
+ image/vnd.wap.wbmp class org.apache.tika.parser.image.ImageParser
317
+ image/webp class org.apache.tika.parser.image.WebPParser
318
+ image/wmf class org.apache.tika.parser.microsoft.WMFParser
319
+ image/x-airsar class org.apache.tika.parser.gdal.GDALParser
320
+ image/x-bpg class org.apache.tika.parser.image.BPGParser
321
+ image/x-dimap class org.apache.tika.parser.gdal.GDALParser
322
+ image/x-fujibas class org.apache.tika.parser.gdal.GDALParser
323
+ image/x-hdf5-image class org.apache.tika.parser.gdal.GDALParser
324
+ image/x-jbig2 class org.apache.tika.parser.image.ImageParser
325
+ image/x-mff class org.apache.tika.parser.gdal.GDALParser
326
+ image/x-mff2 class org.apache.tika.parser.gdal.GDALParser
327
+ image/x-ozi class org.apache.tika.parser.gdal.GDALParser
328
+ image/x-pcraster class org.apache.tika.parser.gdal.GDALParser
329
+ image/x-portable-pixmap class org.apache.tika.parser.ocr.TesseractOCRParser
330
+ image/x-srp class org.apache.tika.parser.gdal.GDALParser
331
+ image/x-xcf class org.apache.tika.parser.image.ImageParser
332
+ message/rfc822 class org.apache.tika.parser.mail.RFC822Parser
333
+ model/vnd.dwfx+xps class org.apache.tika.parser.microsoft.ooxml.OOXMLParser
334
+ text/csv class org.apache.tika.parser.csv.TextAndCSVParser
335
+ text/html class org.apache.tika.parser.html.JSoupParser
336
+ text/iso19139+xml class org.apache.tika.parser.geoinfo.GeographicInformationParser
337
+ text/plain class org.apache.tika.parser.csv.TextAndCSVParser
338
+ text/tsv class org.apache.tika.parser.csv.TextAndCSVParser
339
+ text/vnd.iptc.anpa class org.apache.tika.parser.iptc.IptcAnpaParser
340
+ text/x-c++src class org.apache.tika.parser.code.SourceCodeParser
341
+ text/x-groovy class org.apache.tika.parser.code.SourceCodeParser
342
+ text/x-java-source class org.apache.tika.parser.code.SourceCodeParser
343
+ video/3gpp class org.apache.tika.parser.mp4.MP4Parser
344
+ video/3gpp2 class org.apache.tika.parser.mp4.MP4Parser
345
+ video/daala class org.gagravarr.tika.OggParser
346
+ video/mp4 class org.apache.tika.parser.mp4.MP4Parser
347
+ video/mpeg class org.apache.tika.parser.external.CompositeExternalParser
348
+ video/ogg class org.gagravarr.tika.OggParser
349
+ video/quicktime class org.apache.tika.parser.mp4.MP4Parser
350
+ video/theora class org.gagravarr.tika.TheoraParser
351
+ video/x-dirac class org.gagravarr.tika.OggParser
352
+ video/x-flv class org.apache.tika.parser.video.FLVParser
353
+ video/x-m4v class org.apache.tika.parser.mp4.MP4Parser
354
+ video/x-msvideo class org.apache.tika.parser.external.CompositeExternalParser
355
+ video/x-oggrgb class org.gagravarr.tika.OggParser
356
+ video/x-ogguvs class org.gagravarr.tika.OggParser
357
+ video/x-oggyuv class org.gagravarr.tika.OggParser
358
+ video/x-ogm class org.gagravarr.tika.OggParser
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder-python/Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2021 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ ################################################################################
16
+
17
+ ARG IMG_TAG=latest
18
+ FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
19
+
20
+ RUN install_python.sh
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/bash_parser.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import os
17
+ import sys
18
+
19
+ from glob import glob
20
+
21
+ import bashlex
22
+
23
+
24
+ def find_all_bash_scripts_in_src():
25
+ """Finds all bash scripts that exist in SRC/. This is used to idenfiy scripts
26
+ that may be needed for reading during the AST parsing. This is the case
27
+ when a given build script calls another build script, then we need to
28
+ read those."""
29
+ all_local_scripts = [
30
+ y for x in os.walk('/src/') for y in glob(os.path.join(x[0], '*.sh'))
31
+ ]
32
+ scripts_we_care_about = []
33
+ to_ignore = {'aflplusplus', 'honggfuzz', '/fuzztest', '/centipede'}
34
+ for s in all_local_scripts:
35
+ if any([x for x in to_ignore if x in s]):
36
+ continue
37
+ scripts_we_care_about.append(s)
38
+
39
+ print(scripts_we_care_about)
40
+ return scripts_we_care_about
41
+
42
+
43
+ def should_discard_command(ast_tree) -> bool:
44
+ """Returns True if the command shuold be avoided, otherwise False"""
45
+ try:
46
+ first_word = ast_tree.parts[0].word
47
+ except: # pylint: disable=bare-except
48
+ return False
49
+
50
+ if ('cmake' in first_word and
51
+ any('--build' in part.word for part in ast_tree.parts)):
52
+ return False
53
+
54
+ cmds_to_avoid_replaying = {
55
+ 'configure', 'autoheader', 'autoconf', 'autoreconf', 'cmake', 'autogen.sh'
56
+ }
57
+ if any([cmd for cmd in cmds_to_avoid_replaying if cmd in first_word]):
58
+ return True
59
+
60
+ # Avoid all "make clean" calls. We dont want to erase previously build
61
+ # files.
62
+ try:
63
+ second_word = ast_tree.parts[1].word
64
+ except: # pylint: disable=bare-except
65
+ return False
66
+ if 'make' in first_word and 'clean' in second_word:
67
+ return True
68
+
69
+ # No match was found to commands we dont want to build. There is no
70
+ # indication we shuold avoid.
71
+ return False
72
+
73
+
74
+ def is_local_redirection(ast_node, all_local_scripts):
75
+ """Return the list of scripts corresponding to the command, in case
76
+ the command is an execution of a local script."""
77
+ # print("Checking")
78
+
79
+ # Capture local script called with ./random/path/build.sh
80
+
81
+ if len(ast_node.parts) >= 2:
82
+ try:
83
+ ast_node.parts[0].word
84
+ except:
85
+ return []
86
+ if ast_node.parts[0].word == '.':
87
+ suffixes_matching = []
88
+ #print(ast_node.parts[1].word)
89
+ for bash_script in all_local_scripts:
90
+ #print("- %s"%(bash_script))
91
+ cmd_to_exec = ast_node.parts[1].word.replace('$SRC', 'src')
92
+ if bash_script.endswith(cmd_to_exec):
93
+ suffixes_matching.append(bash_script)
94
+ #print(suffixes_matching)
95
+ return suffixes_matching
96
+ # Capture a local script called with $SRC/random/path/build.sh
97
+ if len(ast_node.parts) >= 1:
98
+ if '$SRC' in ast_node.parts[0].word:
99
+ suffixes_matching = []
100
+ print(ast_node.parts[0].word)
101
+ for bash_script in all_local_scripts:
102
+ print("- %s" % (bash_script))
103
+ cmd_to_exec = ast_node.parts[0].word.replace('$SRC', 'src')
104
+ if bash_script.endswith(cmd_to_exec):
105
+ suffixes_matching.append(bash_script)
106
+ print(suffixes_matching)
107
+ return suffixes_matching
108
+
109
+ return []
110
+
111
+
112
+ def handle_ast_command(ast_node, all_scripts_in_fs, raw_script):
113
+ """Generate bash script string for command node"""
114
+ new_script = ''
115
+ if should_discard_command(ast_node):
116
+ return ''
117
+
118
+ matches = is_local_redirection(ast_node, all_scripts_in_fs)
119
+ if len(matches) == 1:
120
+ new_script += parse_script(matches[0], all_scripts_in_fs) + '\n'
121
+ return ''
122
+
123
+ # Extract the command from the script string
124
+ idx_start = ast_node.pos[0]
125
+ idx_end = ast_node.pos[1]
126
+ new_script += raw_script[idx_start:idx_end]
127
+ #new_script += '\n'
128
+
129
+ # If mkdir is used, then ensure that '-p' is provided, as
130
+ # otherwise we will run into failures. We don't have to worry
131
+ # about multiple uses of -p as `mkdir -p -p -p`` is valid.
132
+ new_script = new_script.replace('mkdir', 'mkdir -p')
133
+ return new_script
134
+
135
+
136
+ def handle_ast_list(ast_node, all_scripts_in_fs, raw_script):
137
+ """Handles bashlex AST list."""
138
+ new_script = ''
139
+ try_hard = 1
140
+
141
+ if not try_hard:
142
+ list_start = ast_node.pos[0]
143
+ list_end = ast_node.pos[1]
144
+ new_script += raw_script[list_start:list_end] # + '\n'
145
+ else:
146
+ # This is more refined logic. Ideally, this should work, but it's a bit
147
+ # more intricate to get right due to e.g. white-space between positions
148
+ # and more extensive parsing needed. We don't neccesarily need this
149
+ # level of success rate for what we're trying to achieve, so am disabling
150
+ # this for now.
151
+ for part in ast_node.parts:
152
+ if part.kind == 'list':
153
+ new_script += handle_ast_list(part, all_scripts_in_fs, raw_script)
154
+ elif part.kind == 'command':
155
+ new_script += handle_ast_command(part, all_scripts_in_fs, raw_script)
156
+ else:
157
+ idx_start = part.pos[0]
158
+ idx_end = part.pos[1]
159
+ new_script += raw_script[idx_start:idx_end]
160
+ new_script += ' '
161
+
162
+ # Make sure what was created is valid syntax, and otherwise return empty
163
+ try:
164
+ bashlex.parse(new_script)
165
+ except: # pylint: disable=bare-except
166
+ # Maybe return the original here instead of skipping?
167
+ return ''
168
+ return new_script
169
+
170
+
171
+ def handle_ast_compound(ast_node, all_scripts_in_fs, raw_script):
172
+ """Handles bashlex compound AST node."""
173
+ new_script = ''
174
+ list_start = ast_node.pos[0]
175
+ list_end = ast_node.pos[1]
176
+ new_script += raw_script[list_start:list_end] + '\n'
177
+ return new_script
178
+
179
+
180
+ def handle_node(ast_node, all_scripts_in_fs, build_script):
181
+ """Generates a bash script string for a given node"""
182
+ if ast_node.kind == 'command':
183
+ return handle_ast_command(ast_node, all_scripts_in_fs, build_script)
184
+ elif ast_node.kind == 'list':
185
+ return handle_ast_list(ast_node, all_scripts_in_fs, build_script)
186
+ elif ast_node.kind == 'compound':
187
+ print('todo: handle compound')
188
+ return handle_ast_compound(ast_node, all_scripts_in_fs, build_script)
189
+ elif ast_node.kind == 'pipeline':
190
+ # Not supported
191
+ return ''
192
+ else:
193
+ raise Exception(f'Missing node handling: {ast_node.kind}')
194
+
195
+
196
+ def parse_script(bash_script, all_scripts) -> str:
197
+ """Top-level bash script parser"""
198
+ new_script = ''
199
+ with open(bash_script, 'r', encoding='utf-8') as f:
200
+ build_script = f.read()
201
+ try:
202
+ parts = bashlex.parse(build_script)
203
+ except bashlex.errors.ParsingError:
204
+ return ''
205
+ for part in parts:
206
+ new_script += handle_node(part, all_scripts, build_script)
207
+ new_script += '\n'
208
+ print("-" * 45)
209
+ print(part.kind)
210
+ print(part.dump())
211
+
212
+ return new_script
213
+
214
+
215
+ def main():
216
+ """Main function"""
217
+ all_scripts = find_all_bash_scripts_in_src()
218
+ replay_bash_script = parse_script(sys.argv[1], all_scripts)
219
+
220
+ print("REPLAYABLE BASH SCRIPT")
221
+ print("#" * 60)
222
+ print(replay_bash_script)
223
+ print("#" * 60)
224
+
225
+ out_dir = os.getenv('OUT', '/out')
226
+ with open(f'{out_dir}/replay-build-script.sh', 'w', encoding='utf-8') as f:
227
+ f.write(replay_bash_script)
228
+
229
+ src_dir = os.getenv('SRC', '/src')
230
+ with open(f'{src_dir}/replay_build.sh', 'w', encoding='utf-8') as f:
231
+ f.write(replay_bash_script)
232
+
233
+
234
+ if __name__ == "__main__":
235
+ main()
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_fuzztests.sh ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ set -x
19
+
20
+ # In order to identify fuzztest test case "bazel query" is used to search
21
+ # the project. A search of the entire project is done with a default "...",
22
+ # however, some projects may fail to, or have very long processing time, if
23
+ # searching the entire project. Additionally, it may include fuzzers in
24
+ # dependencies, which should not be build as part of a given project.
25
+ # Tensorflow is an example project that will fail when the entire project is
26
+ # queried. FUZZTEST_TARGET_FOLDER makes it posible to specify the folder
27
+ # where fuzztest fuzzers should be search for. FUZZTEST_TARGET_FOLDER is passed
28
+ # to "bazel query" below.
29
+ if [[ ${FUZZTEST_TARGET_FOLDER:-"unset"} == "unset" ]];
30
+ then
31
+ export TARGET_FOLDER="..."
32
+ else
33
+ TARGET_FOLDER=${FUZZTEST_TARGET_FOLDER}
34
+ fi
35
+
36
+ BUILD_ARGS="--config=oss-fuzz --subcommands"
37
+ if [[ ${FUZZTEST_EXTRA_ARGS:-"unset"} != "unset" ]];
38
+ then
39
+ BUILD_ARGS="$BUILD_ARGS ${FUZZTEST_EXTRA_ARGS}"
40
+ fi
41
+
42
+ # Trigger setup_configs rule of fuzztest as it generates the necessary
43
+ # configuration file based on OSS-Fuzz environment variables.
44
+ bazel run @com_google_fuzztest//bazel:setup_configs >> /etc/bazel.bazelrc
45
+
46
+ # Bazel target names of the fuzz binaries.
47
+ FUZZ_TEST_BINARIES=$(bazel query "kind(\"cc_test\", rdeps(${TARGET_FOLDER}, @com_google_fuzztest//fuzztest:fuzztest_gtest_main))")
48
+
49
+ # Bazel output paths of the fuzz binaries.
50
+ FUZZ_TEST_BINARIES_OUT_PATHS=$(bazel cquery "kind(\"cc_test\", rdeps(${TARGET_FOLDER}, @com_google_fuzztest//fuzztest:fuzztest_gtest_main))" --output=files)
51
+
52
+ # Build the project and fuzz binaries
53
+ # Expose `FUZZTEST_EXTRA_TARGETS` environment variable, in the event a project
54
+ # includes non-FuzzTest fuzzers then this can be used to compile these in the
55
+ # same `bazel build` command as when building the FuzzTest fuzzers.
56
+ # This is to avoid having to call `bazel build` twice.
57
+ bazel build $BUILD_ARGS -- ${FUZZ_TEST_BINARIES[*]} ${FUZZTEST_EXTRA_TARGETS:-}
58
+
59
+ # Iterate the fuzz binaries and list each fuzz entrypoint in the binary. For
60
+ # each entrypoint create a wrapper script that calls into the binaries the
61
+ # given entrypoint as argument.
62
+ # The scripts will be named:
63
+ # {binary_name}@{fuzztest_entrypoint}
64
+ for fuzz_main_file in $FUZZ_TEST_BINARIES_OUT_PATHS; do
65
+ FUZZ_TESTS=$($fuzz_main_file --list_fuzz_tests)
66
+ cp ${fuzz_main_file} $OUT/
67
+ fuzz_basename=$(basename $fuzz_main_file)
68
+ chmod -x $OUT/$fuzz_basename
69
+ for fuzz_entrypoint in $FUZZ_TESTS; do
70
+ TARGET_FUZZER="${fuzz_basename}@$fuzz_entrypoint"
71
+
72
+ # Write executer script
73
+ echo "#!/bin/sh
74
+ # LLVMFuzzerTestOneInput for fuzzer detection.
75
+ this_dir=\$(dirname \"\$0\")
76
+ chmod +x \$this_dir/$fuzz_basename
77
+ \$this_dir/$fuzz_basename --fuzz=$fuzz_entrypoint -- \$@" > $OUT/$TARGET_FUZZER
78
+ chmod +x $OUT/$TARGET_FUZZER
79
+ done
80
+ done
81
+
82
+ # Synchronise coverage directory to bazel output artifacts. This is a
83
+ # best-effort basis in that it will include source code in common
84
+ # bazel output folders.
85
+ # For projects that store results in non-standard folders or want to
86
+ # manage what code to include in the coverage report more specifically,
87
+ # the FUZZTEST_DO_SYNC environment variable is made available. Projects
88
+ # can then implement a custom way of synchronising source code with the
89
+ # coverage build. Set FUZZTEST_DO_SYNC to something other than "yes" and
90
+ # no effort will be made to automatically synchronise the source code with
91
+ # the code coverage visualisation utility.
92
+ if [[ "$SANITIZER" = "coverage" && ${FUZZTEST_DO_SYNC:-"yes"} == "yes" ]]
93
+ then
94
+ # Synchronize bazel source files to coverage collection.
95
+ declare -r REMAP_PATH="${OUT}/proc/self/cwd"
96
+ mkdir -p "${REMAP_PATH}"
97
+
98
+ # Synchronize the folder bazel-BAZEL_OUT_PROJECT.
99
+ declare -r RSYNC_FILTER_ARGS=("--include" "*.h" "--include" "*.cc" "--include" \
100
+ "*.hpp" "--include" "*.cpp" "--include" "*.c" "--include" "*/" "--include" "*.inc" \
101
+ "--exclude" "*")
102
+
103
+ project_folders="$(find . -name 'bazel-*' -type l -printf '%P\n' | \
104
+ grep -v -x -F \
105
+ -e 'bazel-bin' \
106
+ -e 'bazel-testlogs')"
107
+ for link in $project_folders; do
108
+ if [[ -d "${PWD}"/$link/external ]]
109
+ then
110
+ rsync -avLk "${RSYNC_FILTER_ARGS[@]}" "${PWD}"/$link/external "${REMAP_PATH}"
111
+ fi
112
+ # k8-opt is a common path for storing bazel output artifacts, e.g. bazel-out/k8-opt.
113
+ # It's the output folder for default amd-64 builds, but projects may specify custom
114
+ # platform output directories, see: https://github.com/bazelbuild/bazel/issues/13818
115
+ # We support the default at the moment, and if a project needs custom synchronizing of
116
+ # output artifacts and code coverage we currently recommend using FUZZTEST_DO_SYNC.
117
+ if [[ -d "${PWD}"/$link/k8-opt ]]
118
+ then
119
+ rsync -avLk "${RSYNC_FILTER_ARGS[@]}" "${PWD}"/$link/k8-opt "${REMAP_PATH}"/$link
120
+ fi
121
+ done
122
+
123
+ # Delete symlinks and sync the current folder.
124
+ find . -type l -ls -delete
125
+ rsync -av ${PWD}/ "${REMAP_PATH}"
126
+ fi
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_go_fuzzer ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2020 Google Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ path=$1
19
+ function=$2
20
+ fuzzer=$3
21
+ tags="-tags gofuzz"
22
+ if [[ $# -eq 4 ]]; then
23
+ tags="-tags $4"
24
+ fi
25
+
26
+ # makes directory change temporary
27
+ (
28
+ cd $GOPATH/src/$path || true
29
+ # in the case we are in the right directory, with go.mod but no go.sum
30
+ go mod tidy || true
31
+ # project was downloaded with go get if go list fails
32
+ go list $tags $path || { cd $GOPATH/pkg/mod/ && cd `echo $path | cut -d/ -f1-3 | awk '{print $1"@*"}'`; } || cd -
33
+ # project does not have go.mod if go list fails again
34
+ go list $tags $path || { go mod init $path && go mod tidy ;}
35
+
36
+ if [[ $SANITIZER = *coverage* ]]; then
37
+ fuzzed_package=`go list $tags -f '{{.Name}}' $path`
38
+ abspath=`go list $tags -f {{.Dir}} $path`
39
+ cd $abspath
40
+ cp $GOPATH/ossfuzz_coverage_runner.go ./"${function,,}"_test.go
41
+ sed -i -e 's/FuzzFunction/'$function'/' ./"${function,,}"_test.go
42
+ sed -i -e 's/mypackagebeingfuzzed/'$fuzzed_package'/' ./"${function,,}"_test.go
43
+ sed -i -e 's/TestFuzzCorpus/Test'$function'Corpus/' ./"${function,,}"_test.go
44
+
45
+ # The repo is the module path/name, which is already created above in case it doesn't exist,
46
+ # but not always the same as the module path. This is necessary to handle SIV properly.
47
+ fuzzed_repo=$(go list $tags -f {{.Module}} "$path")
48
+ abspath_repo=`go list -m $tags -f {{.Dir}} $fuzzed_repo || go list $tags -f {{.Dir}} $fuzzed_repo`
49
+ # give equivalence to absolute paths in another file, as go test -cover uses golangish pkg.Dir
50
+ echo "s=$fuzzed_repo"="$abspath_repo"= > $OUT/$fuzzer.gocovpath
51
+ # Additional packages for which to get coverage.
52
+ pkgaddcov=""
53
+ # to prevent bash from failing about unbound variable
54
+ GO_COV_ADD_PKG_SET=${GO_COV_ADD_PKG:-}
55
+ if [[ -n "${GO_COV_ADD_PKG_SET}" ]]; then
56
+ pkgaddcov=","$GO_COV_ADD_PKG
57
+ abspath_repo=`go list -m $tags -f {{.Dir}} $GO_COV_ADD_PKG || go list $tags -f {{.Dir}} $GO_COV_ADD_PKG`
58
+ echo "s=^$GO_COV_ADD_PKG"="$abspath_repo"= >> $OUT/$fuzzer.gocovpath
59
+ fi
60
+ go test -run Test${function}Corpus -v $tags -coverpkg $fuzzed_repo/...$pkgaddcov -c -o $OUT/$fuzzer $path
61
+ else
62
+ # Compile and instrument all Go files relevant to this fuzz target.
63
+ echo "Running go-fuzz $tags -func $function -o $fuzzer.a $path"
64
+ go-fuzz $tags -func $function -o $fuzzer.a $path
65
+
66
+ # Link Go code ($fuzzer.a) with fuzzing engine to produce fuzz target binary.
67
+ $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
68
+ fi
69
+ )
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2016 Google Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ echo "Skipping compilation; using precompiled honggfuzz"
19
+
20
+ cp $SRC/honggfuzz/honggfuzz.a $LIB_FUZZING_ENGINE
21
+ cp $SRC/honggfuzz/honggfuzz $OUT/
22
+
23
+ # Set flags necessary for netdriver compilation.
24
+ export LIB_HFND="-Wl,-u,LIBHFNETDRIVER_module_netdriver -Wl,--start-group $SRC/honggfuzz/libhfnetdriver/libhfnetdriver.a $SRC/honggfuzz/libhfcommon/libhfcommon.a -Wl,--end-group"
25
+
26
+ export HFND_CXXFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION_CXX(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;extern "C" int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
27
+ export HFND_CFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
28
+
29
+ # Custom coverage flags, roughly in sync with:
30
+ # https://github.com/google/honggfuzz/blob/oss-fuzz/hfuzz_cc/hfuzz-cc.c
31
+ export COVERAGE_FLAGS="-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp"
32
+
33
+ echo " done."
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/debug_afl ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # Source this file for afl++ debug sessions.
19
+ apt-get update
20
+ apt-get install -y strace gdb vim joe psmisc
21
+
22
+ pushd $SRC/aflplusplus > /dev/null
23
+ git checkout dev
24
+ git pull
25
+ test -n "$1" && { git checkout "$1" ; git pull ; }
26
+ CFLAGS_SAVE="$CFLAGS"
27
+ CXXFLAGS_SAVE="$CXXFLAGS"
28
+ unset CFLAGS
29
+ unset CXXFLAGS
30
+ make
31
+ export CFLAGS="$CFLAGS_SAVE"
32
+ export CXXFLAGS="$CXXFLAGS_SAVE"
33
+ popd > /dev/null
34
+
35
+ export ASAN_OPTIONS="detect_leaks=0:symbolize=0:detect_odr_violation=0:abort_on_error=1"
36
+ export AFL_LLVM_LAF_ALL=1
37
+ export AFL_LLVM_CMPLOG=1
38
+ touch "$OUT/afl_cmplog.txt"
39
+ export AFL_LLVM_DICT2FILE=$OUT/afl++.dict
40
+ ulimit -c unlimited
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/detect_repo_test.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2019 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Test the functionality of the detect_repo module.
15
+ This will consist of the following functional test:
16
+ 1. Determine if an OSS-Fuzz projects main repo can be detected from example
17
+ commits.
18
+ 2. Determine if an OSS-Fuzz project main repo can be detected from a
19
+ repo name.
20
+ """
21
+ import os
22
+ import re
23
+ import sys
24
+ import tempfile
25
+ import unittest
26
+ from unittest import mock
27
+
28
+ import detect_repo
29
+
30
+ # Appending to path for access to repo_manager module.
31
+ # pylint: disable=wrong-import-position
32
+ sys.path.append(
33
+ os.path.dirname(os.path.dirname(os.path.dirname(
34
+ os.path.abspath(__file__)))))
35
+ import repo_manager
36
+ import test_repos
37
+ # pylint: enable=wrong-import-position
38
+
39
+
40
+ class TestCheckForRepoName(unittest.TestCase):
41
+ """Tests for check_for_repo_name."""
42
+
43
+ @mock.patch('os.path.exists', return_value=True)
44
+ @mock.patch('detect_repo.execute',
45
+ return_value=('https://github.com/google/syzkaller/', None))
46
+ def test_go_get_style_url(self, _, __):
47
+ """Tests that check_for_repo_name works on repos that were downloaded using
48
+ go get."""
49
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
50
+
51
+ @mock.patch('os.path.exists', return_value=True)
52
+ @mock.patch('detect_repo.execute',
53
+ return_value=('https://github.com/google/syzkaller', None))
54
+ def test_missing_git_and_slash_url(self, _, __):
55
+ """Tests that check_for_repo_name works on repos who's URLs do not end in
56
+ ".git" or "/"."""
57
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
58
+
59
+ @mock.patch('os.path.exists', return_value=True)
60
+ @mock.patch('detect_repo.execute',
61
+ return_value=('https://github.com/google/syzkaller.git', None))
62
+ def test_normal_style_repo_url(self, _, __):
63
+ """Tests that check_for_repo_name works on normally cloned repos."""
64
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
65
+
66
+
67
+ @unittest.skipIf(not os.getenv('INTEGRATION_TESTS'),
68
+ 'INTEGRATION_TESTS=1 not set')
69
+ class DetectRepoIntegrationTest(unittest.TestCase):
70
+ """Class to test the functionality of the detect_repo module."""
71
+
72
+ def test_infer_main_repo_from_commit(self):
73
+ """Tests that the main repo can be inferred based on an example commit."""
74
+
75
+ with tempfile.TemporaryDirectory() as tmp_dir:
76
+ # Construct example repo's to check for commits.
77
+ for test_repo in test_repos.TEST_REPOS:
78
+ repo_manager.clone_repo_and_get_manager(test_repo.git_url, tmp_dir)
79
+ self.check_with_repo(test_repo.git_url,
80
+ test_repo.git_repo_name,
81
+ tmp_dir,
82
+ commit=test_repo.old_commit)
83
+
84
+ def test_infer_main_repo_from_name(self):
85
+ """Tests that the main project repo can be inferred from a repo name."""
86
+ with tempfile.TemporaryDirectory() as tmp_dir:
87
+ for test_repo in test_repos.TEST_REPOS:
88
+ repo_manager.clone_repo_and_get_manager(test_repo.git_url, tmp_dir)
89
+ self.check_with_repo(test_repo.git_url, test_repo.git_repo_name,
90
+ tmp_dir)
91
+
92
+ def check_with_repo(self, repo_origin, repo_name, tmp_dir, commit=None):
93
+ """Checks the detect repo's main method for a specific set of inputs.
94
+
95
+ Args:
96
+ repo_origin: URL of the git repo.
97
+ repo_name: The name of the directory it is cloned to.
98
+ tmp_dir: The location of the directory of git repos to be searched.
99
+ commit: The commit that should be used to look up the repo.
100
+ """
101
+ command = ['python3', 'detect_repo.py', '--src_dir', tmp_dir]
102
+
103
+ if commit:
104
+ command += ['--example_commit', commit]
105
+ else:
106
+ command += ['--repo_name', repo_name]
107
+
108
+ out, _ = detect_repo.execute(command,
109
+ location=os.path.dirname(
110
+ os.path.realpath(__file__)))
111
+ match = re.search(r'\bDetected repo: ([^ ]+) ([^ ]+)', out.rstrip())
112
+ if match and match.group(1) and match.group(2):
113
+ self.assertEqual(match.group(1), repo_origin)
114
+ self.assertEqual(match.group(2), os.path.join(tmp_dir, repo_name))
115
+ else:
116
+ self.assertIsNone(repo_origin)
117
+ self.assertIsNone(repo_name)
118
+
119
+
120
+ if __name__ == '__main__':
121
+ unittest.main()
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_go.sh ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ cd /tmp
19
+
20
+ wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz
21
+ mkdir temp-go
22
+ tar -C temp-go/ -xzf go1.23.4.linux-amd64.tar.gz
23
+
24
+ mkdir /root/.go/
25
+ mv temp-go/go/* /root/.go/
26
+ rm -rf temp-go
27
+
28
+ echo 'Set "GOPATH=/root/go"'
29
+ echo 'Set "PATH=$PATH:/root/.go/bin:$GOPATH/bin"'
30
+
31
+ go install github.com/mdempsky/go114-fuzz-build@latest
32
+ ln -s $GOPATH/bin/go114-fuzz-build $GOPATH/bin/go-fuzz
33
+
34
+ # Build signal handler
35
+ if [ -f "$GOPATH/gosigfuzz/gosigfuzz.c" ]; then
36
+ clang -c $GOPATH/gosigfuzz/gosigfuzz.c -o $GOPATH/gosigfuzz/gosigfuzz.o
37
+ fi
38
+
39
+ cd /tmp
40
+ git clone https://github.com/AdamKorcz/go-118-fuzz-build
41
+ cd go-118-fuzz-build
42
+ go build
43
+ mv go-118-fuzz-build $GOPATH/bin/
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_rust.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=$RUSTUP_TOOLCHAIN --profile=minimal
19
+ cargo install cargo-fuzz --locked && rm -rf /rust/registry
20
+ # Needed to recompile rust std library for MSAN
21
+ rustup component add rust-src
22
+ cp -r /usr/local/lib/x86_64-unknown-linux-gnu/* /usr/local/lib/
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/install_swift.sh ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+
19
+ SWIFT_PACKAGES="wget \
20
+ binutils \
21
+ git \
22
+ gnupg2 \
23
+ libc6-dev \
24
+ libcurl4 \
25
+ libedit2 \
26
+ libgcc-9-dev \
27
+ libpython2.7 \
28
+ libsqlite3-0 \
29
+ libstdc++-9-dev \
30
+ libxml2 \
31
+ libz3-dev \
32
+ pkg-config \
33
+ tzdata \
34
+ zlib1g-dev"
35
+ SWIFT_SYMBOLIZER_PACKAGES="build-essential make cmake ninja-build git python3 g++-multilib binutils-dev zlib1g-dev"
36
+ apt-get update && apt install -y $SWIFT_PACKAGES && \
37
+ apt install -y $SWIFT_SYMBOLIZER_PACKAGES --no-install-recommends
38
+
39
+
40
+ wget -q https://download.swift.org/swift-5.10.1-release/ubuntu2004/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu20.04.tar.gz
41
+ tar xzf swift-5.10.1-RELEASE-ubuntu20.04.tar.gz
42
+ cp -r swift-5.10.1-RELEASE-ubuntu20.04/usr/* /usr/
43
+ rm -rf swift-5.10.1-RELEASE-ubuntu20.04.tar.gz swift-5.10.1-RELEASE-ubuntu20.04/
44
+ # TODO: Move to a seperate work dir
45
+ git clone https://github.com/llvm/llvm-project.git
46
+ cd llvm-project
47
+ git checkout 63bf228450b8403e0c5e828d276be47ffbcd00d0 # TODO: Keep in sync with base-clang.
48
+ git apply ../llvmsymbol.diff --verbose
49
+ cmake -G "Ninja" \
50
+ -DLIBCXX_ENABLE_SHARED=OFF \
51
+ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
52
+ -DLIBCXXABI_ENABLE_SHARED=OFF \
53
+ -DCMAKE_BUILD_TYPE=Release \
54
+ -DLLVM_TARGETS_TO_BUILD=X86 \
55
+ -DCMAKE_C_COMPILER=clang \
56
+ -DCMAKE_CXX_COMPILER=clang++ \
57
+ -DLLVM_BUILD_TESTS=OFF \
58
+ -DLLVM_INCLUDE_TESTS=OFF llvm
59
+ ninja -j$(nproc) llvm-symbolizer
60
+ cp bin/llvm-symbolizer /usr/local/bin/llvm-symbolizer-swift
61
+
62
+ cd $SRC
63
+ rm -rf llvm-project llvmsymbol.diff
64
+
65
+ # TODO: Cleanup packages
66
+ apt-get remove --purge -y wget zlib1g-dev
67
+ apt-get autoremove -y
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/ossfuzz_coverage_runner.go ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright 2020 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package mypackagebeingfuzzed
16
+
17
+ import (
18
+ "io/ioutil"
19
+ "os"
20
+ "runtime/pprof"
21
+ "testing"
22
+ )
23
+
24
+ func TestFuzzCorpus(t *testing.T) {
25
+ dir := os.Getenv("FUZZ_CORPUS_DIR")
26
+ if dir == "" {
27
+ t.Logf("No fuzzing corpus directory set")
28
+ return
29
+ }
30
+ infos, err := ioutil.ReadDir(dir)
31
+ if err != nil {
32
+ t.Logf("Not fuzzing corpus directory %s", err)
33
+ return
34
+ }
35
+ filename := ""
36
+ defer func() {
37
+ if r := recover(); r != nil {
38
+ t.Error("Fuzz panicked in "+filename, r)
39
+ }
40
+ }()
41
+ profname := os.Getenv("FUZZ_PROFILE_NAME")
42
+ if profname != "" {
43
+ f, err := os.Create(profname + ".cpu.prof")
44
+ if err != nil {
45
+ t.Logf("error creating profile file %s\n", err)
46
+ } else {
47
+ _ = pprof.StartCPUProfile(f)
48
+ }
49
+ }
50
+ for i := range infos {
51
+ filename = dir + infos[i].Name()
52
+ data, err := ioutil.ReadFile(filename)
53
+ if err != nil {
54
+ t.Error("Failed to read corpus file", err)
55
+ }
56
+ FuzzFunction(data)
57
+ }
58
+ if profname != "" {
59
+ pprof.StopCPUProfile()
60
+ f, err := os.Create(profname + ".heap.prof")
61
+ if err != nil {
62
+ t.Logf("error creating heap profile file %s\n", err)
63
+ }
64
+ if err = pprof.WriteHeapProfile(f); err != nil {
65
+ t.Logf("error writing heap profile file %s\n", err)
66
+ }
67
+ f.Close()
68
+ }
69
+ }
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/precompile_afl ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ echo "Precompiling AFLplusplus"
19
+
20
+ pushd $SRC/aflplusplus > /dev/null
21
+ make clean
22
+ # Unset CFLAGS and CXXFLAGS while building AFL since we don't want to slow it
23
+ # down with sanitizers.
24
+ SAVE_CXXFLAGS=$CXXFLAGS
25
+ SAVE_CFLAGS=$CFLAGS
26
+ unset CXXFLAGS
27
+ unset CFLAGS
28
+ export AFL_IGNORE_UNKNOWN_ENVS=1
29
+ make clean
30
+ AFL_NO_X86=1 PYTHON_INCLUDE=/ make
31
+ make -C utils/aflpp_driver
32
+
33
+ popd > /dev/null
34
+
35
+ echo "Done."
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/precompile_honggfuzz ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2019 Google Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ echo "Precompiling honggfuzz"
19
+ export BUILD_OSSFUZZ_STATIC=true
20
+
21
+ PACKAGES=(
22
+ libunwind8-dev
23
+ libblocksruntime-dev
24
+ liblzma-dev
25
+ libiberty-dev
26
+ zlib1g-dev
27
+ pkg-config)
28
+
29
+ apt-get update && apt-get install -y ${PACKAGES[@]}
30
+
31
+ pushd $SRC/honggfuzz > /dev/null
32
+ make clean
33
+ # These CFLAGs match honggfuzz's default, with the exception of -mtune to
34
+ # improve portability and `-D_HF_LINUX_NO_BFD` to remove assembly instructions
35
+ # from the filenames.
36
+ CC=clang CFLAGS="-O3 -funroll-loops -D_HF_LINUX_NO_BFD" make
37
+
38
+ # libhfuzz.a will be added by CC/CXX linker directly during linking,
39
+ # but it's defined here to satisfy the build infrastructure
40
+ ar rcs honggfuzz.a libhfuzz/*.o libhfcommon/*.o
41
+ popd > /dev/null
42
+
43
+ apt-get remove -y --purge ${PACKAGES[@]}
44
+ apt-get autoremove -y
45
+ echo "Done."
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-builder/write_labels.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2021 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Script for writing from project.yaml to .labels file."""
16
+
17
+ import os
18
+ import json
19
+ import sys
20
+
21
+
22
+ def main():
23
+ """Writes labels."""
24
+ if len(sys.argv) != 3:
25
+ print('Usage: write_labels.py labels_json out_dir', file=sys.stderr)
26
+ sys.exit(1)
27
+
28
+ labels_by_target = json.loads(sys.argv[1])
29
+ out = sys.argv[2]
30
+
31
+ for target_name, labels in labels_by_target.items():
32
+ # Skip over wildcard value applying to all fuzz targets
33
+ if target_name == '*':
34
+ continue
35
+ with open(os.path.join(out, target_name + '.labels'), 'w') as file_handle:
36
+ file_handle.write('\n'.join(labels))
37
+
38
+
39
+ if __name__ == '__main__':
40
+ main()
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/bad_build_check ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -u
2
+ # Copyright 2017 Google Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # A minimal number of runs to test fuzz target with a non-empty input.
19
+ MIN_NUMBER_OF_RUNS=4
20
+
21
+ # The "example" target has 73 with ASan, 65 with UBSan, and 6648 with MSan.
22
+ # Real world targets have greater values (arduinojson: 407, zlib: 664).
23
+ # Mercurial's bdiff_fuzzer has 116 PCs when built with ASan.
24
+ THRESHOLD_FOR_NUMBER_OF_EDGES=100
25
+
26
+ # A fuzz target is supposed to have at least two functions, such as
27
+ # LLVMFuzzerTestOneInput and an API that is being called from there.
28
+ THRESHOLD_FOR_NUMBER_OF_FUNCTIONS=2
29
+
30
+ # Threshold values for different sanitizers used by instrumentation checks.
31
+ ASAN_CALLS_THRESHOLD_FOR_ASAN_BUILD=1000
32
+ ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD=0
33
+
34
+ # The value below can definitely be higher (like 500-1000), but avoid being too
35
+ # agressive here while still evaluating the DFT-based fuzzing approach.
36
+ DFSAN_CALLS_THRESHOLD_FOR_DFSAN_BUILD=100
37
+ DFSAN_CALLS_THRESHOLD_FOR_NON_DFSAN_BUILD=0
38
+
39
+ MSAN_CALLS_THRESHOLD_FOR_MSAN_BUILD=1000
40
+ # Some engines (e.g. honggfuzz) may make a very small number of calls to msan
41
+ # for memory poisoning.
42
+ MSAN_CALLS_THRESHOLD_FOR_NON_MSAN_BUILD=3
43
+
44
+ # Usually, a non UBSan build (e.g. ASan) has 165 calls to UBSan runtime. The
45
+ # majority of targets built with UBSan have 200+ UBSan calls, but there are
46
+ # some very small targets that may have < 200 UBSan calls even in a UBSan build.
47
+ # Use the threshold value of 168 (slightly > 165) for UBSan build.
48
+ UBSAN_CALLS_THRESHOLD_FOR_UBSAN_BUILD=168
49
+
50
+ # It would be risky to use the threshold value close to 165 for non UBSan build,
51
+ # as UBSan runtime may change any time and thus we could have different number
52
+ # of calls to UBSan runtime even in ASan build. With that, we use the threshold
53
+ # value of 200 that would detect unnecessary UBSan instrumentation in the vast
54
+ # majority of targets, except of a handful very small ones, which would not be
55
+ # a big concern either way as the overhead for them would not be significant.
56
+ UBSAN_CALLS_THRESHOLD_FOR_NON_UBSAN_BUILD=200
57
+
58
+ # ASan builds on i386 generally have about 250 UBSan runtime calls.
59
+ if [[ $ARCHITECTURE == 'i386' ]]
60
+ then
61
+ UBSAN_CALLS_THRESHOLD_FOR_NON_UBSAN_BUILD=280
62
+ fi
63
+
64
+
65
+ # Verify that the given fuzz target is correctly built to run with a particular
66
+ # engine.
67
+ function check_engine {
68
+ local FUZZER=$1
69
+ local FUZZER_NAME=$(basename $FUZZER)
70
+ local FUZZER_OUTPUT="/tmp/$FUZZER_NAME.output"
71
+ local CHECK_FAILED=0
72
+
73
+ if [[ "$FUZZING_ENGINE" == libfuzzer ]]; then
74
+ # Store fuzz target's output into a temp file to be used for further checks.
75
+ $FUZZER -seed=1337 -runs=$MIN_NUMBER_OF_RUNS &>$FUZZER_OUTPUT
76
+ CHECK_FAILED=$(egrep "ERROR: no interesting inputs were found. Is the code instrumented" -c $FUZZER_OUTPUT)
77
+ if (( $CHECK_FAILED > 0 )); then
78
+ echo "BAD BUILD: $FUZZER does not seem to have coverage instrumentation."
79
+ cat $FUZZER_OUTPUT
80
+ # Bail out as the further check does not make any sense, there are 0 PCs.
81
+ return 1
82
+ fi
83
+
84
+ local NUMBER_OF_EDGES=$(grep -Po "INFO: Loaded [[:digit:]]+ module.*\(.*(counters|guards)\):[[:space:]]+\K[[:digit:]]+" $FUZZER_OUTPUT)
85
+
86
+ # If a fuzz target fails to start, grep won't find anything, so bail out early to let check_startup_crash deal with it.
87
+ [[ -z "$NUMBER_OF_EDGES" ]] && return
88
+
89
+ if (( $NUMBER_OF_EDGES < $THRESHOLD_FOR_NUMBER_OF_EDGES )); then
90
+ echo "BAD BUILD: $FUZZER seems to have only partial coverage instrumentation."
91
+ fi
92
+ elif [[ "$FUZZING_ENGINE" == afl ]]; then
93
+ AFL_FORKSRV_INIT_TMOUT=30000 AFL_NO_UI=1 SKIP_SEED_CORPUS=1 timeout --preserve-status -s INT 35s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT
94
+ CHECK_PASSED=$(egrep "All set and ready to roll" -c $FUZZER_OUTPUT)
95
+ if (( $CHECK_PASSED == 0 )); then
96
+ echo "BAD BUILD: fuzzing $FUZZER with afl-fuzz failed."
97
+ cat $FUZZER_OUTPUT
98
+ return 1
99
+ fi
100
+ elif [[ "$FUZZING_ENGINE" == honggfuzz ]]; then
101
+ SKIP_SEED_CORPUS=1 timeout --preserve-status -s INT 20s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT
102
+ CHECK_PASSED=$(egrep "^Sz:[0-9]+ Tm:[0-9]+" -c $FUZZER_OUTPUT)
103
+ if (( $CHECK_PASSED == 0 )); then
104
+ echo "BAD BUILD: fuzzing $FUZZER with honggfuzz failed."
105
+ cat $FUZZER_OUTPUT
106
+ return 1
107
+ fi
108
+ elif [[ "$FUZZING_ENGINE" == dataflow ]]; then
109
+ $FUZZER &> $FUZZER_OUTPUT
110
+ local NUMBER_OF_FUNCTIONS=$(grep -Po "INFO:\s+\K[[:digit:]]+(?=\s+instrumented function.*)" $FUZZER_OUTPUT)
111
+ [[ -z "$NUMBER_OF_FUNCTIONS" ]] && NUMBER_OF_FUNCTIONS=0
112
+ if (( $NUMBER_OF_FUNCTIONS < $THRESHOLD_FOR_NUMBER_OF_FUNCTIONS )); then
113
+ echo "BAD BUILD: $FUZZER does not seem to be properly built in 'dataflow' config."
114
+ cat $FUZZER_OUTPUT
115
+ return 1
116
+ fi
117
+ elif [[ "$FUZZING_ENGINE" == centipede \
118
+ && ("${HELPER:-}" == True || "$SANITIZER" == none ) ]]; then
119
+ # Performs run test on unsanitized binaries with auxiliary sanitized
120
+ # binaries if they are built with helper.py.
121
+ # Performs run test on unsanitized binaries without auxiliary sanitized
122
+ # binaries if they are from trial build and production build.
123
+ # TODO(Dongge): Support run test with sanitized binaries for trial and
124
+ # production build.
125
+ SKIP_SEED_CORPUS=1 timeout --preserve-status -s INT 20s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT
126
+ CHECK_PASSED=$(egrep "\[S0.0] begin-fuzz: ft: 0 corp: 0/0" -c $FUZZER_OUTPUT)
127
+ if (( $CHECK_PASSED == 0 )); then
128
+ echo "BAD BUILD: fuzzing $FUZZER with centipede failed."
129
+ cat $FUZZER_OUTPUT
130
+ return 1
131
+ fi
132
+ fi
133
+
134
+ return 0
135
+ }
136
+
137
+ # Verify that the given fuzz target has been built properly and works.
138
+ function check_startup_crash {
139
+ local FUZZER=$1
140
+ local FUZZER_NAME=$(basename $FUZZER)
141
+ local FUZZER_OUTPUT="/tmp/$FUZZER_NAME.output"
142
+ local CHECK_PASSED=0
143
+
144
+ if [[ "$FUZZING_ENGINE" = libfuzzer ]]; then
145
+ # Skip seed corpus as there is another explicit check that uses seed corpora.
146
+ SKIP_SEED_CORPUS=1 run_fuzzer $FUZZER_NAME -seed=1337 -runs=$MIN_NUMBER_OF_RUNS &>$FUZZER_OUTPUT
147
+ CHECK_PASSED=$(egrep "Done $MIN_NUMBER_OF_RUNS runs" -c $FUZZER_OUTPUT)
148
+ elif [[ "$FUZZING_ENGINE" = afl ]]; then
149
+ AFL_FORKSRV_INIT_TMOUT=30000 AFL_NO_UI=1 SKIP_SEED_CORPUS=1 timeout --preserve-status -s INT 35s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT
150
+ if [ $(egrep "target binary (crashed|terminated)" -c $FUZZER_OUTPUT) -eq 0 ]; then
151
+ CHECK_PASSED=1
152
+ fi
153
+ elif [[ "$FUZZING_ENGINE" = dataflow ]]; then
154
+ # TODO(https://github.com/google/oss-fuzz/issues/1632): add check for
155
+ # binaries compiled with dataflow engine when the interface becomes stable.
156
+ CHECK_PASSED=1
157
+ else
158
+ # TODO: add checks for another fuzzing engines if possible.
159
+ CHECK_PASSED=1
160
+ fi
161
+
162
+ if [ "$CHECK_PASSED" -eq "0" ]; then
163
+ echo "BAD BUILD: $FUZZER seems to have either startup crash or exit:"
164
+ cat $FUZZER_OUTPUT
165
+ return 1
166
+ fi
167
+
168
+ return 0
169
+ }
170
+
171
+ # Mixed sanitizers check for ASan build.
172
+ function check_asan_build {
173
+ local FUZZER=$1
174
+ local ASAN_CALLS=$2
175
+ local DFSAN_CALLS=$3
176
+ local MSAN_CALLS=$4
177
+ local UBSAN_CALLS=$5
178
+
179
+ # Perform all the checks for more detailed error message.
180
+ if (( $ASAN_CALLS < $ASAN_CALLS_THRESHOLD_FOR_ASAN_BUILD )); then
181
+ echo "BAD BUILD: $FUZZER does not seem to be compiled with ASan."
182
+ return 1
183
+ fi
184
+
185
+ if (( $DFSAN_CALLS > $DFSAN_CALLS_THRESHOLD_FOR_NON_DFSAN_BUILD )); then
186
+ echo "BAD BUILD: ASan build of $FUZZER seems to be compiled with DFSan."
187
+ return 1
188
+ fi
189
+
190
+ if (( $MSAN_CALLS > $MSAN_CALLS_THRESHOLD_FOR_NON_MSAN_BUILD )); then
191
+ echo "BAD BUILD: ASan build of $FUZZER seems to be compiled with MSan."
192
+ return 1
193
+ fi
194
+
195
+ if (( $UBSAN_CALLS > $UBSAN_CALLS_THRESHOLD_FOR_NON_UBSAN_BUILD )); then
196
+ echo "BAD BUILD: ASan build of $FUZZER seems to be compiled with UBSan."
197
+ return 1
198
+ fi
199
+
200
+ return 0
201
+ }
202
+
203
+ # Mixed sanitizers check for DFSan build.
204
+ function check_dfsan_build {
205
+ local FUZZER=$1
206
+ local ASAN_CALLS=$2
207
+ local DFSAN_CALLS=$3
208
+ local MSAN_CALLS=$4
209
+ local UBSAN_CALLS=$5
210
+
211
+ # Perform all the checks for more detailed error message.
212
+ if (( $ASAN_CALLS > $ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD )); then
213
+ echo "BAD BUILD: DFSan build of $FUZZER seems to be compiled with ASan."
214
+ return 1
215
+ fi
216
+
217
+ if (( $DFSAN_CALLS < $DFSAN_CALLS_THRESHOLD_FOR_DFSAN_BUILD )); then
218
+ echo "BAD BUILD: $FUZZER does not seem to be compiled with DFSan."
219
+ return 1
220
+ fi
221
+
222
+ if (( $MSAN_CALLS > $MSAN_CALLS_THRESHOLD_FOR_NON_MSAN_BUILD )); then
223
+ echo "BAD BUILD: ASan build of $FUZZER seems to be compiled with MSan."
224
+ return 1
225
+ fi
226
+
227
+ if (( $UBSAN_CALLS > $UBSAN_CALLS_THRESHOLD_FOR_NON_UBSAN_BUILD )); then
228
+ echo "BAD BUILD: ASan build of $FUZZER seems to be compiled with UBSan."
229
+ return 1
230
+ fi
231
+
232
+ return 0
233
+ }
234
+
235
+
236
+ # Mixed sanitizers check for MSan build.
237
+ function check_msan_build {
238
+ local FUZZER=$1
239
+ local ASAN_CALLS=$2
240
+ local DFSAN_CALLS=$3
241
+ local MSAN_CALLS=$4
242
+ local UBSAN_CALLS=$5
243
+
244
+ # Perform all the checks for more detailed error message.
245
+ if (( $ASAN_CALLS > $ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD )); then
246
+ echo "BAD BUILD: MSan build of $FUZZER seems to be compiled with ASan."
247
+ return 1
248
+ fi
249
+
250
+ if (( $DFSAN_CALLS > $DFSAN_CALLS_THRESHOLD_FOR_NON_DFSAN_BUILD )); then
251
+ echo "BAD BUILD: MSan build of $FUZZER seems to be compiled with DFSan."
252
+ return 1
253
+ fi
254
+
255
+ if (( $MSAN_CALLS < $MSAN_CALLS_THRESHOLD_FOR_MSAN_BUILD )); then
256
+ echo "BAD BUILD: $FUZZER does not seem to be compiled with MSan."
257
+ return 1
258
+ fi
259
+
260
+ if (( $UBSAN_CALLS > $UBSAN_CALLS_THRESHOLD_FOR_NON_UBSAN_BUILD )); then
261
+ echo "BAD BUILD: MSan build of $FUZZER seems to be compiled with UBSan."
262
+ return 1
263
+ fi
264
+
265
+ return 0
266
+ }
267
+
268
+ # Mixed sanitizers check for UBSan build.
269
+ function check_ubsan_build {
270
+ local FUZZER=$1
271
+ local ASAN_CALLS=$2
272
+ local DFSAN_CALLS=$3
273
+ local MSAN_CALLS=$4
274
+ local UBSAN_CALLS=$5
275
+
276
+ if [[ "$FUZZING_ENGINE" != libfuzzer ]]; then
277
+ # Ignore UBSan checks for fuzzing engines other than libFuzzer because:
278
+ # A) we (probably) are not going to use those with UBSan
279
+ # B) such builds show indistinguishable number of calls to UBSan
280
+ return 0
281
+ fi
282
+
283
+ # Perform all the checks for more detailed error message.
284
+ if (( $ASAN_CALLS > $ASAN_CALLS_THRESHOLD_FOR_NON_ASAN_BUILD )); then
285
+ echo "BAD BUILD: UBSan build of $FUZZER seems to be compiled with ASan."
286
+ return 1
287
+ fi
288
+
289
+ if (( $DFSAN_CALLS > $DFSAN_CALLS_THRESHOLD_FOR_NON_DFSAN_BUILD )); then
290
+ echo "BAD BUILD: UBSan build of $FUZZER seems to be compiled with DFSan."
291
+ return 1
292
+ fi
293
+
294
+ if (( $MSAN_CALLS > $MSAN_CALLS_THRESHOLD_FOR_NON_MSAN_BUILD )); then
295
+ echo "BAD BUILD: UBSan build of $FUZZER seems to be compiled with MSan."
296
+ return 1
297
+ fi
298
+
299
+ if (( $UBSAN_CALLS < $UBSAN_CALLS_THRESHOLD_FOR_UBSAN_BUILD )); then
300
+ echo "BAD BUILD: $FUZZER does not seem to be compiled with UBSan."
301
+ return 1
302
+ fi
303
+ }
304
+
305
+ # Verify that the given fuzz target is compiled with correct sanitizer.
306
+ function check_mixed_sanitizers {
307
+ local FUZZER=$1
308
+ local result=0
309
+ local CALL_INSN=
310
+
311
+ if [ "${FUZZING_LANGUAGE:-}" = "jvm" ]; then
312
+ # Sanitizer runtime is linked into the Jazzer driver, so this check does not
313
+ # apply.
314
+ return 0
315
+ fi
316
+
317
+ if [ "${FUZZING_LANGUAGE:-}" = "javascript" ]; then
318
+ # Jazzer.js currently does not support using sanitizers with native Node.js addons.
319
+ # This is not relevant anyways since supporting this will be done by preloading
320
+ # the sanitizers in the wrapper script starting Jazzer.js.
321
+ return 0
322
+ fi
323
+
324
+ if [ "${FUZZING_LANGUAGE:-}" = "python" ]; then
325
+ # Sanitizer runtime is loaded via LD_PRELOAD, so this check does not apply.
326
+ return 0
327
+ fi
328
+
329
+ # For fuzztest fuzzers point to the binary instead of launcher script.
330
+ if [[ $FUZZER == *"@"* ]]; then
331
+ FUZZER=(${FUZZER//@/ }[0])
332
+ fi
333
+
334
+ CALL_INSN=
335
+ if [[ $ARCHITECTURE == "x86_64" ]]
336
+ then
337
+ CALL_INSN="callq?\s+[0-9a-f]+\s+<"
338
+ elif [[ $ARCHITECTURE == "i386" ]]
339
+ then
340
+ CALL_INSN="call\s+[0-9a-f]+\s+<"
341
+ elif [[ $ARCHITECTURE == "aarch64" ]]
342
+ then
343
+ CALL_INSN="bl\s+[0-9a-f]+\s+<"
344
+ else
345
+ echo "UNSUPPORTED ARCHITECTURE"
346
+ exit 1
347
+ fi
348
+ local ASAN_CALLS=$(objdump -dC $FUZZER | egrep "${CALL_INSN}__asan" -c)
349
+ local DFSAN_CALLS=$(objdump -dC $FUZZER | egrep "${CALL_INSN}__dfsan" -c)
350
+ local MSAN_CALLS=$(objdump -dC $FUZZER | egrep "${CALL_INSN}__msan" -c)
351
+ local UBSAN_CALLS=$(objdump -dC $FUZZER | egrep "${CALL_INSN}__ubsan" -c)
352
+
353
+
354
+ if [[ "$SANITIZER" = address ]]; then
355
+ check_asan_build $FUZZER $ASAN_CALLS $DFSAN_CALLS $MSAN_CALLS $UBSAN_CALLS
356
+ result=$?
357
+ elif [[ "$SANITIZER" = dataflow ]]; then
358
+ check_dfsan_build $FUZZER $ASAN_CALLS $DFSAN_CALLS $MSAN_CALLS $UBSAN_CALLS
359
+ result=$?
360
+ elif [[ "$SANITIZER" = memory ]]; then
361
+ check_msan_build $FUZZER $ASAN_CALLS $DFSAN_CALLS $MSAN_CALLS $UBSAN_CALLS
362
+ result=$?
363
+ elif [[ "$SANITIZER" = undefined ]]; then
364
+ check_ubsan_build $FUZZER $ASAN_CALLS $DFSAN_CALLS $MSAN_CALLS $UBSAN_CALLS
365
+ result=$?
366
+ elif [[ "$SANITIZER" = thread ]]; then
367
+ # TODO(metzman): Implement this.
368
+ result=0
369
+ fi
370
+
371
+ return $result
372
+ }
373
+
374
+ # Verify that the given fuzz target doesn't crash on the seed corpus.
375
+ function check_seed_corpus {
376
+ local FUZZER=$1
377
+ local FUZZER_NAME="$(basename $FUZZER)"
378
+ local FUZZER_OUTPUT="/tmp/$FUZZER_NAME.output"
379
+
380
+ if [[ "$FUZZING_ENGINE" != libfuzzer ]]; then
381
+ return 0
382
+ fi
383
+
384
+ # Set up common fuzzing arguments, otherwise "run_fuzzer" errors out.
385
+ if [ -z "$FUZZER_ARGS" ]; then
386
+ export FUZZER_ARGS="-rss_limit_mb=2560 -timeout=25"
387
+ fi
388
+
389
+ bash -c "run_fuzzer $FUZZER_NAME -runs=0" &> $FUZZER_OUTPUT
390
+
391
+ # Don't output anything if fuzz target hasn't crashed.
392
+ if [ $? -ne 0 ]; then
393
+ echo "BAD BUILD: $FUZZER has a crashing input in its seed corpus:"
394
+ cat $FUZZER_OUTPUT
395
+ return 1
396
+ fi
397
+
398
+ return 0
399
+ }
400
+
401
+ function check_architecture {
402
+ local FUZZER=$1
403
+ local FUZZER_NAME=$(basename $FUZZER)
404
+
405
+ if [ "${FUZZING_LANGUAGE:-}" = "jvm" ]; then
406
+ # The native dependencies of a JVM project are not packaged, but loaded
407
+ # dynamically at runtime and thus cannot be checked here.
408
+ return 0;
409
+ fi
410
+
411
+ if [ "${FUZZING_LANGUAGE:-}" = "javascript" ]; then
412
+ # Jazzer.js fuzzers are wrapper scripts that start the fuzz target with
413
+ # the Jazzer.js CLI.
414
+ return 0;
415
+ fi
416
+
417
+ if [ "${FUZZING_LANGUAGE:-}" = "python" ]; then
418
+ FUZZER=${FUZZER}.pkg
419
+ fi
420
+
421
+ # For fuzztest fuzzers point to the binary instead of launcher script.
422
+ if [[ $FUZZER == *"@"* ]]; then
423
+ FUZZER=(${FUZZER//@/ }[0])
424
+ fi
425
+
426
+ FILE_OUTPUT=$(file $FUZZER)
427
+ if [[ $ARCHITECTURE == "x86_64" ]]
428
+ then
429
+ echo $FILE_OUTPUT | grep "x86-64" > /dev/null
430
+ elif [[ $ARCHITECTURE == "i386" ]]
431
+ then
432
+ echo $FILE_OUTPUT | grep "80386" > /dev/null
433
+ elif [[ $ARCHITECTURE == "aarch64" ]]
434
+ then
435
+ echo $FILE_OUTPUT | grep "aarch64" > /dev/null
436
+ else
437
+ echo "UNSUPPORTED ARCHITECTURE"
438
+ return 1
439
+ fi
440
+ result=$?
441
+ if [[ $result != 0 ]]
442
+ then
443
+ echo "BAD BUILD $FUZZER is not built for architecture: $ARCHITECTURE"
444
+ echo "file command output: $FILE_OUTPUT"
445
+ echo "check_mixed_sanitizers test will fail."
446
+ fi
447
+ return $result
448
+ }
449
+
450
+ function main {
451
+ local FUZZER=$1
452
+ local AUXILIARY_FUZZER=${2:-}
453
+ local checks_failed=0
454
+ local result=0
455
+
456
+ export RUN_FUZZER_MODE="batch"
457
+ check_engine $FUZZER
458
+ result=$?
459
+ checks_failed=$(( $checks_failed + $result ))
460
+
461
+ check_architecture $FUZZER
462
+ result=$?
463
+ checks_failed=$(( $checks_failed + $result ))
464
+
465
+ if [[ "$FUZZING_ENGINE" == centipede \
466
+ && "$SANITIZER" != none && "${HELPER:-}" == True ]]; then
467
+ check_mixed_sanitizers $AUXILIARY_FUZZER
468
+ else
469
+ check_mixed_sanitizers $FUZZER
470
+ fi
471
+ result=$?
472
+ checks_failed=$(( $checks_failed + $result ))
473
+
474
+ check_startup_crash $FUZZER
475
+ result=$?
476
+ checks_failed=$(( $checks_failed + $result ))
477
+
478
+ # TODO: re-enable after introducing bug auto-filing for bad builds.
479
+ # check_seed_corpus $FUZZER
480
+ return $checks_failed
481
+ }
482
+
483
+
484
+ if [ $# -ne 1 -a $# -ne 2 ]; then
485
+ echo "Usage: $0 <fuzz_target_binary> [<auxiliary_binary>]"
486
+ exit 1
487
+ fi
488
+
489
+ # Fuzz target path.
490
+ FUZZER=$1
491
+ AUXILIARY_FUZZER=${2:-}
492
+
493
+ main $FUZZER $AUXILIARY_FUZZER
494
+ exit $?
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/install_deps.sh ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # Install dependencies in a platform-aware way.
19
+
20
+ apt-get update && apt-get install -y \
21
+ binutils \
22
+ file \
23
+ ca-certificates \
24
+ fonts-dejavu \
25
+ git \
26
+ libcap2 \
27
+ rsync \
28
+ unzip \
29
+ wget \
30
+ zip --no-install-recommends
31
+
32
+ case $(uname -m) in
33
+ x86_64)
34
+ # We only need to worry about i386 if we are on x86_64.
35
+ apt-get install -y lib32gcc1 libc6-i386
36
+ ;;
37
+ esac
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/install_go.sh ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # Install go on x86_64, don't do anything on ARM.
19
+
20
+ case $(uname -m) in
21
+ x86_64)
22
+ # Download and install Go 1.19.
23
+ wget -q https://storage.googleapis.com/golang/getgo/installer_linux -O $SRC/installer_linux
24
+ chmod +x $SRC/installer_linux
25
+ SHELL="bash" $SRC/installer_linux -version 1.19
26
+ rm $SRC/installer_linux
27
+ # Set up Golang coverage modules.
28
+ printf $(find . -name gocoverage)
29
+ cd $GOPATH/gocoverage && /root/.go/bin/go install ./...
30
+ cd convertcorpus && /root/.go/bin/go install .
31
+ cd /root/.go/src/cmd/cover && /root/.go/bin/go build && mv cover $GOPATH/bin/gotoolcover
32
+ ;;
33
+ aarch64)
34
+ # Don't install go because installer is not provided.
35
+ echo "Not installing go: aarch64."
36
+ ;;
37
+ *)
38
+ echo "Error: unsupported architecture: $(uname -m)"
39
+ exit 1
40
+ ;;
41
+ esac
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/nyc_report_converter.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2023 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+ """Helper script for creating a llvm-cov style JSON summary from a nyc
18
+ JSON summary."""
19
+ import json
20
+ import sys
21
+
22
+
23
+ def convert(nyc_json_summary):
24
+ """Turns a nyc JSON report into a llvm-cov JSON summary."""
25
+ summary = {
26
+ 'type':
27
+ 'oss-fuzz.javascript.coverage.json.export',
28
+ 'version':
29
+ '1.0.0',
30
+ 'data': [{
31
+ 'totals':
32
+ file_summary(nyc_json_summary['total']),
33
+ 'files': [{
34
+ 'filename': src_file,
35
+ 'summary': file_summary(nyc_json_summary[src_file])
36
+ } for src_file in nyc_json_summary if src_file != 'total'],
37
+ }],
38
+ }
39
+
40
+ return json.dumps(summary)
41
+
42
+
43
+ def file_summary(nyc_file_summary):
44
+ """Returns a summary for a given file in the nyc JSON summary report."""
45
+ return {
46
+ 'functions': element_summary(nyc_file_summary['functions']),
47
+ 'lines': element_summary(nyc_file_summary['lines']),
48
+ 'regions': element_summary(nyc_file_summary['branches'])
49
+ }
50
+
51
+
52
+ def element_summary(element):
53
+ """Returns a summary of a coverage element in the nyc JSON summary
54
+ of the file"""
55
+ return {
56
+ 'count': element['total'],
57
+ 'covered': element['covered'],
58
+ 'notcovered': element['total'] - element['covered'] - element['skipped'],
59
+ 'percent': element['pct'] if element['pct'] != 'Unknown' else 0
60
+ }
61
+
62
+
63
+ def main():
64
+ """Produces a llvm-cov style JSON summary from a nyc JSON summary."""
65
+ if len(sys.argv) != 3:
66
+ sys.stderr.write('Usage: %s <path_to_nyc_json_summary> <out_path_json>\n' %
67
+ sys.argv[0])
68
+ return 1
69
+
70
+ with open(sys.argv[1], 'r') as nyc_json_summary_file:
71
+ nyc_json_summary = json.load(nyc_json_summary_file)
72
+ json_summary = convert(nyc_json_summary)
73
+ with open(sys.argv[2], 'w') as json_output_file:
74
+ json_output_file.write(json_summary)
75
+
76
+ return 0
77
+
78
+
79
+ if __name__ == '__main__':
80
+ sys.exit(main())
local-test-tika-delta-03/fuzz-tooling/infra/base-images/base-runner/parse_options.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2020 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+ """Helper script for parsing custom fuzzing options."""
18
+ import configparser
19
+ import sys
20
+
21
+
22
+ def parse_options(options_file_path, options_section):
23
+ """Parses the given file and returns options from the given section."""
24
+ parser = configparser.ConfigParser()
25
+ parser.read(options_file_path)
26
+
27
+ if not parser.has_section(options_section):
28
+ return None
29
+
30
+ options = parser[options_section]
31
+
32
+ if options_section == 'libfuzzer':
33
+ options_string = ' '.join(
34
+ '-%s=%s' % (key, value) for key, value in options.items())
35
+ else:
36
+ # Sanitizer options.
37
+ options_string = ':'.join(
38
+ '%s=%s' % (key, value) for key, value in options.items())
39
+
40
+ return options_string
41
+
42
+
43
+ def main():
44
+ """Processes the arguments and prints the options in the correct format."""
45
+ if len(sys.argv) < 3:
46
+ sys.stderr.write('Usage: %s <path_to_options_file> <options_section>\n' %
47
+ sys.argv[0])
48
+ return 1
49
+
50
+ options = parse_options(sys.argv[1], sys.argv[2])
51
+ if options is not None:
52
+ print(options)
53
+
54
+ return 0
55
+
56
+
57
+ if __name__ == "__main__":
58
+ sys.exit(main())