Kitxuuu commited on
Commit
22a9e88
·
verified ·
1 Parent(s): 5fffcc2

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/_sass/color_schemes/wider.scss +2 -0
  2. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/advanced-topics/advanced_topics.md +9 -0
  3. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/advanced-topics/code_coverage.md +130 -0
  4. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/assets/css/just-the-docs-wider.scss +3 -0
  5. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/further-reading/clusterfuzz.md +67 -0
  6. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/further-reading/further_reading.md +9 -0
  7. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/accepting_new_projects.md +36 -0
  8. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/bazel.md +97 -0
  9. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/go_lang.md +125 -0
  10. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/javascript_lang.md +140 -0
  11. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/rust_lang.md +148 -0
  12. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/swift_lang.md +78 -0
  13. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/oss-fuzz/architecture.md +33 -0
  14. local-test-tika-full-01-vuln_7/fuzz-tooling/docs/reference/reference.md +9 -0
  15. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.gitignore +6 -0
  16. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.prettierrc.js +18 -0
  17. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.vscodeignore +10 -0
  18. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/README.md +17 -0
  19. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/src/coverageHelper.ts +300 -0
  20. local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/src/logger.ts +31 -0
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/_sass/color_schemes/wider.scss ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ @import "./color_schemes/light";
2
+ $content-width: 70rem;
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/advanced-topics/advanced_topics.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Advanced topics
4
+ has_children: true
5
+ nav_order: 3
6
+ permalink: /advanced-topics/
7
+ ---
8
+
9
+ # Advanced topics
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/advanced-topics/code_coverage.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Code coverage
4
+ parent: Advanced topics
5
+ nav_order: 2
6
+ permalink: /advanced-topics/code-coverage/
7
+ ---
8
+
9
+ # Code Coverage
10
+ {: .no_toc}
11
+
12
+ For projects written in C/C++, Rust, Go, Swift or Java and other JVM-based languages,
13
+ you can generate code coverage reports using Clang source-based code coverage.
14
+ This page walks you through the basic steps.
15
+ For more details on C/C++ coverage, see [Clang's documentation].
16
+
17
+ Code coverage reports generation for other languages is not supported yet.
18
+
19
+ - TOC
20
+ {:toc}
21
+ ---
22
+
23
+ ## Pull the latest Docker images
24
+
25
+ Docker images get regularly updated with a newer version of build tools, build
26
+ configurations, scripts, and other changes. We recommend you pull the most
27
+ recent images by running the following command:
28
+
29
+ ```bash
30
+ $ python infra/helper.py pull_images
31
+ ```
32
+
33
+ ## Build fuzz targets
34
+
35
+ Code coverage report generation requires a special build configuration to be
36
+ used. To create a code coverage build for your project, run these commands:
37
+
38
+ ```bash
39
+ $ python infra/helper.py build_image $PROJECT_NAME
40
+ $ python infra/helper.py build_fuzzers --sanitizer=coverage $PROJECT_NAME
41
+ ```
42
+
43
+ ## Establish access to GCS
44
+
45
+ To get a good understanding of fuzz testing quality, you should generate code
46
+ coverage reports by running fuzz targets against the corpus
47
+ aggregated by OSS-Fuzz. Set up `gsutil` and ensure that you have access to the
48
+ corpora by doing the following:
49
+
50
+ * Install the [gsutil tool].
51
+ * Check whether you have access to the corpus for your project:
52
+
53
+ ```bash
54
+ $ gsutil ls gs://${PROJECT_NAME}-corpus.clusterfuzz-external.appspot.com/
55
+ ```
56
+
57
+ If you see an authorization error from the command above, run this:
58
+
59
+ ```bash
60
+ $ gcloud auth login
61
+ ```
62
+
63
+ and try again. Once `gsutil` works, you can run the report generation.
64
+
65
+ ## Generate code coverage reports
66
+
67
+ ### Full project report
68
+
69
+ If you want to generate a code coverage report using the corpus aggregated on
70
+ OSS-Fuzz, run this command:
71
+
72
+ ```bash
73
+ $ python infra/helper.py coverage $PROJECT_NAME
74
+ ```
75
+
76
+ If you want to generate a code coverage report using the corpus you have
77
+ locally, copy the corpus into the
78
+ `build/corpus/$PROJECT_NAME/<fuzz_target_name>/` directories for each fuzz
79
+ target, then run this command:
80
+
81
+ ```bash
82
+ $ python infra/helper.py coverage --no-corpus-download $PROJECT_NAME
83
+ ```
84
+
85
+ ### Single fuzz target
86
+
87
+ You can generate a code coverage report for a particular fuzz target by using
88
+ the `--fuzz-target` argument:
89
+
90
+ ```bash
91
+ $ python infra/helper.py coverage --fuzz-target=<fuzz_target_name> $PROJECT_NAME
92
+ ```
93
+
94
+ In this mode, you can specify an arbitrary corpus location for the fuzz target
95
+ (instead of the corpus downloaded from OSS-Fuzz) by using `--corpus-dir`:
96
+
97
+ ```bash
98
+ $ python infra/helper.py coverage --fuzz-target=<fuzz_target_name> \
99
+ --corpus-dir=<my_local_corpus_dir> $PROJECT_NAME
100
+ ```
101
+
102
+ ### Additional arguments for `llvm-cov` (C/C++/Rust only)
103
+
104
+ You may want to use some of the options provided by the [llvm-cov tool], like
105
+ `-ignore-filename-regex=`. You can pass these to the helper script after `--`:
106
+
107
+ ```bash
108
+ $ python infra/helper.py coverage $PROJECT_NAME -- \
109
+ -ignore-filename-regex=.*code/to/be/ignored/.* <other_extra_args>
110
+ ```
111
+
112
+ If you want to specify particular source files or directories to show in the
113
+ report, list their paths at the end of the extra arguments sequence:
114
+
115
+ ```bash
116
+ $ python infra/helper.py coverage zlib -- \
117
+ <other_extra_args> /src/zlib/inftrees.c /src/zlib_uncompress_fuzzer.cc /src/zlib/zutil.c
118
+ ```
119
+
120
+ If you want OSS-Fuzz to use extra arguments when generating code coverage
121
+ reports for your project, add the arguments into your `project.yaml` file as
122
+ follows:
123
+
124
+ ```yaml
125
+ coverage_extra_args: -ignore-filename-regex=.*crc.* -ignore-filename-regex=.*adler.* <other_extra_args>
126
+ ```
127
+
128
+ [Clang's documentation]: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
129
+ [gsutil tool]: https://cloud.google.com/storage/docs/gsutil_install
130
+ [llvm-cov tool]: https://llvm.org/docs/CommandGuide/llvm-cov.html
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/assets/css/just-the-docs-wider.scss ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ---
2
+ ---
3
+ {% include css/just-the-docs.scss.liquid color_scheme="wider" %}
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/further-reading/clusterfuzz.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: ClusterFuzz
4
+ parent: Further reading
5
+ nav_order: 1
6
+ permalink: /further-reading/clusterfuzz/
7
+ ---
8
+
9
+ # ClusterFuzz
10
+
11
+ [ClusterFuzz](https://github.com/google/clusterfuzz) is the distributed fuzzing
12
+ infrastructure behind OSS-Fuzz. It was initially built for fuzzing Chrome at
13
+ scale.
14
+
15
+ - TOC
16
+ {:toc}
17
+ ---
18
+
19
+ ## Web interface
20
+
21
+ ClusterFuzz provides a [web interface](https://oss-fuzz.com)
22
+ to view statistics about your fuzz targets, as well as current crashes.
23
+
24
+ *Note*: Access is restricted to project developers who we auto CC on new bug
25
+ reports.
26
+
27
+ ## Testcase reports
28
+
29
+ ClusterFuzz will automatically de-duplicate and file reproducible crashes into
30
+ our [bug tracker](https://bugs.chromium.org/p/oss-fuzz/issues/list). We provide
31
+ a crash report page that gives you the stack trace, a link to the crashing
32
+ testcase, and regression ranges where the bug was most likely introduced.
33
+
34
+ ![report]({{ site.baseurl }}/images/pcre2_testcase.png?raw=true)
35
+
36
+ ## Fuzzer stats
37
+
38
+ You can view statistics about your fuzz targets (e.g. speed, coverage
39
+ information, memory usage) on our fuzzer statistics dashboard.
40
+
41
+ ![stats]({{ site.baseurl }}/images/freetype_stats_graphs.png?raw=true)
42
+
43
+ ![stats]({{ site.baseurl }}/images/freetype_stats_table.png?raw=true)
44
+
45
+ ## Coverage reports
46
+
47
+ We provide coverage reports, where we highlight the parts of source code that
48
+ are being reached by your fuzz target. Make sure to look at the uncovered code
49
+ marked in red and add appropriate fuzz targets to cover those use cases.
50
+
51
+ ![coverage_1]({{ site.baseurl }}/images/freetype_coverage_1.png?raw=true)
52
+ ![coverage_2]({{ site.baseurl }}/images/freetype_coverage_2.png?raw=true)
53
+
54
+ ## Performance analyzer
55
+
56
+ You can view performance issues that your fuzz target is running into (e.g.
57
+ leaks, timeouts, etc) by clicking on `Performance` link on our fuzzer statistics
58
+ dashboard. Make sure to fix all cited issues, so as to keep your fuzz target
59
+ running efficiently and finding new bugs.
60
+
61
+ ![performance_analyzer]({{ site.baseurl }}/images/expat_performance_analyzer.png?raw=true)
62
+
63
+ ## Crash stats
64
+
65
+ You can view statistics of crashes over time on our crash statistics dashboard.
66
+
67
+ ![crash_stats]({{ site.baseurl }}/images/crash_stats.png?raw=true)
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/further-reading/further_reading.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Further reading
4
+ has_children: true
5
+ nav_order: 4
6
+ permalink: /further-reading/
7
+ ---
8
+
9
+ # Further reading
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/accepting_new_projects.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Accepting new projects
4
+ parent: Getting started
5
+ nav_order: 1
6
+ permalink: /getting-started/accepting-new-projects/
7
+ ---
8
+
9
+ # Accepting New Projects
10
+
11
+ To be accepted to OSS-Fuzz, an open-source project must
12
+ have a significant user base and/or be critical to the global IT infrastructure.
13
+
14
+ To submit a new project, do the following:
15
+
16
+ 1. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/)
17
+ with a new `projects/<project_name>/project.yaml` file
18
+ ([example](https://github.com/google/oss-fuzz/tree/master/projects/libarchive/project.yaml)).
19
+ **Note:** `project_name` can only contain alphanumeric characters,
20
+ underscores(_) or dashes(-).
21
+ 2. In the file, provide the following information:
22
+ * Your project's homepage. ([`homepage`]({{ site.baseurl }}/getting-started/new-project-guide/#homepage))
23
+ * Your project's main repository URL. ([`main_repo`]({{ site.baseurl }}/getting-started/new-project-guide/#main_repo))
24
+ * Your project's primary language. ([`language`]({{ site.baseurl }}/getting-started/new-project-guide/#language))
25
+ * An email address for the engineering contact to be CCed on new issues ([`primary_contact`]({{ site.baseurl }}/getting-started/new-project-guide/#primary)), satisfying the following:
26
+ * The address belongs to an established project committer (according to VCS logs).
27
+ If the address isn't you, or if the address differs from VCS, we'll require an informal
28
+ email verification.
29
+ * The address is associated with a Google account
30
+ ([why?]({{ site.baseurl }}/faq/#why-do-you-require-a-google-account-for-authentication)).
31
+ If you use an alternate email address
32
+ [linked to a Google Account](https://support.google.com/accounts/answer/176347?hl=en),
33
+ you'll only get access to [filed bugs in the issue tracker](https://bugs.chromium.org/p/oss-fuzz/issues/list), not to the [ClusterFuzz]({{ site.baseurl }}/further-reading/clusterfuzz)
34
+ dashboard. This is due to appengine API limitations.
35
+ 3. Once your project is accepted, configure it by following the
36
+ [New Project Guide]({{ site.baseurl }}/getting-started/new-project-guide/).
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/bazel.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Integrating a Bazel project
4
+ parent: Setting up a new project
5
+ grand_parent: Getting started
6
+ nav_order: 5
7
+ permalink: /getting-started/new-project-guide/bazel/
8
+ ---
9
+
10
+ # Integrating a Bazel project
11
+ {: .no_toc}
12
+
13
+ - TOC
14
+ {:toc}
15
+ ---
16
+
17
+ ## Bazel projects
18
+
19
+ The process of integrating a project using the [Bazel](https://bazel.build/)
20
+ build system with OSS-Fuzz is very similar to the general
21
+ [Setting up a new project]({{ site.baseurl }}/getting-started/new-project-guide/)
22
+ process. The key specifics of integrating a Bazel project are outlined below.
23
+
24
+ ## Fuzzing support in Bazel
25
+
26
+ For Bazel-based projects, we recommend using the
27
+ [`rules_fuzzing`](https://github.com/bazelbuild/rules_fuzzing) extension library
28
+ for defining fuzz tests. `rules_fuzzing` provides support for building and running
29
+ fuzz tests under
30
+ [multiple sanitizer and fuzzing engine configurations][rules-fuzzing-usage].
31
+ It also supports specifying corpora and dictionaries as part of the fuzz test
32
+ definition.
33
+
34
+ The fuzzing rules provide out-of-the-box support for building and packaging fuzz
35
+ test artifacts in the OSS-Fuzz format. Each `//path/to:fuzz_test` fuzz test
36
+ target automatically has a `//path/to:fuzz_test_oss_fuzz` packaging target that
37
+ (a) builds the fuzz test using the instrumentation and engine library specified
38
+ in the OSS-Fuzz environment variables, and (b) generates an archive containing
39
+ the binary and its associated artifacts (corpus, dictionary, etc.). Moreover,
40
+ OSS-Fuzz provides a standard tool to automatically process these targets,
41
+ substantially simplifying the `build.sh` script (see below).
42
+
43
+ [rules-fuzzing-usage]: https://github.com/bazelbuild/rules_fuzzing#using-the-rules-in-your-project
44
+
45
+ ## Project files
46
+
47
+ This section explains how to integrate the fuzz tests written using the
48
+ `rules_fuzzing` library with OSS-Fuzz. You can also see a complete example in the
49
+ [`bazel-rules-fuzzing-test`](https://github.com/google/oss-fuzz/tree/master/projects/bazel-rules-fuzzing-test)
50
+ project.
51
+
52
+ The structure of the project directory in the OSS-Fuzz repository does not
53
+ differ for Bazel-based projects. The project files have the following specific
54
+ aspects.
55
+
56
+ ### project.yaml
57
+
58
+ Only C++ projects are currently supported.
59
+
60
+ Since the OSS-Fuzz target builds the fuzz test using the instrumentation and
61
+ engine specified in the OSS-Fuzz environment variables, all the engine and
62
+ sanitizer configurations supported in the `project.yaml` file are automatically
63
+ supported by the fuzzing rules.
64
+
65
+ ### Dockerfile
66
+
67
+ There is no need to install Bazel in your Docker image. The OSS-Fuzz builder
68
+ image provides the `bazel` executable through the
69
+ [Bazelisk](https://github.com/bazelbuild/bazelisk) launcher, which will fetch
70
+ and use the latest Bazel release. If your project requires a particular Bazel
71
+ version, create a
72
+ [`.bazelversion`](https://docs.bazel.build/versions/master/updating-bazel.html)
73
+ file in your repository root with the desired version string.
74
+
75
+ ### build.sh
76
+
77
+ Your `build.sh` script essentially needs to perform three steps: (1) selecting
78
+ which fuzz tests to build, (2) building their OSS-Fuzz package targets in the
79
+ right configuration, and (3) copying the build artifacts to the `${OUT}/`
80
+ destination.
81
+
82
+ OSS-Fuzz provides a
83
+ [`bazel_build_fuzz_tests`](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/bazel_build_fuzz_tests)
84
+ tool that implements these steps in a standard way, so in most cases your
85
+ build script only needs to invoke this command with no arguments.
86
+
87
+ If necessary, the behavior of the tool can be customized through a set of
88
+ environment variables. The most common are:
89
+
90
+ * `BAZEL_EXTRA_BUILD_FLAGS` are extra build flags passed on the Bazel command
91
+ line.
92
+ * `BAZEL_FUZZ_TEST_TAG` and `BAZEL_FUZZ_TEST_EXCLUDE_TAG` can be overridden to
93
+ specify which target tags to use when determining what fuzz tests to include.
94
+ By default, the tool selects all the fuzz tests except for those tagged as
95
+ `"no-oss-fuzz"`.
96
+ * `BAZEL_FUZZ_TEST_QUERY` overrides the Bazel query the tool uses to identify
97
+ the fuzz tests to build, if the tag-based approach is not sufficient.
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/go_lang.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Integrating a Go project
4
+ parent: Setting up a new project
5
+ grand_parent: Getting started
6
+ nav_order: 1
7
+ permalink: /getting-started/new-project-guide/go-lang/
8
+ ---
9
+
10
+ # Integrating a Go project
11
+ {: .no_toc}
12
+
13
+ - TOC
14
+ {:toc}
15
+ ---
16
+
17
+ The process of integrating a project written in Go with OSS-Fuzz is very similar
18
+ to the general
19
+ [Setting up a new project]({{ site.baseurl }}/getting-started/new-project-guide/)
20
+ process. The key specifics of integrating a Go project are outlined below.
21
+
22
+ ## Go-fuzz support
23
+
24
+ OSS-Fuzz supports **go-fuzz** in the
25
+ [libFuzzer compatible mode](https://github.com/mdempsky/go114-fuzz-build)
26
+ only. In that mode, fuzz targets for Go use the libFuzzer engine with native Go
27
+ coverage instrumentation. Binaries compiled in this mode provide the same
28
+ libFuzzer command line interface as non-Go fuzz targets.
29
+
30
+ ## Native Go Fuzzing support
31
+
32
+ OSS-fuzz supports [fuzzers written for the native Go 1.18 engine](https://go.dev/doc/fuzz/). These fuzzers are built as libFuzzer binaries in a similar fashion as fuzzers written for the go-fuzz engine. Because of that, dictionaries and seed corpora should be handled in accordance with [the OSS-fuzz documentation](https://google.github.io/oss-fuzz/getting-started/new-project-guide/#seed-corpus).
33
+ Unlike libFuzzer/go-fuzz targets which must accept one data buffer, fuzz targets written for the Native Go engine can accept any number of arguments of any type. Here is an example of a valid fuzzer with multiple arguments:
34
+
35
+ ```go
36
+ package demofuzzing
37
+
38
+ import (
39
+ "fmt"
40
+ "testing"
41
+ )
42
+
43
+ func FuzzDemo(f *testing.F) {
44
+ f.Fuzz(func(t *testing.T, data1 string, data2 uint32, data3 float64) {
45
+ fmt.Println(data1)
46
+ fmt.Println(data2)
47
+ fmt.Println(data3)
48
+ })
49
+ }
50
+ ```
51
+
52
+ Some requirements for native Go 1.18 fuzzers are:
53
+ * The only `testing.F` method supported is currently `F.Fuzz()`.
54
+ * `F.Add()` will not add seeds when fuzzing. To provide OSS-fuzz with a seed corpus, follow the documentation [here](https://google.github.io/oss-fuzz/getting-started/new-project-guide/#seed-corpus).
55
+
56
+ ## Project files
57
+
58
+ First, you need to write a Go fuzz target. This fuzz target should reside in your project
59
+ repository
60
+ ([example](https://github.com/golang/go/blob/4ad13555184eb0697c2e92c64c1b0bdb287ccc10/src/html/fuzz.go#L13)).
61
+
62
+ The structure of the project directory in OSS-Fuzz repository doesn't differ for
63
+ projects written in Go. The project files have the following Go specific
64
+ aspects.
65
+
66
+ ### project.yaml
67
+
68
+ The `language` attribute must be specified.
69
+
70
+ ```yaml
71
+ language: go
72
+ ```
73
+
74
+ The only supported fuzzing engine and sanitizer are `libfuzzer` and `address`,
75
+ respectively.
76
+ [Example](https://github.com/google/oss-fuzz/blob/356f2b947670b7eb33a1f535c71bc5c87a60b0d1/projects/syzkaller/project.yaml#L7):
77
+
78
+ ```yaml
79
+ fuzzing_engines:
80
+ - libfuzzer
81
+ sanitizers:
82
+ - address
83
+ ```
84
+
85
+ ### Dockerfile
86
+
87
+ The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-go`
88
+
89
+ The OSS-Fuzz builder image has the latest stable release of Golang installed. In
90
+ order to install dependencies of your project, add `RUN git clone ...` command to
91
+ your Dockerfile.
92
+ [Example](https://github.com/google/oss-fuzz/blob/356f2b947670b7eb33a1f535c71bc5c87a60b0d1/projects/syzkaller/Dockerfile#L23):
93
+
94
+ ```dockerfile
95
+ # Dependency for one of the fuzz targets.
96
+ RUN git clone --depth 1 https://github.com/ianlancetaylor/demangle
97
+ ```
98
+
99
+ go-fuzz will then automatically download the dependencies based on the go.mod file
100
+
101
+ ### build.sh
102
+
103
+ In order to build a Go fuzz target, you need to call `go-fuzz`
104
+ command first, and then link the resulting `.a` file against
105
+ `$LIB_FUZZING_ENGINE` using the `$CXX $CXXFLAGS ...` command.
106
+
107
+ For go-fuzz fuzzers, the best way to do this is by using the [`compile_go_fuzzer` script](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/compile_go_fuzzer), and for native Go 1.18 fuzzers it is recommended to use the [`compile_native_go_fuzzer` script](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/compile_native_go_fuzzer). Both of these also support coverage builds.
108
+
109
+ `compile_native_go_fuzzer` requires two dependencies which can be installed with:
110
+ ```bash
111
+ go install github.com/AdamKorcz/go-118-fuzz-build@latest
112
+ go get github.com/AdamKorcz/go-118-fuzz-build/testing
113
+ ```
114
+
115
+ A usage example from go-dns project is
116
+
117
+ ```sh
118
+ compile_go_fuzzer github.com/miekg/dns FuzzNewRR fuzz_newrr fuzz
119
+ ```
120
+
121
+ Arguments are :
122
+ * path of the package with the fuzz target
123
+ * name of the fuzz function
124
+ * name of the fuzzer to be built
125
+ * optional tag to be used by `go build` and such
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/javascript_lang.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Integrating a JavaScript project
4
+ parent: Setting up a new project
5
+ grand_parent: Getting started
6
+ nav_order: 4
7
+ permalink: /getting-started/new-project-guide/javascript-lang/
8
+ ---
9
+
10
+ # Integrating a JavaScript project
11
+ {: .no_toc}
12
+
13
+ - TOC
14
+ {:toc}
15
+ ---
16
+
17
+ The process of integrating a project written in JavaScript for Node.js
18
+ with OSS-Fuzz is very similar to the general
19
+ [Setting up a new project]({{ site.baseurl }}/getting-started/new-project-guide/)
20
+ process. The key specifics of integrating a JavaScript project are outlined below.
21
+
22
+ ## Jazzer.js
23
+
24
+ JavaScript fuzzing in OSS-Fuzz is powered by
25
+ [Jazzer.js](https://github.com/CodeIntelligenceTesting/jazzer.js), which is
26
+ installed during the build step. As Jazzer.js operates directly on the JavaScript
27
+ source code level, it can be applied to any project written in a language that
28
+ can be transpiled into JavaScript such as TypeScript. More information on how Jazzer.js
29
+ fuzz targets look like can be found in its
30
+ [README's Usage section](https://github.com/CodeIntelligenceTesting/jazzer.js#usage).
31
+
32
+ ## Project files
33
+
34
+ ### Example project
35
+
36
+ We recommend viewing
37
+ [javascript-example](https://github.com/google/oss-fuzz/tree/master/projects/javascript-example)
38
+ as an example of a simple JavaScript fuzzing project. We also recommend having a look at
39
+ [typescript-example](https://github.com/google/oss-fuzz/tree/master/projects/typescript-example)
40
+ as an example of how to fuzz TypeScript projects. This example also demonstrates how to use
41
+ Jazzer.js fuzzed data provider.
42
+
43
+ ### project.yaml
44
+
45
+ The `language` attribute must be specified as follows:
46
+
47
+ ```yaml
48
+ language: javascript
49
+ ```
50
+
51
+ The only supported fuzzing engine is libFuzzer (`libfuzzer`). So far, native sanitizers such as
52
+ AddressSanitizer (`address`) and UndefinedBehaviorSanitizer (`undefined`) are not supported.
53
+ They would only be needed for projects that have native addons, which is a rather infrequent
54
+ use case for JavaScript projects. If you have a project where you need ASan or UBSan, please
55
+ create open an issue on [Jazzer.js GitHub repo](https://github.com/CodeIntelligenceTesting/jazzer.js). None (`none`) is the default sanitizer for
56
+ JavaScript projects, so setting it up in `project.yaml` is optional.
57
+
58
+ ```yaml
59
+ fuzzing_engines:
60
+ - libfuzzer
61
+ sanitizers:
62
+ - none
63
+ ```
64
+
65
+ ### Dockerfile
66
+
67
+ The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-javascript`
68
+
69
+ The OSS-Fuzz base Docker images already come with Node.js 19 and `npm` pre-installed.
70
+ Apart from that, you should usually not need to do more than to clone the
71
+ project, set a `WORKDIR`, and copy any necessary files, or install any
72
+ project-specific dependencies here as you normally would.
73
+
74
+ ### Fuzzers
75
+
76
+ In the simplest case, every fuzzer consists of a single JavaScript file that exports
77
+ a function named `fuzz` taking a single argument of type [Buffer](https://nodejs.org/api/buffer.html).
78
+ An example fuzz target could thus be a file `fuzz_string_compare.js` with contents:
79
+
80
+ ```javascript
81
+ /**
82
+ * @param { Buffer } data
83
+ */
84
+ module.exports.fuzz = function (data) {
85
+ const s = data.toString();
86
+ if (s.length !== 16) {
87
+ return;
88
+ }
89
+ if (
90
+ s.slice(0, 8) === "Awesome " &&
91
+ s.slice(8, 15) === "Fuzzing" &&
92
+ s[15] === "!"
93
+ ) {
94
+ throw Error("Welcome to Awesome Fuzzing!");
95
+ }
96
+ };
97
+ ```
98
+
99
+ ### build.sh
100
+
101
+ The OSS-Fuzz base docker image for JavaScript comes with the [`compile_javascript_fuzzer` script](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/compile_javascript_fuzzer) preinstalled. In `build.sh`, you should install dependencies for your project, and if necessary compile the code into JavaScript. Then, you can use the script to build the fuzzers. The script ensures that [@Jazzer.js/core](https://www.npmjs.com/package/@jazzer.js/core) is installed so that its CLI can be used to execute your fuzz tests. It also generates a wrapper script that can be used as a drop-in replacement for libFuzzer. This means that the generated script accepts the same command line flags for libFuzzer. Under the hood these flags are simply forwarded to the libFuzzer native addon used by Jazzer.js.
102
+
103
+ A usage example from the javascript-example project is
104
+
105
+ ```shell
106
+ compile_javascript_fuzzer example fuzz_string_compare.js --sync
107
+ ```
108
+
109
+ Arguments are:
110
+ * relative path of the project in the $SRC directory
111
+ * relative path to the fuzz test inside the project
112
+ * remaining arguments are forwarded to the [Jazzer.js CLI](https://github.com/CodeIntelligenceTesting/jazzer.js/blob/main/docs/fuzz-targets.md#running-the-fuzz-target)
113
+
114
+ The [javascript-example](https://github.com/google/oss-fuzz/blob/master/projects/javascript-example/build.sh)
115
+ project contains an example of a `build.sh` for JavaScript projects.
116
+
117
+ ## FuzzedDataProvider
118
+
119
+ Jazzer.js provides a `FuzzedDataProvider` that can simplify the task of creating a
120
+ fuzz target by translating the raw input bytes received from the fuzzer into
121
+ useful primitive JavaScript types. Its functionality is similar to
122
+ `FuzzedDataProviders` available in other languages, such as
123
+ [Java](https://codeintelligencetesting.github.io/jazzer-docs/jazzer-api/com/code_intelligence/jazzer/api/FuzzedDataProvider.html) and
124
+ [C++](https://github.com/google/fuzzing/blob/master/docs/split-inputs.md).
125
+
126
+ A fuzz target using the `FuzzedDataProvider` would look as follows:
127
+
128
+ ```javascript
129
+ const { FuzzedDataProvider } = require("@jazzer.js/core");
130
+
131
+ /**
132
+ * @param { Buffer } fuzzerInputData
133
+ */
134
+ module.exports.fuzz = function (fuzzerInputData) {
135
+ const data = new FuzzedDataProvider(fuzzerInputData);
136
+ const i = data.consumeIntegral(4);
137
+ const s = data.consumeRemainingAsString();
138
+ exploreMe(i, s);
139
+ };
140
+ ```
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/rust_lang.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Integrating a Rust project
4
+ parent: Setting up a new project
5
+ grand_parent: Getting started
6
+ nav_order: 2
7
+ permalink: /getting-started/new-project-guide/rust-lang/
8
+ ---
9
+
10
+ # Integrating a Rust project
11
+ {: .no_toc}
12
+
13
+ - TOC
14
+ {:toc}
15
+ ---
16
+
17
+ The process of integrating a project written in Rust with OSS-Fuzz is very
18
+ similar to the general [Setting up a new project]({{ site.baseurl
19
+ }}/getting-started/new-project-guide/) process. The key specifics of integrating
20
+ a Rust project are outlined below.
21
+
22
+ ## cargo-fuzz support
23
+
24
+ Rust integration with OSS-Fuzz is expected to use [`cargo
25
+ fuzz`](https://github.com/rust-fuzz/cargo-fuzz) to build fuzzers. The `cargo
26
+ fuzz` tool will build code with required compiler flags as well as link to the
27
+ correct libFuzzer on OSS-Fuzz itself. Note that using `cargo fuzz` also makes it
28
+ quite easy to run the fuzzers locally yourself if you get a failing test case!
29
+
30
+ ## Project files
31
+
32
+ First you'll want to follow the [setup instructions for `cargo fuzz`
33
+ itself](https://rust-fuzz.github.io/book/). Afterwards your project should have:
34
+
35
+ * A top-level `fuzz` directory.
36
+ * A `fuzz/Cargo.toml` manifest which pulls in necessary dependencies to fuzz.
37
+ * Some `fuzz/fuzz_targets/*.rs` files which are the fuzz targets that will be
38
+ compiled and run on OSS-Fuzz.
39
+
40
+ Note that you can customize this layout as well, but you'll need to edit some
41
+ the scripts below to integrate into OSS-Fuzz.
42
+
43
+ ### project.yaml
44
+
45
+ The `language` attribute must be specified.
46
+
47
+ ```yaml
48
+ language: rust
49
+ ```
50
+
51
+ The only supported fuzzing engine and sanitizer are `libfuzzer` and `address`,
52
+ respectively.
53
+ [Example](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects/serde_json/project.yaml#L3-L6)
54
+
55
+ ```yaml
56
+ sanitizers:
57
+ - address
58
+ fuzzing_engines:
59
+ - libfuzzer
60
+ ```
61
+
62
+ ### Dockerfile
63
+
64
+ The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-rust`
65
+
66
+ The OSS-Fuzz builder image has the latest nightly release of Rust as well as
67
+ `cargo fuzz` pre-installed and in `PATH`. In the `Dockerfile` for your project
68
+ all you'll need to do is fetch the latest copy of your code and install any
69
+ system dependencies necessary to build your project.
70
+ [Example](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects/serde_json/Dockerfile#L18-L20)
71
+
72
+ ```dockerfile
73
+ RUN git clone --depth 1 https://github.com/serde-rs/json json
74
+ ```
75
+
76
+ ### build.sh
77
+
78
+ Here it's expected that you'll build the fuzz targets for your project and then
79
+ copy the final binaries into the output directory.
80
+ [Example](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects/serde_json/build.sh#L20):
81
+
82
+ ```sh
83
+ cd $SRC/json
84
+ cargo fuzz build -O
85
+ cp fuzz/target/x86_64-unknown-linux-gnu/release/from_slice $OUT/
86
+ ```
87
+
88
+ Note that you likely want to pass the `-O` flag to `cargo fuzz build` which
89
+ builds fuzzers in release mode. You may also want to pass the
90
+ `--debug-assertions` flag to enable more checks while fuzzing. In this example
91
+ the `from_slice` binary is the fuzz target.
92
+
93
+ With some bash-fu you can also automatically copy over all fuzz targets into
94
+ the output directory so when you add a fuzz target to your project it's
95
+ automatically integrated into OSS-Fuzz:
96
+
97
+ ```sh
98
+ FUZZ_TARGET_OUTPUT_DIR=target/x86_64-unknown-linux-gnu/release
99
+ for f in fuzz/fuzz_targets/*.rs
100
+ do
101
+ FUZZ_TARGET_NAME=$(basename ${f%.*})
102
+ cp $FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME $OUT/
103
+ done
104
+ ```
105
+
106
+ ## Writing fuzzers using a test-style strategy
107
+
108
+ In Rust you will often have tests written in a way so they are only
109
+ compiled into the final binary when build in test-mode. This is, achieved by
110
+ wrapping your test code in `cfg(test)`, e.g.
111
+ ```rust
112
+ #[cfg(test)]
113
+ mod tests {
114
+ use super::*;
115
+
116
+ ...
117
+ ```
118
+
119
+ Cargo-fuzz automatically enables the `fuzzing` feature, which means you can
120
+ follow a similar strategy to writing fuzzers as you do when writing tests.
121
+ Specifically, you can create modules wrapped in the `fuzzing` feature:
122
+ ```rust
123
+ #[cfg(fuzzing)]
124
+ pub mod fuzz_logic {
125
+ use super::*;
126
+
127
+ ...
128
+ ```
129
+ and then call the logic within `fuzz_logic` from your fuzzer.
130
+
131
+ Furthermore, within your `.toml` files, you can then specify fuzzing-specific
132
+ dependencies by wrapping them as follows:
133
+ ```
134
+ [target.'cfg(fuzzing)'.dependencies]
135
+ ```
136
+ similar to how you wrap test-dependencies as follows:
137
+ ```
138
+ [dev-dependencies]
139
+ ```
140
+
141
+ Finally, you can also combine the testing logic you have and the fuzz logic. This
142
+ can be achieved simply by using
143
+ ```rust
144
+ #[cfg(any(test, fuzzing))]
145
+ ```
146
+
147
+ A project that follows this structure is Linkerd2-proxy and the project files can be
148
+ seen [here](https://github.com/google/oss-fuzz/tree/master/projects/linkerd2-proxy).
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/getting-started/new-project-guide/swift_lang.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Integrating a Swift project
4
+ parent: Setting up a new project
5
+ grand_parent: Getting started
6
+ nav_order: 1
7
+ permalink: /getting-started/new-project-guide/swift-lang/
8
+ ---
9
+
10
+ # Integrating a Swift project
11
+ {: .no_toc}
12
+
13
+ - TOC
14
+ {:toc}
15
+ ---
16
+
17
+ The process of integrating a project written in Swift with OSS-Fuzz is very similar
18
+ to the general
19
+ [Setting up a new project]({{ site.baseurl }}/getting-started/new-project-guide/)
20
+ process. The key specifics of integrating a Swift project are outlined below.
21
+
22
+ ## Project files
23
+
24
+ First, you need to write a Swift fuzz target that accepts a stream of bytes and
25
+ calls the program API with that. This fuzz target should reside in your project
26
+ repository.
27
+
28
+ The structure of the project directory in OSS-Fuzz repository doesn't differ for
29
+ projects written in Swift. The project files have the following Swift specific
30
+ aspects.
31
+
32
+ ### project.yaml
33
+
34
+ The `language` attribute must be specified.
35
+
36
+ ```yaml
37
+ language: swift
38
+ ```
39
+
40
+ The only supported fuzzing engine is `libfuzzer`
41
+
42
+ The supported sanitizers are and `address`, `thread`
43
+
44
+ [Example](https://github.com/google/oss-fuzz/blob/2a15c3c88b21f4f1be2a7ff115f72bd7a08e34ac/projects/swift-nio/project.yaml#L9):
45
+
46
+ ```yaml
47
+ fuzzing_engines:
48
+ - libfuzzer
49
+ sanitizers:
50
+ - address
51
+ - thread
52
+ ```
53
+
54
+ ### Dockerfile
55
+
56
+ The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-swift`
57
+ instead of using the simple base-builder
58
+
59
+ ### build.sh
60
+
61
+ A `precompile_swift` generates an environment variable `SWIFTFLAGS`
62
+ This can then be used in the building command such as `swift build -c release $SWIFTFLAGS`
63
+
64
+
65
+ A usage example from swift-protobuf project is
66
+
67
+ ```sh
68
+ . precompile_swift
69
+ # build project
70
+ cd FuzzTesting
71
+ swift build -c debug $SWIFTFLAGS
72
+
73
+ (
74
+ cd .build/debug/
75
+ find . -maxdepth 1 -type f -name "*Fuzzer" -executable | while read i; do cp $i $OUT/"$i"-debug; done
76
+ )
77
+
78
+ ```
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/oss-fuzz/architecture.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Architecture
4
+ permalink: /architecture/
5
+ nav_order: 1
6
+ parent: OSS-Fuzz
7
+ ---
8
+
9
+ # Architecture
10
+ ![OSS-Fuzz architecture diagram]({{ site.baseurl }}/images/process.png?raw=true)
11
+
12
+ The process works like this:
13
+
14
+ 1. A maintainer of an open source project (or an outside volunteer) creates
15
+ one or more [fuzz targets](https://llvm.org/docs/LibFuzzer.html#fuzz-target)
16
+ and [integrates]({{ site.baseurl }}/advanced-topics/ideal-integration/) them
17
+ with the project's build and test system.
18
+ 1. The project is [accepted to OSS-Fuzz]({{ site.baseurl }}/getting-started/accepting-new-projects/) and the developer commits their build configurations.
19
+ 1. The OSS-Fuzz [builder](https://github.com/google/oss-fuzz/tree/master/infra/build) builds the project from the committed configs.
20
+ 1. The builder uploads the fuzz targets to the OSS-Fuzz GCS bucket.
21
+ 1. [ClusterFuzz]({{ site.baseurl }}/further-reading/clusterfuzz) downloads the fuzz targets and begins to fuzz the projects.
22
+ 1. When Clusterfuzz finds a
23
+ bug, it reports the issue automatically to the OSS-Fuzz
24
+ [issue tracker](https://bugs.chromium.org/p/oss-fuzz/issues/list)
25
+ ([example](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9)).
26
+ ([Why use a different tracker?]({{ site.baseurl }}/faq/#why-do-you-use-a-different-issue-tracker-for-reporting-bugs-in-oss-projects))
27
+ 1. Project owners are CCed on the bug report.
28
+ 1. The project developer fixes the bug upstream and credits OSS-Fuzz for the
29
+ discovery (the commit message should contain the string **'Credit to OSS-Fuzz'**).
30
+
31
+ Once the developer fixes the bug, [ClusterFuzz]({{ site.baseurl }}/further-reading/clusterfuzz) automatically
32
+ verifies the fix, adds a comment, and closes the issue ([example](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53#c3)). After the fix is verified or 90 days after reporting (whichever is earlier), the issue becomes [public]({{ site.baseurl }}/getting-started/bug-disclosure-guidelines/).
33
+
local-test-tika-full-01-vuln_7/fuzz-tooling/docs/reference/reference.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: default
3
+ title: Reference
4
+ has_children: true
5
+ nav_order: 6
6
+ permalink: /reference/
7
+ ---
8
+
9
+ # Reference
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ out
2
+ build
3
+ dist
4
+ node_modules
5
+ .vscode-test/
6
+ *.vsix
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.prettierrc.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright 2023 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
+ module.exports = {
17
+ ...require('gts/.prettierrc.json')
18
+ }
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/.vscodeignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .vscode/**
2
+ .vscode-test/**
3
+ src/**
4
+ .gitignore
5
+ .yarnrc
6
+ vsc-extension-quickstart.md
7
+ **/tsconfig.json
8
+ **/.eslintrc.json
9
+ **/*.map
10
+ **/*.ts
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/README.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OSS-Fuzz VSCode extension
2
+
3
+ [OSS-Fuzz](https://github.com/google/oss-fuzz) is a fuzzing toolkit and service for fuzzing open source projects. This VSCode extension provides features and capabilities for interacting with the OSS-Fuzz toolkit and also to compare local changes to the OSS-Fuzz cloud database by way of [Open source fuzz introspection](https://introspector.oss-fuzz.com).
4
+
5
+ ## Features
6
+
7
+ The VSCode extension is largely driven by commands at this point. The featues of these commands includes:
8
+
9
+ - Easily setting up OSS-Fuzz
10
+ - Templates for easily setting up a new OSS-Fuzz project
11
+ - Building arbitrary projects from OSS-Fuzz
12
+ - Modify a project from VSCode and test changes in OSS-Fuzz
13
+ - Easily extract code coverage of fuzzers, including local-only fuzzers
14
+ - Compare local code coverage to what is currently achieved by OSS-Fuzz
15
+ - Auto-generation of fuzzer templates
16
+
17
+ For a full list of commands and their features, please check the commands page.
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/src/coverageHelper.ts ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright 2023 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
+ import * as vscode from 'vscode';
18
+ import {Uri} from 'vscode';
19
+ import {println} from './logger';
20
+ import {
21
+ getOSSFuzzCloudURL,
22
+ getLocalOutBuildDir,
23
+ downloadRemoteURL,
24
+ } from './utils';
25
+
26
+ const path = require('path');
27
+ let isCodeCoverageEnabled = false;
28
+
29
+ // create a decorator type that we use to decorate small numbers
30
+ const codeCoveredLineDecorationType =
31
+ vscode.window.createTextEditorDecorationType({
32
+ backgroundColor: '#184916',
33
+ overviewRulerColor: 'blue',
34
+ overviewRulerLane: vscode.OverviewRulerLane.Right,
35
+ light: {
36
+ // this color will be used in light color themes
37
+ borderColor: 'darkblue',
38
+ },
39
+ dark: {
40
+ // this color will be used in dark color themes
41
+ borderColor: 'lightblue',
42
+ },
43
+ });
44
+
45
+ const missingLineDecorationType = vscode.window.createTextEditorDecorationType({
46
+ backgroundColor: '#6C2B34',
47
+ overviewRulerColor: 'blue',
48
+ overviewRulerLane: vscode.OverviewRulerLane.Right,
49
+ light: {
50
+ // this color will be used in light color themes
51
+ borderColor: 'darkblue',
52
+ },
53
+ dark: {
54
+ // this color will be used in dark color themes
55
+ borderColor: 'lightblue',
56
+ },
57
+ });
58
+
59
+ export async function loadSummaryJsonCoverage(
60
+ context: vscode.ExtensionContext,
61
+ codeCoverageFile: Uri
62
+ ) {
63
+ const coverageSummaryRawJson = await vscode.workspace.openTextDocument(
64
+ codeCoverageFile
65
+ );
66
+ const jsonCodeCoverage = JSON.parse(coverageSummaryRawJson.getText());
67
+ return jsonCodeCoverage;
68
+ }
69
+
70
+ export async function compareLocalToRemoteCoverage(
71
+ context: vscode.ExtensionContext,
72
+ projectName: string
73
+ ) {
74
+ println('Checking the file matching');
75
+ /* Get the coverage from the remote server */
76
+ const urlString =
77
+ (await getOSSFuzzCloudURL(projectName)) + '/linux/summary.json';
78
+
79
+ println('URL: ' + urlString);
80
+ const codeCoverageFile: false | vscode.Uri = await downloadRemoteURL(
81
+ urlString,
82
+ 'summary.json',
83
+ context
84
+ );
85
+ if (!codeCoverageFile) {
86
+ println('Could not get the coverage summary file');
87
+ return;
88
+ }
89
+ const remoteCoverage = await loadSummaryJsonCoverage(
90
+ context,
91
+ codeCoverageFile
92
+ );
93
+
94
+ /* Get the local coverage report */
95
+ // Compare the local coverage to the upstream coverage
96
+ const localSummaryCovPath =
97
+ (await getLocalOutBuildDir(projectName)) + '/report/linux/summary.json';
98
+ const localCodeCoverage = await loadSummaryJsonCoverage(
99
+ context,
100
+ vscode.Uri.file(localSummaryCovPath)
101
+ );
102
+
103
+ for (let i = 0; i < localCodeCoverage.data[0].files.length; i++) {
104
+ for (let j = 0; j < remoteCoverage.data[0].files.length; j++) {
105
+ // Get the file dictionary
106
+ const localFileData = localCodeCoverage.data[0].files[i];
107
+ const remoteFileData = remoteCoverage.data[0].files[j];
108
+
109
+ // If the filepaths are the same, then we match coverage data
110
+ if (localFileData.filename === remoteFileData.filename) {
111
+ const remoteFuncCount = remoteFileData.summary.functions.count;
112
+ const localFuncCount = localFileData.summary.functions.count;
113
+
114
+ if (localFuncCount > remoteFuncCount) {
115
+ println(
116
+ 'Coverage improved in :' +
117
+ localFileData.filename +
118
+ ' [' +
119
+ localFuncCount +
120
+ ' : ' +
121
+ remoteFuncCount +
122
+ ']'
123
+ );
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+ /**
131
+ *
132
+ * @param context Adds visualisation to the editor based on reading a code coverage file.
133
+ * @param codeCoverageFile
134
+ */
135
+ export async function loadCoverageIntoWorkspace(
136
+ context: vscode.ExtensionContext,
137
+ codeCoverageFile: Uri
138
+ ) {
139
+ isCodeCoverageEnabled = true;
140
+
141
+ const doc3 = await vscode.workspace.openTextDocument(codeCoverageFile);
142
+ const jsonCodeCoverageObj3 = JSON.parse(doc3.getText());
143
+
144
+ const codeCoverageMappingWithCoverage = new Map();
145
+ const codeCoverageMapMissingCoverage = new Map();
146
+
147
+ Object.entries(jsonCodeCoverageObj3['files']).forEach(entry => {
148
+ const [key, value] = entry;
149
+ println(key);
150
+ const filename = path.parse(key).base;
151
+ println('Filename base: ' + filename);
152
+ const objectDictionary: any = value as any;
153
+ const linesWithCodeCoverage: unknown[] = [];
154
+ println(objectDictionary['executed_lines']);
155
+ Object.entries(objectDictionary['executed_lines']).forEach(entryInner => {
156
+ const lineNumber = entryInner[1];
157
+ //println("executed line: " + lineNumber);
158
+ linesWithCodeCoverage.push(lineNumber);
159
+ });
160
+ codeCoverageMappingWithCoverage.set(filename, linesWithCodeCoverage);
161
+
162
+ const linesMissingCodeCoverage: unknown[] = [];
163
+ Object.entries(objectDictionary['missing_lines']).forEach(entryInner => {
164
+ const lineNumber = entryInner[1];
165
+ //println("executed line: " + line_numb);
166
+ linesMissingCodeCoverage.push(lineNumber);
167
+ });
168
+ codeCoverageMapMissingCoverage.set(filename, linesMissingCodeCoverage);
169
+ });
170
+ println('=========>');
171
+
172
+ println('Enabling code coverage decorator');
173
+ println('decorator sample is activated');
174
+
175
+ let timeout: NodeJS.Timer | undefined = undefined;
176
+
177
+ // create a decorator type that we use to decorate large numbers
178
+
179
+ let activeEditor = vscode.window.activeTextEditor;
180
+
181
+ function updateDecorations(
182
+ linesWithCodeCoverage: any,
183
+ linesWithoNoCodeCoverage: any
184
+ ) {
185
+ if (!isCodeCoverageEnabled) {
186
+ return;
187
+ }
188
+ if (!activeEditor) {
189
+ return;
190
+ }
191
+ println('Filename');
192
+ println(activeEditor.document.fileName);
193
+
194
+ // Current file opened in the editor.
195
+ const nameOfCurrentFile = path.parse(activeEditor.document.fileName).base;
196
+
197
+ println('Base filename: ' + nameOfCurrentFile);
198
+ println('Done filename');
199
+ const lineNumbersWithCoverage: vscode.DecorationOptions[] = [];
200
+ const missingLineNumbers: vscode.DecorationOptions[] = [];
201
+
202
+ if (linesWithCodeCoverage.has(nameOfCurrentFile)) {
203
+ println('Has this file');
204
+ const elemWithCov = linesWithCodeCoverage.get(nameOfCurrentFile);
205
+ for (let idx = 0; idx < elemWithCov.length; idx++) {
206
+ const lineNo = elemWithCov[idx];
207
+ println('Setting up: ' + lineNo);
208
+ lineNumbersWithCoverage.push({
209
+ range: new vscode.Range(lineNo - 1, 0, lineNo, 0),
210
+ });
211
+ }
212
+
213
+ const elemNoCov = linesWithoNoCodeCoverage.get(nameOfCurrentFile);
214
+ for (let idx = 0; idx < elemNoCov.length; idx++) {
215
+ const lineNo = elemNoCov[idx];
216
+ println('Setting up: ' + lineNo);
217
+ missingLineNumbers.push({
218
+ range: new vscode.Range(lineNo - 1, 0, lineNo, 0),
219
+ });
220
+ }
221
+ } else {
222
+ println('Does not have this file');
223
+ }
224
+
225
+ activeEditor.setDecorations(
226
+ codeCoveredLineDecorationType,
227
+ lineNumbersWithCoverage
228
+ );
229
+ activeEditor.setDecorations(missingLineDecorationType, missingLineNumbers);
230
+ //activeEditor.setDecorations(largeNumberDecorationType, largeNumbers);
231
+ }
232
+
233
+ function triggerUpdateDecorations(
234
+ throttle = false,
235
+ covMap: any,
236
+ covMisMap: any
237
+ ) {
238
+ if (timeout) {
239
+ clearTimeout(timeout);
240
+ timeout = undefined;
241
+ }
242
+ if (throttle) {
243
+ //timeout = setTimeout(updateDecorations, 500);
244
+ updateDecorations(covMap, covMisMap);
245
+ } else {
246
+ updateDecorations(covMap, covMisMap);
247
+ }
248
+ }
249
+
250
+ if (activeEditor) {
251
+ triggerUpdateDecorations(
252
+ false,
253
+ codeCoverageMappingWithCoverage,
254
+ codeCoverageMapMissingCoverage
255
+ );
256
+ }
257
+
258
+ vscode.window.onDidChangeActiveTextEditor(
259
+ editor => {
260
+ activeEditor = editor;
261
+ if (editor) {
262
+ triggerUpdateDecorations(
263
+ false,
264
+ codeCoverageMappingWithCoverage,
265
+ codeCoverageMapMissingCoverage
266
+ );
267
+ }
268
+ },
269
+ null,
270
+ context.subscriptions
271
+ );
272
+
273
+ vscode.workspace.onDidChangeTextDocument(
274
+ event => {
275
+ if (activeEditor && event.document === activeEditor.document) {
276
+ triggerUpdateDecorations(
277
+ true,
278
+ codeCoverageMappingWithCoverage,
279
+ codeCoverageMapMissingCoverage
280
+ );
281
+ }
282
+ },
283
+ null,
284
+ context.subscriptions
285
+ );
286
+ }
287
+
288
+ /**
289
+ * Removes the values from the mappings used to track code coverage. As a
290
+ * result, the visualisation disappears.
291
+ */
292
+ export async function clearCoverage() {
293
+ // Set global indicator.
294
+ const activeEditor = vscode.window.activeTextEditor;
295
+ isCodeCoverageEnabled = false;
296
+ if (activeEditor) {
297
+ activeEditor.setDecorations(codeCoveredLineDecorationType, []);
298
+ activeEditor.setDecorations(missingLineDecorationType, []);
299
+ }
300
+ }
local-test-tika-full-01-vuln_7/fuzz-tooling/tools/vscode-extension/src/logger.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright 2023 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
+ import * as vscode from 'vscode';
18
+ export const vscodeOutputChannel =
19
+ vscode.window.createOutputChannel('oss-fuzz');
20
+
21
+ export function println(line: string) {
22
+ vscodeOutputChannel.appendLine(line);
23
+ }
24
+
25
+ export function printRaw(line: string) {
26
+ vscodeOutputChannel.append(line);
27
+ }
28
+
29
+ export function debugPrintln(line: string) {
30
+ console.log(line);
31
+ }