Skip to content

Commit

Permalink
no relative path to parents allowed in tar references
Browse files Browse the repository at this point in the history
  • Loading branch information
wagoodman committed Apr 11, 2018
1 parent e50f5fb commit c30096e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 9 deletions.
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL := /bin/bash
.DEFAULT_GOAL := ci
TARGETS := $(shell ls scripts)
.PHONY: run clean $(TARGETS)
Expand All @@ -6,14 +7,8 @@ $(TARGETS):
./scripts/$@

run:
make build
rm -f 16-bundle-manifest.bundle
rm -rf /tmp/bashful.*
./dist/bashful bundle example/16-bundle-manifest.yml
./16-bundle-manifest.bundle

# go run main.go task.go config.go screen.go download.go log.go \
# run example/16-bundle-manifest.yml
go run main.go task.go config.go screen.go download.go log.go archive.go \
run example/00-demo.yml

examples: clean build
./dist/bashful run example/00-demo.yml
Expand Down
7 changes: 6 additions & 1 deletion archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"archive/tar"
"compress/gzip"
"errors"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -81,14 +82,18 @@ func (archiver *archive) Archive(srcPath string, preservePath bool) error {
fields := strings.Split(srcPath, string(os.PathSeparator))
for idx := range fields {
path := strings.Join(fields[:idx+1], string(os.PathSeparator))
archiver.addTarFile(path, path)
err := archiver.addTarFile(path, path)
checkError(err, "Unable to archive file")
}
}

return err
}

func (archiver *archive) addTarFile(path, name string) error {
if strings.Contains(path, "..") {
return errors.New("Path cannot contain a relative marker of '..': " + path)
}
fi, err := os.Lstat(path)
if err != nil {
return err
Expand Down
66 changes: 66 additions & 0 deletions example/.bashful/downloads/compile-something.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# From: https://codegolf.stackexchange.com/questions/30322/make-it-look-like-im-working

collect()
{
while read line;do
if [ -d "$line" ];then
(for i in "$line"/*;do echo $i;done)|shuf|collect
echo $line
elif [[ "$line" == *".h" ]];then
echo $line
fi
done
}

sse="$(awk '/flags/{print;exit}' </proc/cpuinfo|grep -o 'sse\S*'|sed 's/^/-m/'|xargs)"

flags=""
pd="\\"
count=$1

while true;do
collect <<< /usr/include|cut -d/ -f4-|
(
while read line;do
count=$(($count-1))
if [[ $count -le 0 ]]; then
exit 0
fi
if [ "$(dirname "$line")" != "$pd" ];then
x=$((RANDOM%8-3))
if [[ "$x" != "-"* ]];then
ssef="$(sed 's/\( *\S\S*\)\{'"$x,$x"'\}$//' <<< "$sse")"
fi
pd="$(dirname "$line")"
opt="-O$((RANDOM%4))"
if [[ "$((RANDOM%2))" == 0 ]];then
pipe=-pipe
fi
case $((RANDOM%4)) in
0) arch=-m32;;
1) arch="";;
*) arch=-m64;;
esac
if [[ "$((RANDOM%3))" == 0 ]];then
gnu="-D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L "
fi
flags="gcc -w $(xargs -n1 <<< "opt pipe gnu ssef arch"|shuf|(while read line;do eval echo \$$line;done))"
fi
if [ -d "/usr/include/$line" ];then
echo $flags -shared $(for i in /usr/include/$line/*.h;do cut -d/ -f4- <<< "$i"|sed 's/h$/o/';done) -o "$line"".so"
sleep .$RANDOM
else
line=$(sed 's/h$//' <<< "$line")
echo $flags -c $line"c" -o $line"o"
sleep .1
fi

done
)
count=$(($count-1))
if [[ $count -le 0 ]]; then
exit 0
fi
done

0 comments on commit c30096e

Please sign in to comment.