Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/syz-env: add local build option and consider HTTP proxy environment variables #5386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ docker pull docker.pkg.github.com/google/syzkaller/env
docker tag docker.pkg.github.com/google/syzkaller/env gcr.io/syzkaller/env
```

You can also build the container from the respective `Dockerfile` by setting the `SYZ_ENV_BUILD` environment variable, i.e.:
```
SYZ_ENV_BUILD=1 syz-env
```
This can be useful to test local changes that have not been pushed to the registry yet.

### Using [act](https://github.com/nektos/act)
.github/workflows has more tests compared to `syz-env make presubmit`. To have the same tests as the workflow, we can run these workflow jobs locally.
```
Expand Down
28 changes: 24 additions & 4 deletions tools/syz-env
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,21 @@
# (Googlers see go/docker).

COMMAND=""
BUILDARGS=()
DOCKERARGS=()
[ -n $https_proxy ] && DOCKERARGS+=" --env https_proxy=$https_proxy"
if [ -n $http_proxy ]; then
BUILDARGS+=" --build-arg http_proxy=$http_proxy"
DOCKERARGS+=" --env http_proxy=$http_proxy"
fi
if [ -n $https_proxy ]; then
BUILDARGS+=" --build-arg https_proxy=$https_proxy"
DOCKERARGS+=" --env https_proxy=$https_proxy"
fi
if [ -n $no_proxy ]; then
BUILDARGS+=" --build-arg no_proxy=$no_proxy"
DOCKERARGS+=" --env no_proxy=$no_proxy"
fi

for ARG in "$@"; do
while IFS='=' read KEY VAL; do
# If we have a kernel path passed in, we mount it in the container
Expand Down Expand Up @@ -62,8 +75,15 @@ if [ ! "$(docker info -f "{{println .SecurityOptions}}" | grep rootless)" ]; the
DOCKERARGS+=" --user $(id -u ${USER}):$(id -g ${USER})"
fi

# Update docker image
docker pull -q gcr.io/syzkaller/${IMAGE}

# Build or update docker image
if [ ! -z "$SYZ_ENV_BUILD" ]; then
IMAGE_NAME="syz-$IMAGE"
docker build "tools/docker/$IMAGE" --tag "$IMAGE_NAME" ${BUILDARGS[@]}
else
IMAGE_NAME="gcr.io/syzkaller/$IMAGE"
docker pull -q "$IMAGE_NAME"
fi

# Run everything as the host user, this is important for created/modified files.
docker run \
Expand All @@ -82,4 +102,4 @@ docker run \
--env GITHUB_PR_COMMITS \
--env CI \
${DOCKERARGS[@]} \
gcr.io/syzkaller/${IMAGE} -c "$COMMAND"
"$IMAGE_NAME" -c "$COMMAND"