mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-12-24 19:30:18 +01:00
Merge remote-tracking branch 'dutchcoders/master'
This commit is contained in:
commit
614a7fd23d
4 changed files with 4 additions and 129 deletions
16
.travis.yml
16
.travis.yml
|
@ -9,6 +9,8 @@ services:
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.13.x
|
- 1.13.x
|
||||||
|
- 1.14.x
|
||||||
|
- 1.15.x
|
||||||
- tip
|
- tip
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
@ -23,18 +25,6 @@ install:
|
||||||
script:
|
script:
|
||||||
- go test ./...
|
- go test ./...
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- stage: Fuzz regression
|
|
||||||
go: 1.13.x
|
|
||||||
dist: bionic
|
|
||||||
script: ./fuzzit.sh local-regression
|
|
||||||
- stage: Fuzz
|
|
||||||
if: branch = master AND type IN (push)
|
|
||||||
go: 1.13.x
|
|
||||||
dist: bionic
|
|
||||||
script: ./fuzzit.sh fuzzing
|
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- mkdir -p release
|
- mkdir -p release
|
||||||
- "GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags -a -tags netgo -ldflags '-s -w -extldflags -static' -o release/transfersh-$TRAVIS_TAG-linux-amd64"
|
- "GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags -a -tags netgo -ldflags '-s -w -extldflags -static' -o release/transfersh-$TRAVIS_TAG-linux-amd64"
|
||||||
|
@ -54,5 +44,5 @@ deploy:
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
go: 1.13.x
|
go: 1.15.x
|
||||||
overwrite: true
|
overwrite: true
|
|
@ -1,4 +1,4 @@
|
||||||
# transfer.sh [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dutchcoders/transfer.sh?utm_source=badge&utm_medium=badge&utm_campaign=&utm_campaign=pr-badge&utm_content=badge) [![Go Report Card](https://goreportcard.com/badge/github.com/dutchcoders/transfer.sh)](https://goreportcard.com/report/github.com/dutchcoders/transfer.sh) [![Docker pulls](https://img.shields.io/docker/pulls/dutchcoders/transfer.sh.svg)](https://hub.docker.com/r/dutchcoders/transfer.sh/) [![Build Status](https://travis-ci.org/dutchcoders/transfer.sh.svg?branch=master)](https://travis-ci.org/dutchcoders/transfer.sh) [![Fuzzit Status](https://app.fuzzit.dev/badge?org_id=transfer.sh)](https://app.fuzzit.dev/orgs/transfer.sh/dashboard)
|
# transfer.sh [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dutchcoders/transfer.sh?utm_source=badge&utm_medium=badge&utm_campaign=&utm_campaign=pr-badge&utm_content=badge) [![Go Report Card](https://goreportcard.com/badge/github.com/dutchcoders/transfer.sh)](https://goreportcard.com/report/github.com/dutchcoders/transfer.sh) [![Docker pulls](https://img.shields.io/docker/pulls/dutchcoders/transfer.sh.svg)](https://hub.docker.com/r/dutchcoders/transfer.sh/) [![Build Status](https://travis-ci.com/dutchcoders/transfer.sh.svg?branch=master)](https://travis-ci.com/dutchcoders/transfer.sh)
|
||||||
|
|
||||||
Easy and fast file sharing from the command-line. This code contains the server with everything you need to create your own instance.
|
Easy and fast file sharing from the command-line. This code contains the server with everything you need to create your own instance.
|
||||||
|
|
||||||
|
|
33
fuzzit.sh
33
fuzzit.sh
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -xe
|
|
||||||
|
|
||||||
# Validate arguments
|
|
||||||
if [ "$#" -ne 1 ]; then
|
|
||||||
echo "Usage: $0 <fuzz-type>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure
|
|
||||||
NAME=transfersh
|
|
||||||
ROOT=./server
|
|
||||||
TYPE=$1
|
|
||||||
|
|
||||||
# Setup
|
|
||||||
export GOFUZZ111MODULE="on"
|
|
||||||
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
|
|
||||||
go get -d -v -u ./...
|
|
||||||
if [ ! -f fuzzit ]; then
|
|
||||||
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.72/fuzzit_Linux_x86_64
|
|
||||||
chmod a+x fuzzit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fuzz
|
|
||||||
function fuzz {
|
|
||||||
FUNC=Fuzz$1
|
|
||||||
TARGET=$2
|
|
||||||
DIR=${3:-$ROOT}
|
|
||||||
go-fuzz-build -libfuzzer -func $FUNC -o fuzzer.a $DIR
|
|
||||||
clang -fsanitize=fuzzer fuzzer.a -o fuzzer
|
|
||||||
./fuzzit create job --type $TYPE $NAME/$TARGET fuzzer
|
|
||||||
}
|
|
||||||
fuzz LocalStorage local-storage
|
|
|
@ -1,82 +0,0 @@
|
||||||
// +build gofuzz
|
|
||||||
|
|
||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
"math/rand"
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
const applicationOctetStream = "application/octet-stream"
|
|
||||||
|
|
||||||
// FuzzLocalStorage tests the Local Storage.
|
|
||||||
func FuzzLocalStorage(fuzz []byte) int {
|
|
||||||
var fuzzLength = uint64(len(fuzz))
|
|
||||||
if fuzzLength == 0 {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
storage, err := NewLocalStorage("/tmp", nil)
|
|
||||||
if err != nil {
|
|
||||||
panic("unable to create local storage")
|
|
||||||
}
|
|
||||||
|
|
||||||
token := Encode(10000000 + int64(rand.Intn(1000000000)))
|
|
||||||
filename := Encode(10000000+int64(rand.Intn(1000000000))) + ".bin"
|
|
||||||
|
|
||||||
input := bytes.NewReader(fuzz)
|
|
||||||
err = storage.Put(token, filename, input, applicationOctetStream, fuzzLength)
|
|
||||||
if err != nil {
|
|
||||||
panic("unable to save file")
|
|
||||||
}
|
|
||||||
|
|
||||||
contentLength, err := storage.Head(token, filename)
|
|
||||||
if err != nil {
|
|
||||||
panic("not visible through head")
|
|
||||||
}
|
|
||||||
|
|
||||||
if contentLength != fuzzLength {
|
|
||||||
panic("incorrect content length")
|
|
||||||
}
|
|
||||||
|
|
||||||
output, contentLength, err := storage.Get(token, filename)
|
|
||||||
if err != nil {
|
|
||||||
panic("not visible through get")
|
|
||||||
}
|
|
||||||
|
|
||||||
if contentLength != fuzzLength {
|
|
||||||
panic("incorrect content length")
|
|
||||||
}
|
|
||||||
|
|
||||||
var length uint64
|
|
||||||
b := make([]byte, len(fuzz))
|
|
||||||
for {
|
|
||||||
n, err := output.Read(b)
|
|
||||||
length += uint64(n)
|
|
||||||
if err == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(b, fuzz) {
|
|
||||||
panic("incorrect content body")
|
|
||||||
}
|
|
||||||
|
|
||||||
if length != fuzzLength {
|
|
||||||
panic("incorrect content length")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = storage.Delete(token, filename)
|
|
||||||
if err != nil {
|
|
||||||
panic("unable to delete file")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = storage.Head(token, filename)
|
|
||||||
if !storage.IsNotExist(err) {
|
|
||||||
panic("file not deleted")
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
Loading…
Reference in a new issue