Fix parsing short env vars
This commit is contained in:
parent
00c68f09db
commit
215639ff94
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,5 +2,6 @@ Cargo.lock
|
||||||
node_modules
|
node_modules
|
||||||
build
|
build
|
||||||
*.log
|
*.log
|
||||||
|
log.html
|
||||||
package-lock.json
|
package-lock.json
|
||||||
target
|
target
|
||||||
|
|
112
corpus/env.txt
112
corpus/env.txt
|
@ -1,93 +1,107 @@
|
||||||
==================
|
================================================================================
|
||||||
Quoted value
|
Quoted value
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST="okay"
|
ENV TEST="okay"
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string))))
|
value: (double_quoted_string))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Unquoted value
|
Unquoted value
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST_2=value\ 2
|
ENV TEST_2=value\ 2
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (unquoted_string))))
|
value: (unquoted_string))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Multiple
|
Multiple
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST="foo" TEST_2=foo\ bar
|
ENV TEST="foo" TEST_2=foo\ bar
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string))
|
value: (double_quoted_string))
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (unquoted_string))))
|
value: (unquoted_string))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Multiline
|
Multiline
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST1="foo" \
|
ENV TEST1="foo" \
|
||||||
TEST2=bar
|
TEST2=bar
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string))
|
value: (double_quoted_string))
|
||||||
(line_continuation)
|
(line_continuation)
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (unquoted_string))))
|
value: (unquoted_string))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Multiple instructions
|
Multiple instructions
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST1="foo"
|
ENV TEST1="foo"
|
||||||
ENV TEST2="bar"
|
ENV TEST2="bar"
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string)))
|
value: (double_quoted_string)))
|
||||||
(env_instruction
|
(env_instruction
|
||||||
(env_pair
|
(env_pair
|
||||||
name: (unquoted_string)
|
name: (unquoted_string)
|
||||||
value: (double_quoted_string))))
|
value: (double_quoted_string))))
|
||||||
|
|
||||||
==================
|
================================================================================
|
||||||
Space syntax
|
Space syntax
|
||||||
==================
|
================================================================================
|
||||||
|
|
||||||
ENV TEST1 foo
|
ENV TEST1 foo
|
||||||
|
|
||||||
---
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(env_instruction
|
||||||
|
(env_pair
|
||||||
|
name: (unquoted_string)
|
||||||
|
value: (unquoted_string))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Space syntax 2
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
ENV TZ America/Toronto
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(env_instruction
|
(env_instruction
|
||||||
|
|
|
@ -92,14 +92,12 @@ Expose
|
||||||
|
|
||||||
EXPOSE $FOO
|
EXPOSE $FOO
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(expose_instruction
|
(expose_instruction
|
||||||
(expose_port
|
(expansion
|
||||||
(expansion
|
(variable))))
|
||||||
(variable)))))
|
|
||||||
|
|
||||||
==================
|
==================
|
||||||
From
|
From
|
||||||
|
|
110
examples/1
Normal file
110
examples/1
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb0a849a393b87d94fb174 as libsqlite3-pcre
|
||||||
|
|
||||||
|
COPY libsqlite3-pcre-install-alpine.sh /libsqlite3-pcre-install-alpine.sh
|
||||||
|
RUN /libsqlite3-pcre-install-alpine.sh
|
||||||
|
|
||||||
|
# Install p4 CLI (keep this up to date with cmd/gitserver/Dockerfile)
|
||||||
|
FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb0a849a393b87d94fb174 AS p4cli
|
||||||
|
|
||||||
|
# hadolint ignore=DL3003
|
||||||
|
RUN wget http://cdist2.perforce.com/perforce/r20.1/bin.linux26x86_64/p4 && \
|
||||||
|
mv p4 /usr/local/bin/p4 && \
|
||||||
|
chmod +x /usr/local/bin/p4
|
||||||
|
|
||||||
|
FROM sourcegraph/alpine:3.12@sha256:ce099fbcd3cf70b338fc4cb2a4e1fa9ae847de21afdb0a849a393b87d94fb174
|
||||||
|
# TODO(security): This container should not be running as root!
|
||||||
|
#
|
||||||
|
# The default user in sourcegraph/alpine is a non-root `sourcegraph` user but because old deployments
|
||||||
|
# cannot be easily migrated we have not changed this from root -> sourcegraph. See:
|
||||||
|
# https://github.com/sourcegraph/sourcegraph/issues/13238
|
||||||
|
# hadolint ignore=DL3002
|
||||||
|
USER root
|
||||||
|
|
||||||
|
ARG COMMIT_SHA="unknown$TEST"
|
||||||
|
ARG DATE="unknown"
|
||||||
|
ARG VERSION="unknown"
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
|
||||||
|
LABEL org.opencontainers.image.created=${DATE}
|
||||||
|
LABEL org.opencontainers.image.version=${VERSION}
|
||||||
|
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
|
||||||
|
|
||||||
|
# hadolint ignore=DL3018
|
||||||
|
RUN apk update && apk add --no-cache \
|
||||||
|
# NOTE that the Postgres version we run is different
|
||||||
|
# from our *Minimum Supported Version* which alone dictates
|
||||||
|
# the features we can depend on. See this link for more information:
|
||||||
|
# https://github.com/sourcegraph/sourcegraph/blob/main/doc/dev/postgresql.md#version-requirements
|
||||||
|
'bash=5.0.17-r0' \
|
||||||
|
'redis=5.0.11-r0' \
|
||||||
|
# Gitserver requires Git protocol v2 https://github.com/sourcegraph/sourcegraph/issues/13168
|
||||||
|
'git>=2.18' \
|
||||||
|
git-p4 \
|
||||||
|
python2 \
|
||||||
|
'nginx>=1.18.0' openssh-client pcre sqlite-libs su-exec 'nodejs-current=14.5.0-r0' \
|
||||||
|
postgresql=12.6-r0 \
|
||||||
|
postgresql-contrib
|
||||||
|
|
||||||
|
# IMPORTANT: If you update the syntect_server version below, you MUST confirm
|
||||||
|
# the ENV variables from its Dockerfile (https://github.com/sourcegraph/syntect_server/blob/master/Dockerfile)
|
||||||
|
# have been appropriately set in cmd/server/shared/shared.go.
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=comby/comby:0.18.4@sha256:b47ce282778bfea7f80d45f5ef0cc546ba0d6347baccebaf171a7866143b2593 /usr/local/bin/comby /usr/local/bin/comby
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/syntect_server:dd97058@sha256:d7163842f41388f41d19ce04833ac5f6d4e41d212869e7d2aea9c38ba6e77261 /syntect_server /usr/local/bin/
|
||||||
|
|
||||||
|
|
||||||
|
# install minio (keep this up to date with docker-images/minio/Dockerfile)
|
||||||
|
ENV MINIO_VERSION=RELEASE.2021-04-22T15-44-28Z
|
||||||
|
RUN wget "https://dl.min.io/server/minio/release/linux-amd64/archive/minio.$MINIO_VERSION" && \
|
||||||
|
chmod +x "minio.$MINIO_VERSION" && \
|
||||||
|
mv "minio.$MINIO_VERSION" /usr/local/bin/minio
|
||||||
|
|
||||||
|
COPY ctags-install-alpine.sh /ctags-install-alpine.sh
|
||||||
|
RUN /ctags-install-alpine.sh
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /bin/prom-wrapper /bin
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /bin/alertmanager /bin
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /alertmanager.sh /alertmanager.sh
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /bin/prometheus /bin
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /prometheus.sh /prometheus.sh
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/prometheus:server /usr/share/prometheus /usr/share/prometheus
|
||||||
|
|
||||||
|
# hadolint ignore=DL3018
|
||||||
|
RUN set -ex && \
|
||||||
|
addgroup -S grafana && \
|
||||||
|
adduser -S -G grafana grafana && \
|
||||||
|
apk add --no-cache libc6-compat ca-certificates su-exec
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/grafana:server /usr/share/grafana /usr/share/grafana
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=libsqlite3-pcre /sqlite3-pcre/pcre.so /libsqlite3-pcre.so
|
||||||
|
ENV LIBSQLITE3_PCRE /libsqlite3-pcre.so
|
||||||
|
COPY . /
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=p4cli /usr/local/bin/p4 /usr/local/bin/p4
|
||||||
|
|
||||||
|
# This is a trick to include libraries required by p4,
|
||||||
|
# please refer to https://blog.tilander.org/docker-perforce/
|
||||||
|
ADD https://github.com/jtilander/p4d/raw/4600d741720f85d77852dcca7c182e96ad613358/lib/lib-x64.tgz /
|
||||||
|
RUN tar zxf /lib-x64.tgz --directory /
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/grafana:server /sg_config_grafana/provisioning/dashboards /sg_config_grafana/provisioning/dashboards
|
||||||
|
|
||||||
|
# hadolint ignore=DL3022
|
||||||
|
COPY --from=sourcegraph/postgres_exporter:server /usr/local/bin/postgres_exporter /usr/local/bin/postgres_exporter
|
||||||
|
|
||||||
|
RUN echo "hosts: files dns" > /etc/nsswitch.conf
|
||||||
|
|
||||||
|
ENV GO111MODULES=on LANG=en_US.utf8
|
||||||
|
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/server"]
|
43
examples/2
Normal file
43
examples/2
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Downloaded from https://sourcegraph.com/github.com/0b01/tectonicdb/-/blob/Dockerfile?subtree=true#L40
|
||||||
|
# Copied from https://github.com/emk/rust-musl-builder/blob/master/examples/using-diesel/Dockerfile
|
||||||
|
FROM ekidd/rust-musl-builder:nightly AS builder
|
||||||
|
|
||||||
|
# Add the source code.
|
||||||
|
ADD . ./
|
||||||
|
|
||||||
|
# Fix permissions on source code.
|
||||||
|
RUN sudo chown -R rust:rust /home/rust
|
||||||
|
|
||||||
|
# Delete and re-install rustup in order to get the latest verison of Rust nightly.
|
||||||
|
# This is necessary due to a bug in Rust: https://github.com/rust-lang-nursery/rustup.rs/issues/1239
|
||||||
|
RUN rm -rf ~/.rustup
|
||||||
|
RUN curl https://sh.rustup.rs -sSf | \
|
||||||
|
sh -s -- -y && \
|
||||||
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
|
WORKDIR ~
|
||||||
|
|
||||||
|
# Build the `tdb-server` application.
|
||||||
|
RUN PKG_CONFIG_PATH=/usr/local/musl/lib/pkgconfig \
|
||||||
|
LDFLAGS=-L/usr/local/musl/lib \
|
||||||
|
cargo build --bin tdb-server --target x86_64-unknown-linux-musl --release
|
||||||
|
|
||||||
|
# Build the `tdb` application.
|
||||||
|
RUN PKG_CONFIG_PATH=/usr/local/musl/lib/pkgconfig \
|
||||||
|
LDFLAGS=-L/usr/local/musl/lib \
|
||||||
|
cargo build --bin tdb --target x86_64-unknown-linux-musl --release
|
||||||
|
|
||||||
|
# Now, we need to build the _real_ Docker container, copying in `tdb-server`
|
||||||
|
FROM alpine:latest
|
||||||
|
RUN apk --no-cache add ca-certificates && update-ca-certificates
|
||||||
|
ENV IMAGE_NAME=tectonicdb
|
||||||
|
COPY --from=builder \
|
||||||
|
/home/rust/src/target/x86_64-unknown-linux-musl/release/tdb-server \
|
||||||
|
/usr/local/bin/
|
||||||
|
|
||||||
|
COPY --from=builder \
|
||||||
|
/home/rust/src/target/x86_64-unknown-linux-musl/release/tdb \
|
||||||
|
/usr/local/bin/
|
||||||
|
|
||||||
|
# Initialize the application
|
||||||
|
CMD /usr/local/bin/tdb-server -vv
|
11
examples/3
Normal file
11
examples/3
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:8.5
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ADD ./package.json .
|
||||||
|
ADD ./package-lock.json .
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
CMD npm run start
|
177
examples/4
Normal file
177
examples/4
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
# VERSION 0.3.0
|
||||||
|
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
MAINTAINER Shane Frasier <jeremy.frasier@trio.dhs.gov>
|
||||||
|
|
||||||
|
###
|
||||||
|
# Dependencies
|
||||||
|
###
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get update \
|
||||||
|
-qq \
|
||||||
|
&& apt-get install \
|
||||||
|
-qq \
|
||||||
|
--yes \
|
||||||
|
--no-install-recommends \
|
||||||
|
--no-install-suggests \
|
||||||
|
apt-utils \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
libc6-dev \
|
||||||
|
libfontconfig1 \
|
||||||
|
libreadline-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libssl-doc \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt1-dev \
|
||||||
|
libyaml-dev \
|
||||||
|
make \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
zlib1g-dev \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
bison \
|
||||||
|
gawk \
|
||||||
|
libffi-dev \
|
||||||
|
libgdbm-dev \
|
||||||
|
libncurses5-dev \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libtool \
|
||||||
|
pkg-config \
|
||||||
|
sqlite3 \
|
||||||
|
# Additional dependencies for python-build
|
||||||
|
libbz2-dev \
|
||||||
|
llvm \
|
||||||
|
libncursesw5-dev \
|
||||||
|
# Additional dependencies for third-parties scanner
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
# Additional dependencies for a11y scanner
|
||||||
|
net-tools \
|
||||||
|
# Chrome dependencies
|
||||||
|
fonts-liberation \
|
||||||
|
libappindicator3-1 \
|
||||||
|
libasound2 \
|
||||||
|
libatk-bridge2.0-0 \
|
||||||
|
libgtk-3-0 \
|
||||||
|
libnspr4 \
|
||||||
|
libnss3 \
|
||||||
|
libxss1 \
|
||||||
|
libxtst6 \
|
||||||
|
lsb-release \
|
||||||
|
xdg-utils
|
||||||
|
|
||||||
|
RUN apt-get install -qq --yes locales && locale-gen en_US.UTF-8
|
||||||
|
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
|
###
|
||||||
|
# Google Chrome
|
||||||
|
###
|
||||||
|
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
|
||||||
|
&& dpkg -i google-chrome-stable_current_amd64.deb \
|
||||||
|
&& rm google-chrome-stable_current_amd64.deb
|
||||||
|
# The third-parties scanner looks for an executable called chrome
|
||||||
|
RUN ln -s /usr/bin/google-chrome-stable /usr/bin/chrome
|
||||||
|
|
||||||
|
###
|
||||||
|
## Python
|
||||||
|
###
|
||||||
|
ENV PYENV_RELEASE=1.2.2 PYENV_PYTHON_VERSION=3.6.4 PYENV_ROOT=/opt/pyenv \
|
||||||
|
PYENV_REPO=https://github.com/pyenv/pyenv
|
||||||
|
|
||||||
|
RUN wget ${PYENV_REPO}/archive/v${PYENV_RELEASE}.zip \
|
||||||
|
--no-verbose \
|
||||||
|
&& unzip v$PYENV_RELEASE.zip -d $PYENV_ROOT \
|
||||||
|
&& mv $PYENV_ROOT/pyenv-$PYENV_RELEASE/* $PYENV_ROOT/ \
|
||||||
|
&& rm -r $PYENV_ROOT/pyenv-$PYENV_RELEASE
|
||||||
|
|
||||||
|
#
|
||||||
|
# Uncomment these lines if you just want to install python...
|
||||||
|
#
|
||||||
|
ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/versions/${PYENV_PYTHON_VERSION}/bin:$PATH
|
||||||
|
RUN echo 'eval "$(pyenv init -)"' >> /etc/profile \
|
||||||
|
&& eval "$(pyenv init -)" \
|
||||||
|
&& pyenv install $PYENV_PYTHON_VERSION \
|
||||||
|
&& pyenv local ${PYENV_PYTHON_VERSION}
|
||||||
|
|
||||||
|
#
|
||||||
|
# ...uncomment these lines if you want to also debug python code in GDB
|
||||||
|
#
|
||||||
|
# ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/versions/${PYENV_PYTHON_VERSION}-debug/bin:$PATH
|
||||||
|
# RUN echo 'eval "$(pyenv init -)"' >> /etc/profile \
|
||||||
|
# && eval "$(pyenv init -)" \
|
||||||
|
# && pyenv install --debug --keep $PYENV_PYTHON_VERSION \
|
||||||
|
# && pyenv local ${PYENV_PYTHON_VERSION}-debug
|
||||||
|
# RUN ln -s /opt/pyenv/sources/${PYENV_PYTHON_VERSION}-debug/Python-${PYENV_PYTHON_VERSION}/python-gdb.py \
|
||||||
|
# /opt/pyenv/versions/${PYENV_PYTHON_VERSION}-debug/bin/python3.6-gdb.py \
|
||||||
|
# && ln -s /opt/pyenv/sources/${PYENV_PYTHON_VERSION}-debug/Python-${PYENV_PYTHON_VERSION}/python-gdb.py \
|
||||||
|
# /opt/pyenv/versions/${PYENV_PYTHON_VERSION}-debug/bin/python3-gdb.py \
|
||||||
|
# && ln -s /opt/pyenv/sources/${PYENV_PYTHON_VERSION}-debug/Python-${PYENV_PYTHON_VERSION}/python-gdb.py \
|
||||||
|
# /opt/pyenv/versions/${PYENV_PYTHON_VERSION}-debug/bin/python-gdb.py
|
||||||
|
# RUN apt-get -qq --yes --no-install-recommends --no-install-suggests install gdb
|
||||||
|
# RUN echo add-auto-load-safe-path \
|
||||||
|
# /opt/pyenv/sources/${PYENV_PYTHON_VERSION}-debug/Python-${PYENV_PYTHON_VERSION}/ \
|
||||||
|
# >> etc/gdb/gdbinit
|
||||||
|
|
||||||
|
###
|
||||||
|
# Update pip and setuptools to the latest versions
|
||||||
|
###
|
||||||
|
RUN pip install --upgrade pip setuptools
|
||||||
|
|
||||||
|
###
|
||||||
|
# Node
|
||||||
|
###
|
||||||
|
# RUN ln -s /usr/bin/nodejs /usr/bin/node
|
||||||
|
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
|
||||||
|
RUN apt-get install -y nodejs
|
||||||
|
|
||||||
|
###
|
||||||
|
## pa11y
|
||||||
|
###
|
||||||
|
|
||||||
|
RUN wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
|
||||||
|
&& tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/ \
|
||||||
|
&& ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
|
||||||
|
RUN npm install --global pa11y@4.13.2 --ignore-scripts
|
||||||
|
|
||||||
|
###
|
||||||
|
## third_parties
|
||||||
|
###
|
||||||
|
|
||||||
|
RUN npm install puppeteer
|
||||||
|
|
||||||
|
###
|
||||||
|
# Create unprivileged User
|
||||||
|
###
|
||||||
|
ENV SCANNER_HOME /home/scanner
|
||||||
|
RUN mkdir $SCANNER_HOME \
|
||||||
|
&& groupadd -r scanner \
|
||||||
|
&& useradd -r -c "Scanner user" -g scanner scanner \
|
||||||
|
&& chown -R scanner:scanner ${SCANNER_HOME}
|
||||||
|
|
||||||
|
###
|
||||||
|
# Prepare to Run
|
||||||
|
###
|
||||||
|
WORKDIR $SCANNER_HOME
|
||||||
|
|
||||||
|
# Volume mount for use with the 'data' option.
|
||||||
|
VOLUME /data
|
||||||
|
|
||||||
|
COPY . $SCANNER_HOME
|
||||||
|
|
||||||
|
###
|
||||||
|
# domain-scan
|
||||||
|
###
|
||||||
|
RUN pip install --upgrade \
|
||||||
|
-r requirements.txt \
|
||||||
|
-r requirements-gatherers.txt \
|
||||||
|
-r requirements-scanners.txt
|
||||||
|
|
||||||
|
# Clean up aptitude stuff we no longer need
|
||||||
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENTRYPOINT ["./scan_wrap.sh"]
|
54
examples/5
Normal file
54
examples/5
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
FROM registry.cn-beijing.aliyuncs.com/acs-sample/jenkins-kubernetes-slave-dind:1.0
|
||||||
|
|
||||||
|
MAINTAINER Ringtail <zhongwei.lzw@alibaba-inc.com>
|
||||||
|
|
||||||
|
# gcc for cgo
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
libc6-dev \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV GOLANG_VERSION 1.8.5
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
\
|
||||||
|
# this "case" statement is generated via "update.sh"
|
||||||
|
dpkgArch="$(dpkg --print-architecture)"; \
|
||||||
|
case "${dpkgArch##*-}" in \
|
||||||
|
amd64) goRelArch='linux-amd64'; goRelSha256='4f8aeea2033a2d731f2f75c4d0a4995b357b22af56ed69b3015f4291fca4d42d' ;; \
|
||||||
|
armhf) goRelArch='linux-armv6l'; goRelSha256='f5c58e7fd6cdfcc40b94c6655cf159b25836dffe13431f683b51705b8a67d608' ;; \
|
||||||
|
arm64) goRelArch='linux-arm64'; goRelSha256='6c552ae1e77c52944e0f9b9034761bd3dcc3fef57dad6d751a53638783b07d2c' ;; \
|
||||||
|
i386) goRelArch='linux-386'; goRelSha256='cf959b60b89acb588843ff985ecb47a7f6c37da6e4987739ab4aafad7211464f' ;; \
|
||||||
|
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='1ee0874ce8c8625e14b4457a4861777be78f30067d914bcb264f7e0331d087de' ;; \
|
||||||
|
s390x) goRelArch='linux-s390x'; goRelSha256='e978a56842297dc8924555540314ff09128e9a62da9881c3a26771ddd5d7ebc2' ;; \
|
||||||
|
*) goRelArch='src'; goRelSha256='4949fd1a5a4954eb54dd208f2f412e720e23f32c91203116bed0387cf5d0ff2d'; \
|
||||||
|
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
|
||||||
|
esac; \
|
||||||
|
\
|
||||||
|
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
|
||||||
|
wget -O go.tgz "$url"; \
|
||||||
|
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
|
||||||
|
tar -C /usr/local -xzf go.tgz; \
|
||||||
|
rm go.tgz; \
|
||||||
|
\
|
||||||
|
if [ "$goRelArch" = 'src' ]; then \
|
||||||
|
echo >&2; \
|
||||||
|
echo >&2 'error: UNIMPLEMENTED'; \
|
||||||
|
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
|
||||||
|
echo >&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
\
|
||||||
|
export PATH="/usr/local/go/bin:$PATH"; \
|
||||||
|
go version
|
||||||
|
|
||||||
|
ENV GOPATH /go
|
||||||
|
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
||||||
|
|
||||||
|
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
||||||
|
WORKDIR $GOPATH
|
||||||
|
|
||||||
|
COPY go-wrapper /usr/local/bin/
|
14
examples/6
Normal file
14
examples/6
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
FROM node:12.13.1
|
||||||
|
WORKDIR /home/node
|
||||||
|
COPY . /home/node
|
||||||
|
|
||||||
|
# Install Kompose
|
||||||
|
RUN curl -L https://github.com/kubernetes/kompose/releases/download/v1.21.0/kompose-linux-amd64 -o kompose
|
||||||
|
RUN chmod +x kompose
|
||||||
|
RUN mv ./kompose /usr/local/bin/kompose
|
||||||
|
|
||||||
|
# Set environment varibles
|
||||||
|
ENV TZ America/Toronto
|
||||||
|
|
||||||
|
CMD ["/bin/sh", "entrypoint.sh"]
|
||||||
|
|
39
grammar.js
39
grammar.js
|
@ -1,7 +1,11 @@
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: 'dockerfile',
|
name: 'dockerfile',
|
||||||
|
|
||||||
extras: $ => [$.comment, /\s+/, '\\\n'],
|
extras: $ => [
|
||||||
|
$.comment,
|
||||||
|
/\s+/,
|
||||||
|
'\\\n'
|
||||||
|
],
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
source_file: $ => repeat(seq($._instruction, "\n")),
|
source_file: $ => repeat(seq($._instruction, "\n")),
|
||||||
|
@ -64,8 +68,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
expose_instruction: $ => seq(
|
expose_instruction: $ => seq(
|
||||||
alias(/[eE][xX][pP][oO][sS][eE]/, "EXPOSE"),
|
alias(/[eE][xX][pP][oO][sS][eE]/, "EXPOSE"),
|
||||||
$._non_newline_whitespace,
|
repeat1(choice($.expose_port, $.expansion)),
|
||||||
repeat1($.expose_port),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
env_instruction: $ => seq(
|
env_instruction: $ => seq(
|
||||||
|
@ -192,28 +195,27 @@ module.exports = grammar({
|
||||||
|
|
||||||
path: $ => seq(
|
path: $ => seq(
|
||||||
choice(
|
choice(
|
||||||
/[^-\s]/, // cannot start with a '-' to avoid conflicts with params
|
/[^-\s\$]/, // cannot start with a '-' to avoid conflicts with params
|
||||||
$.expansion,
|
$.expansion,
|
||||||
),
|
),
|
||||||
repeat(choice(
|
repeat(choice(
|
||||||
token.immediate(/[^\s\$]+/),
|
/[^\s\$]+/,
|
||||||
$.expansion,
|
$.expansion,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
||||||
expansion: $ => seq(
|
expansion: $ => seq(
|
||||||
token.immediate('$'),
|
'$',
|
||||||
choice(
|
choice(
|
||||||
$.variable,
|
$.variable,
|
||||||
seq('{', alias(/[^\}]+/, $.variable), '}'),
|
seq('{', alias(/[^\}]+/, $.variable), '}'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
variable: $ => token.immediate(/[a-zA-Z][a-zA-Z0-9_]*/),
|
variable: $ => /[a-zA-Z][a-zA-Z0-9_]*/,
|
||||||
|
|
||||||
|
|
||||||
env_pair: $ => seq(
|
env_pair: $ => seq(
|
||||||
field("name", alias(/[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]/, $.unquoted_string)),
|
field("name", $._env_key),
|
||||||
token.immediate("="),
|
token.immediate("="),
|
||||||
field("value", choice(
|
field("value", choice(
|
||||||
$.double_quoted_string,
|
$.double_quoted_string,
|
||||||
|
@ -222,7 +224,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
_spaced_env_pair: $ => seq(
|
_spaced_env_pair: $ => seq(
|
||||||
field("name", alias(/[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]/, $.unquoted_string)),
|
field("name", $._env_key),
|
||||||
token.immediate(/\s+/),
|
token.immediate(/\s+/),
|
||||||
field("value", choice(
|
field("value", choice(
|
||||||
$.double_quoted_string,
|
$.double_quoted_string,
|
||||||
|
@ -230,15 +232,14 @@ module.exports = grammar({
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
||||||
expose_port: $ => choice(
|
_env_key: $ => alias(/[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]/, $.unquoted_string),
|
||||||
seq(
|
|
||||||
/\d+/,
|
expose_port: $ => seq(
|
||||||
optional(choice(
|
/\d+/,
|
||||||
"/tcp",
|
optional(choice(
|
||||||
"/udp",
|
"/tcp",
|
||||||
)),
|
"/udp",
|
||||||
),
|
)),
|
||||||
$.expansion,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
label_pair: $ => seq(
|
label_pair: $ => seq(
|
||||||
|
|
102
src/grammar.json
102
src/grammar.json
|
@ -257,15 +257,20 @@
|
||||||
"named": false,
|
"named": false,
|
||||||
"value": "EXPOSE"
|
"value": "EXPOSE"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_non_newline_whitespace"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "CHOICE",
|
||||||
"name": "expose_port"
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expose_port"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expansion"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -800,7 +805,7 @@
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[^-\\s]"
|
"value": "[^-\\s\\$]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
@ -814,11 +819,8 @@
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "IMMEDIATE_TOKEN",
|
"type": "PATTERN",
|
||||||
"content": {
|
"value": "[^\\s\\$]+"
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[^\\s\\$]+"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
@ -833,11 +835,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "IMMEDIATE_TOKEN",
|
"type": "STRING",
|
||||||
"content": {
|
"value": "$"
|
||||||
"type": "STRING",
|
|
||||||
"value": "$"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
@ -873,11 +872,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"variable": {
|
"variable": {
|
||||||
"type": "IMMEDIATE_TOKEN",
|
"type": "PATTERN",
|
||||||
"content": {
|
"value": "[a-zA-Z][a-zA-Z0-9_]*"
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[a-zA-Z][a-zA-Z0-9_]*"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"env_pair": {
|
"env_pair": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
@ -886,13 +882,8 @@
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "ALIAS",
|
"type": "SYMBOL",
|
||||||
"content": {
|
"name": "_env_key"
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]"
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "unquoted_string"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -928,13 +919,8 @@
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "ALIAS",
|
"type": "SYMBOL",
|
||||||
"content": {
|
"name": "_env_key"
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9]"
|
|
||||||
},
|
|
||||||
"named": true,
|
|
||||||
"value": "unquoted_string"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -963,42 +949,42 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"_env_key": {
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]"
|
||||||
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "unquoted_string"
|
||||||
|
},
|
||||||
"expose_port": {
|
"expose_port": {
|
||||||
"type": "CHOICE",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SEQ",
|
"type": "PATTERN",
|
||||||
|
"value": "\\d+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "\\d+"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "STRING",
|
||||||
"members": [
|
"value": "/tcp"
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "/tcp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "/udp"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "STRING",
|
||||||
|
"value": "/udp"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "expansion"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -197,6 +197,10 @@
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "expansion",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "expose_port",
|
"type": "expose_port",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -207,17 +211,7 @@
|
||||||
{
|
{
|
||||||
"type": "expose_port",
|
"type": "expose_port",
|
||||||
"named": true,
|
"named": true,
|
||||||
"fields": {},
|
"fields": {}
|
||||||
"children": {
|
|
||||||
"multiple": false,
|
|
||||||
"required": false,
|
|
||||||
"types": [
|
|
||||||
{
|
|
||||||
"type": "expansion",
|
|
||||||
"named": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "from_instruction",
|
"type": "from_instruction",
|
||||||
|
|
8671
src/parser.c
8671
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue