diff options
author | Catena cyber <35799796+catenacyber@users.noreply.github.com> | 2021-05-24 22:48:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-24 13:48:18 -0700 |
commit | 5fe68329adbf1f7aec606dc0371a07addf54ebef (patch) | |
tree | 8f0e2f4f23806b9175ab5620c9435b0402d42176 /projects/grpc-swift | |
parent | 878a05a0926eb14783ae38f42c0bf22d07eb991c (diff) | |
download | oss-fuzz-5fe68329adbf1f7aec606dc0371a07addf54ebef.tar.gz |
Use upstream targets for grpc-swift (#5825)
Diffstat (limited to 'projects/grpc-swift')
-rw-r--r-- | projects/grpc-swift/Dockerfile | 2 | ||||
-rw-r--r-- | projects/grpc-swift/Package.swift | 39 | ||||
-rwxr-xr-x | projects/grpc-swift/build.sh | 12 | ||||
-rw-r--r-- | projects/grpc-swift/fuzz_pipeline_configurator.swift | 30 | ||||
-rw-r--r-- | projects/grpc-swift/patch.diff | 62 |
5 files changed, 3 insertions, 142 deletions
diff --git a/projects/grpc-swift/Dockerfile b/projects/grpc-swift/Dockerfile index 56955acf0..ccea076b3 100644 --- a/projects/grpc-swift/Dockerfile +++ b/projects/grpc-swift/Dockerfile @@ -45,6 +45,4 @@ COPY llvmsymbol.diff $SRC # specific to project RUN git clone --depth 1 https://github.com/grpc/grpc-swift COPY build.sh $SRC -COPY *.swift $SRC/ -COPY patch.diff $SRC/ WORKDIR $SRC/grpc-swift diff --git a/projects/grpc-swift/Package.swift b/projects/grpc-swift/Package.swift deleted file mode 100644 index 3a4e9265c..000000000 --- a/projects/grpc-swift/Package.swift +++ /dev/null @@ -1,39 +0,0 @@ -// swift-tools-version:5.3 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "grpc-swift-fuzz", - dependencies: [ - // Dependencies declare other packages that this package depends on. - .package(name: "grpc-swift", path: ".."), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "grpc-swift-fuzz", - dependencies: [ - .target(name: "EchoImplementation"), - .product(name: "GRPC", package: "grpc-swift") - ]), - - .target( - name: "EchoImplementation", - dependencies: [ - .target(name: "EchoModel"), - .product(name: "GRPC", package: "grpc-swift"), - ], - path: "Sources/Echo/Implementation" - ), - - .target( - name: "EchoModel", - dependencies: [ - .product(name: "GRPC", package: "grpc-swift"), - ], - path: "Sources/Echo/Model" - ), - ] -) diff --git a/projects/grpc-swift/build.sh b/projects/grpc-swift/build.sh index 19b4bad32..3c1aaf841 100755 --- a/projects/grpc-swift/build.sh +++ b/projects/grpc-swift/build.sh @@ -33,14 +33,8 @@ ninja -j$(nproc) llvm-symbolizer cp bin/llvm-symbolizer $OUT/ ) -git apply $SRC/patch.diff # build project -mkdir grpc-swift-fuzz -cd grpc-swift-fuzz -swift package init --type=executable -cp $SRC/fuzz_pipeline_configurator.swift Sources/grpc-swift-fuzz/main.swift -cp -r ../Sources/Examples/Echo Sources/ -cp $SRC/Package.swift Package.swift +cd FuzzTesting # Maybe we should have a helper script to set $SWIFT_FLAGS # for instance about -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in -Xcc swift build -c debug -Xswiftc -sanitize=fuzzer,address \ @@ -51,7 +45,7 @@ swift build -c debug -Xswiftc -sanitize=fuzzer,address \ ( cd .build/debug/ -find . -maxdepth 1 -type f -name "*fuzz" -executable | while read i; do cp $i $OUT/"$i"-debug; done +find . -maxdepth 1 -type f -name "*Fuzzer" -executable | while read i; do cp $i $OUT/"$i"-debug; done ) swift build -c release -Xswiftc -sanitize=fuzzer,address \ -Xswiftc -parse-as-library -Xswiftc -static-stdlib \ @@ -60,5 +54,5 @@ swift build -c release -Xswiftc -sanitize=fuzzer,address \ -Xcxx="-fsanitize=fuzzer-no-link,address" ( cd .build/release/ -find . -maxdepth 1 -type f -name "*fuzz" -executable | while read i; do cp $i $OUT/"$i"-release; done +find . -maxdepth 1 -type f -name "*Fuzzer" -executable | while read i; do cp $i $OUT/"$i"-release; done ) diff --git a/projects/grpc-swift/fuzz_pipeline_configurator.swift b/projects/grpc-swift/fuzz_pipeline_configurator.swift deleted file mode 100644 index 9b03e68a3..000000000 --- a/projects/grpc-swift/fuzz_pipeline_configurator.swift +++ /dev/null @@ -1,30 +0,0 @@ -import GRPC -import NIO -import EchoImplementation - -@_cdecl("LLVMFuzzerTestOneInput") -public func test(_ start: UnsafeRawPointer, _ count: Int) -> CInt { - let bytes = UnsafeRawBufferPointer(start: start, count: count) - - let channel = EmbeddedChannel() - let configuration = Server.Configuration( - target: .unixDomainSocket("/ignored"), - eventLoopGroup: channel.eventLoop, - serviceProviders: [EchoProvider()] - ) - let handler = GRPCServerPipelineConfigurator(configuration: configuration) - - var buffer = channel.allocator.buffer(capacity: count) - buffer.writeBytes(bytes) - do { - try channel.pipeline.addHandler(handler).wait() - try channel.writeInbound(buffer) - channel.embeddedEventLoop.run() - } catch { - } - do { - try _ = channel.finish(acceptAlreadyClosed: true) - } catch { - } - return 0 -} diff --git a/projects/grpc-swift/patch.diff b/projects/grpc-swift/patch.diff deleted file mode 100644 index 6d15e6029..000000000 --- a/projects/grpc-swift/patch.diff +++ /dev/null @@ -1,62 +0,0 @@ -diff --git a/Sources/GRPC/GRPCServerPipelineConfigurator.swift b/Sources/GRPC/GRPCServerPipelineConfigurator.swift -index 4a0c143..1a02cd7 100644 ---- a/Sources/GRPC/GRPCServerPipelineConfigurator.swift -+++ b/Sources/GRPC/GRPCServerPipelineConfigurator.swift -@@ -25,9 +25,9 @@ import NIOTLS - /// If TLS is enabled then the handler listens for an 'TLSUserEvent.handshakeCompleted' event and - /// configures the pipeline appropriately for the protocol negotiated via ALPN. If TLS is not - /// configured then the HTTP version is determined by parsing the inbound byte stream. --final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChannelHandler { -- internal typealias InboundIn = ByteBuffer -- internal typealias InboundOut = ByteBuffer -+public final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChannelHandler { -+ public typealias InboundIn = ByteBuffer -+ public typealias InboundOut = ByteBuffer - - /// The server configuration. - private let configuration: Server.Configuration -@@ -57,7 +57,7 @@ final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChan - case configuring - } - -- init(configuration: Server.Configuration) { -+ public init(configuration: Server.Configuration) { - if let tls = configuration.tls { - self.state = .notConfigured(alpn: .expected(required: tls.requireALPN)) - } else { -@@ -251,7 +251,7 @@ final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChan - - // MARK: - Channel Handler - -- internal func errorCaught(context: ChannelHandlerContext, error: Error) { -+ public func errorCaught(context: ChannelHandlerContext, error: Error) { - if let delegate = self.configuration.errorDelegate { - let baseError: Error - -@@ -267,7 +267,7 @@ final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChan - context.close(mode: .all, promise: nil) - } - -- internal func userInboundEventTriggered(context: ChannelHandlerContext, event: Any) { -+ public func userInboundEventTriggered(context: ChannelHandlerContext, event: Any) { - switch self.state { - case let .notConfigured(alpn: .expected(required)): - if let event = event as? TLSUserEvent { -@@ -283,7 +283,7 @@ final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChan - context.fireUserInboundEventTriggered(event) - } - -- internal func channelRead(context: ChannelHandlerContext, data: NIOAny) { -+ public func channelRead(context: ChannelHandlerContext, data: NIOAny) { - self.bufferedReads.append(data) - - switch self.state { -@@ -302,7 +302,7 @@ final class GRPCServerPipelineConfigurator: ChannelInboundHandler, RemovableChan - // Don't forward the reads: we'll do so when we have configured the pipeline. - } - -- internal func removeHandler( -+ public func removeHandler( - context: ChannelHandlerContext, - removalToken: ChannelHandlerContext.RemovalToken - ) { |