aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorGravatar Catena cyber <35799796+catenacyber@users.noreply.github.com>2021-09-02 23:56:01 +0200
committerGravatar GitHub <noreply@github.com>2021-09-02 14:56:01 -0700
commitdd8e46c38b11788db8ac42de0d27fc11abfcdbae (patch)
tree84e06bf3168c02be1cef7579d52a11c46c839273 /docs
parent3ae0d9fe148e18064cd8b361e2a21deb0dbc637f (diff)
Swift ideal integration (#6312)
* Helper flags for swift compilation * Documentation for swift project integration * Adds swift to the languages with coverage * Only thread sanitizer is supported * Fixes swift coverage target compilation * fixup flags facotring * swift: run on new ubuntu * fixup * swift: right copy for symbolizer
Diffstat (limited to 'docs')
-rw-r--r--docs/getting-started/new-project-guide/swift.md78
1 files changed, 78 insertions, 0 deletions
diff --git a/docs/getting-started/new-project-guide/swift.md b/docs/getting-started/new-project-guide/swift.md
new file mode 100644
index 00000000..dbb127b0
--- /dev/null
+++ b/docs/getting-started/new-project-guide/swift.md
@@ -0,0 +1,78 @@
+---
+layout: default
+title: Integrating a Swift project
+parent: Setting up a new project
+grand_parent: Getting started
+nav_order: 1
+permalink: /getting-started/new-project-guide/swift/
+---
+
+# Integrating a Swift project
+{: .no_toc}
+
+- TOC
+{:toc}
+---
+
+The process of integrating a project written in Swift with OSS-Fuzz is very similar
+to the general
+[Setting up a new project]({{ site.baseurl }}/getting-started/new-project-guide/)
+process. The key specifics of integrating a Swift project are outlined below.
+
+## Project files
+
+First, you need to write a Swift fuzz target that accepts a stream of bytes and
+calls the program API with that. This fuzz target should reside in your project
+repository.
+
+The structure of the project directory in OSS-Fuzz repository doesn't differ for
+projects written in Swift. The project files have the following Swift specific
+aspects.
+
+### project.yaml
+
+The `language` attribute must be specified.
+
+```yaml
+language: swift
+```
+
+The only supported fuzzing engine is `libfuzzer`
+
+The supported sanitizers are and `address`, `thread`
+
+[Example](https://github.com/google/oss-fuzz/blob/2a15c3c88b21f4f1be2a7ff115f72bd7a08e34ac/projects/swift-nio/project.yaml#L9):
+
+```yaml
+fuzzing_engines:
+ - libfuzzer
+sanitizers:
+ - address
+ - thread
+```
+
+### Dockerfile
+
+The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-swift`
+instead of using the simple base-builder
+
+### build.sh
+
+A `precompile_swift` generates an environment variable `SWIFTFLAGS`
+This can then be used in the building command such as `swift build -c release $SWIFTFLAGS`
+
+
+A usage example from swift-protobuf project is
+
+```sh
+. precompile_swift
+# build project
+cd FuzzTesting
+swift build -c debug $SWIFTFLAGS
+
+(
+cd .build/debug/
+find . -maxdepth 1 -type f -name "*Fuzzer" -executable | while read i; do cp $i $OUT/"$i"-debug; done
+)
+
+```