Skip to content

Commit e568580

Browse files
authored
Merge pull request #3 from cisagov/first-commits
Initial Functionality
2 parents f3f257e + 94011c3 commit e568580

14 files changed

+661
-142
lines changed

.github/lineage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version: "1"
33

44
lineage:
55
skeleton:
6-
remote-url: https://github.com/cisagov/skeleton-generic.git
6+
remote-url: https://github.com/cisagov/skeleton-docker.git

.github/workflows/build.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ on:
2626

2727
env:
2828
BUILDX_CACHE_DIR: ~/.cache/buildx
29-
IMAGE_NAME: cisagov/example
29+
IMAGE_NAME: cisagov/vdp-scanner
3030
PIP_CACHE_DIR: ~/.cache/pip
31-
PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,\
32-
linux/arm64,linux/ppc64le,linux/s390x"
31+
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64"
3332
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
3433

3534
jobs:

.isort.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ import_heading_stdlib=Standard Python Libraries
66
import_heading_thirdparty=Third-Party Libraries
77
import_heading_firstparty=cisagov Libraries
88

9+
known_first_party=hash_http_content
10+
911
# Run isort under the black profile to align with our other Python linting
1012
profile=black

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ all of which should be in this repository.
1515

1616
If you want to report a bug or request a new feature, the most direct
1717
method is to [create an
18-
issue](https://github.com/cisagov/skeleton-docker/issues) in this
18+
issue](https://github.com/cisagov/vdp-scanner-docker/issues) in this
1919
repository. We recommend that you first search through existing
2020
issues (both open and closed) to check if your particular issue has
2121
already been reported. If it has then you might want to add a comment
@@ -25,7 +25,7 @@ one.
2525
## Pull requests ##
2626

2727
If you choose to [submit a pull
28-
request](https://github.com/cisagov/skeleton-docker/pulls), you will
28+
request](https://github.com/cisagov/vdp-scanner-docker/pulls), you will
2929
notice that our continuous integration (CI) system runs a fairly
3030
extensive set of linters and syntax checkers. Your pull request may
3131
fail these checks, and that's OK. If you want you can stop there and
@@ -111,9 +111,9 @@ can create and configure the Python virtual environment with these
111111
commands:
112112

113113
```console
114-
cd skeleton-docker
115-
pyenv virtualenv <python_version_to_use> skeleton-docker
116-
pyenv local skeleton-docker
114+
cd vdp-scanner-docker
115+
pyenv virtualenv <python_version_to_use> vdp-scanner-docker
116+
pyenv local vdp-scanner-docker
117117
pip install --requirement requirements-dev.txt
118118
```
119119

Dockerfile

+64-25
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,77 @@
1-
ARG VERSION=unspecified
1+
ARG PY_VERSION=3.9
22

3-
FROM python:3.9-alpine
4-
5-
ARG VERSION
3+
FROM python:${PY_VERSION} AS compile-stage
64

75
# For a list of pre-defined annotation keys and value types see:
86
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
97
# Note: Additional labels are added by the build workflow.
10-
LABEL org.opencontainers.image.authors="mark.feldhousen@cisa.dhs.gov"
8+
LABEL org.opencontainers.image.authors="nicholas.mcdonnell@cisa.dhs.gov"
119
LABEL org.opencontainers.image.vendor="Cyber and Infrastructure Security Agency"
1210

13-
ARG CISA_UID=421
14-
ENV CISA_HOME="/home/cisa"
15-
ENV ECHO_MESSAGE="Hello World from Dockerfile"
11+
RUN apt-get update \
12+
&& apt-get install -y --allow-downgrades --no-install-recommends \
13+
libxml2-dev=2.9.4+dfsg1-7+deb10u1 \
14+
libxslt1-dev=1.1.32-2.2~deb10u1
15+
16+
ENV PY_VENV=/.venv
17+
18+
# Manually set up the virtual environment
19+
RUN python -m venv --system-site-packages ${PY_VENV}
20+
ENV PATH="${PY_VENV}/bin:$PATH"
21+
22+
# Install core Python dependencies
23+
RUN python -m pip install --no-cache-dir \
24+
pip==21.0.1 \
25+
pipenv==2020.11.15 \
26+
setuptools==53.0.0 \
27+
wheel==0.36.2
28+
29+
# Install vdp_scanner.py requirements
30+
COPY src/Pipfile Pipfile
31+
COPY src/Pipfile.lock Pipfile.lock
32+
# PIPENV_VENV_IN_PROJECT=1 directs pipenv to use the current directory for venvs
33+
RUN PIPENV_VENV_IN_PROJECT=1 pipenv sync
34+
35+
# We only need pipenv to set up the environment, so we remove it from the venv
36+
# as a last step.
37+
RUN python -m pip uninstall --yes pipenv
38+
39+
FROM python:${PY_VERSION}-slim AS build-stage
40+
41+
ARG SERVERLESS_CHROME_VERSION="v1.0.0-57"
42+
ARG SERVERLESS_CHROME_LOCAL="/usr/local/bin/serverless-chrome"
43+
44+
RUN apt-get update \
45+
&& apt-get install -y --allow-downgrades --no-install-recommends \
46+
ca-certificates=20200601~deb10u2 \
47+
chromium-common=88.0.4324.182-1~deb10u1 \
48+
curl=7.64.0-4+deb10u2 \
49+
libnss3=2:3.42.1-1+deb10u3 \
50+
libxml2-dev=2.9.4+dfsg1-7+deb10u1 \
51+
libxslt1-dev=1.1.32-2.2~deb10u1 \
52+
openssl=1.1.1d-0+deb10u6 \
53+
&& apt-get clean \
54+
&& rm -rf /var/lib/apt/lists/*
1655

17-
RUN addgroup --system --gid ${CISA_UID} cisa \
18-
&& adduser --system --uid ${CISA_UID} --ingroup cisa cisa
56+
# Download the specified serverless chrome release and install it for use
57+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
58+
# Follow redirects and output as the specified file name
59+
RUN curl -L \
60+
https://github.com/adieuadieu/serverless-chrome/releases/download/${SERVERLESS_CHROME_VERSION}/stable-headless-chromium-amazonlinux-2.zip \
61+
| gunzip --stdout - > ${SERVERLESS_CHROME_LOCAL}
62+
RUN chmod 755 ${SERVERLESS_CHROME_LOCAL}
1963

20-
RUN apk --update --no-cache add \
21-
ca-certificates \
22-
openssl \
23-
py-pip
64+
ENV PY_VENV=/.venv
65+
COPY --from=compile-stage ${PY_VENV} ${PY_VENV}
66+
ENV PATH="${PY_VENV}/bin:$PATH"
2467

25-
WORKDIR ${CISA_HOME}
68+
ENV TASK_HOME="/task"
2669

27-
RUN wget -O sourcecode.tgz https://github.com/cisagov/skeleton-python-library/archive/v${VERSION}.tar.gz && \
28-
tar xzf sourcecode.tgz --strip-components=1 && \
29-
pip install --requirement requirements.txt && \
30-
ln -snf /run/secrets/quote.txt src/example/data/secret.txt && \
31-
rm sourcecode.tgz
70+
WORKDIR ${TASK_HOME}
71+
RUN mkdir host_mount
3272

33-
USER cisa
73+
COPY src/version.txt version.txt
74+
COPY src/vdp_scanner.py vdp_scanner.py
3475

35-
EXPOSE 8080/TCP
36-
VOLUME ["/var/log"]
37-
ENTRYPOINT ["example"]
38-
CMD ["--log-level", "DEBUG"]
76+
ENTRYPOINT ["python", "vdp_scanner.py"]
77+
CMD ["github"]

README.md

+33-49
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,56 @@
1-
# skeleton-docker 💀🐳 #
1+
# vdp-scanner-docker 🔍📄 #
22

3-
[![GitHub Build Status](https://github.com/cisagov/skeleton-docker/workflows/build/badge.svg)](https://github.com/cisagov/skeleton-docker/actions)
4-
[![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/skeleton-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-docker/alerts/)
5-
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/skeleton-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/skeleton-docker/context:python)
3+
[![GitHub Build Status](https://github.com/cisagov/vdp-scanner-docker/workflows/build/badge.svg)](https://github.com/cisagov/vdp-scanner-docker/actions)
4+
[![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/vdp-scanner-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/vdp-scanner-docker/alerts/)
5+
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/vdp-scanner-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/vdp-scanner-docker/context:python)
66

77
## Docker Image ##
88

9-
[![Docker Pulls](https://img.shields.io/docker/pulls/cisagov/example)](https://hub.docker.com/r/cisagov/example)
10-
[![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/cisagov/example)](https://hub.docker.com/r/cisagov/example)
11-
[![Platforms](https://img.shields.io/badge/platforms-amd64%20%7C%20arm%2Fv6%20%7C%20arm%2Fv7%20%7C%20arm64%20%7C%20ppc64le%20%7C%20s390x-blue)](https://hub.docker.com/r/cisagov/skeleton-docker/tags)
9+
[![Docker Pulls](https://img.shields.io/docker/pulls/cisagov/vdp-scanner-docker)](https://hub.docker.com/r/cisagov/vdp-scanner)
10+
[![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/cisagov/vdp-scanner)](https://hub.docker.com/r/cisagov/vdp-scanner)
11+
[![Platforms](https://img.shields.io/badge/platforms-amd64%20%7C%20arm%2Fv6%20%7C%20arm%2Fv7%20%7C%20arm64%20%7C%20ppc64le%20%7C%20s390x-blue)](https://hub.docker.com/r/cisagov/vdp-scanner/tags)
1212

13-
This is a docker skeleton project that can be used to quickly get a
14-
new [cisagov](https://github.com/cisagov) GitHub docker project
15-
started. This skeleton project contains [licensing
16-
information](LICENSE), as well as [pre-commit hooks](https://pre-commit.com)
17-
and [GitHub Actions](https://github.com/features/actions) configurations
18-
appropriate for docker containers and the major languages that we use.
13+
This is a Docker project to scan either the
14+
[GSA current Federal .gov domain list](https://github.com/GSA/data/blob/master/dotgov-domains/current-federal.csv)
15+
or a given CSV in the same format with the
16+
[cisagov/hash-http-content](https://github.com/cisagov/hash-http-content)
17+
Python library. Then it will output CSVs with agency and domain level results.
1918

2019
## Usage ##
2120

2221
### Install ###
2322

24-
Pull `cisagov/example` from the Docker repository:
23+
Pull `cisagov/vdp-scanner` from the Docker repository:
2524

26-
docker pull cisagov/example
25+
```console
26+
docker pull cisagov/vdp-scanner
27+
```
2728

28-
Or build `cisagov/example` from source:
29+
Or build `cisagov/vdp-scanner` from source:
2930

30-
git clone https://github.com/cisagov/skeleton-docker.git
31-
cd skeleton-docker
32-
docker-compose build --build-arg VERSION=0.0.1
31+
```console
32+
git clone https://github.com/cisagov/vdp-scanner-docker.git
33+
cd vdp-scanner-docker
34+
docker-compose build
35+
```
3336

3437
### Run ###
3538

36-
docker-compose run --rm example
39+
This Docker image needs a bind mount to get the output from the script to the
40+
host.
3741

38-
## Ports ##
42+
Using `docker run`
3943

40-
This container exposes the following ports:
44+
```console
45+
docker run --mount type=bind,source=$(pwd),target=/task/host_mount --rm cisagov/vdp-scanner
46+
```
4147

42-
| Port | Protocol | Service |
43-
|-------|----------|----------|
44-
| 8080 | TCP | http |
48+
or if you have cloned the repository, you can use the included
49+
`docker-compose.yml`
4550

46-
## Environment Variables ##
47-
48-
| Variable | Default Value | Purpose |
49-
|---------------|-------------------------------|--------------|
50-
| ECHO_MESSAGE | `Hello World from Dockerfile` | Text to echo |
51-
52-
## Secrets ##
53-
54-
| Filename | Purpose |
55-
|---------------|----------------------|
56-
| quote.txt | Secret text to echo |
57-
58-
## Volumes ##
59-
60-
| Mount point | Purpose |
61-
|-------------|----------------|
62-
| /var/log | logging output |
63-
64-
## New Repositories from a Skeleton ##
65-
66-
Please see our [Project Setup guide](https://github.com/cisagov/development-guide/tree/develop/project_setup)
67-
for step-by-step instructions on how to start a new repository from
68-
a skeleton. This will save you time and effort when configuring a
69-
new repository!
51+
```console
52+
docker-compose up
53+
```
7054

7155
## Contributing ##
7256

docker-compose.yml

+10-20
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,25 @@ version: "3.7"
33

44
# This docker-compose file is used to build and test the container
55

6-
secrets:
7-
quote_txt:
8-
file: ./src/secrets/quote.txt
9-
106
services:
11-
example:
7+
vdp-scanner:
128
# Run the container normally
139
build:
14-
# VERSION must be specified on the command line:
15-
# e.g., --build-arg VERSION=0.0.1
10+
# SERVERLESS_CHROME_VERSION and SERVERLESS_CHROME_LOCAL can be specified
11+
# on the command line to modify what is installed and where:
12+
# --build-arg SERVERLESS_CHROME_VERSION=v1.0.0-56
13+
# --build-arg SERVERLESS_CHROME_LOCAL=/opt/serverless-chrome
1614
context: .
1715
dockerfile: Dockerfile
18-
image: cisagov/example
16+
image: cisagov/vdp-scanner
1917
init: true
2018
restart: "no"
21-
environment:
22-
- ECHO_MESSAGE=Hello World from docker-compose!
23-
ports:
24-
- target: "8080"
25-
published: "8080"
26-
protocol: tcp
27-
mode: host
28-
secrets:
29-
- source: quote_txt
30-
target: quote.txt
19+
volumes:
20+
- .:/task/host_mount
3121

32-
example-version:
22+
vdp-scanner-version:
3323
# Run the container to collect version information
34-
image: cisagov/example
24+
image: cisagov/vdp-scanner
3525
init: true
3626
restart: "no"
3727
command: --version

src/Pipfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
docopt = "*"
8+
hash-http-content = {file = "https://github.com/cisagov/hash-http-content/archive/v0.0.1.tar.gz"}
9+
requests = "*"
10+
urllib3 = "*"
11+
pip = "*"
12+
setuptools = "*"
13+
wheel = "*"
14+
15+
[dev-packages]
16+
17+
[requires]
18+
python_version = "3"

0 commit comments

Comments
 (0)