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

added dockernized-vuls with vulsrepo #121

Merged
merged 1 commit into from
Jul 4, 2016
Merged
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
14 changes: 0 additions & 14 deletions setup/docker/Dockerfile

This file was deleted.

77 changes: 77 additions & 0 deletions setup/docker/README.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Vuls on Docker

## Index

- テスト環境
- サーバーセットアップ
- Dockerのインストール
- Docker Composeのインストール
- vulsセットアップ
- sshキーの配置
- tomlの編集
- Vuls 起動
- Vuls scan実行
- ブラウザから動作確認


##テスト環境

- Server OS: ubuntu 14.04

## サーバーセットアップ

1. Dockerのインストール
2. Docker Composeのインストール

### 作業ディレクトリの作成

```
mkdir work
cd work
git clone https://github.com/hikachan/vuls
cd vuls
```

## Vuls セットアップ

### sshキーの配置(vuls/docker/conf/id_rsa)

### tomlの編集(vuls/docker/conf/config.toml)

```
[servers]

#This is a sample
[servers.172.17.0.1]
host = "172.17.0.1"
port = "22"
user = "ubuntu"
keyPath = "/root/.ssh/id_rsa"
#containers = ["target_container"]
```

## Vuls 起動

```
docker-compose up -d
```

## Update cve

```
docker exec -t vuls scripts/update_cve.sh
```

## Vuls Scan 実行

```
docker exec -t vuls vuls prepare -config=conf/config.toml
docker exec -t vuls scripts/scan_for_vulsrepo.sh
```

### Vuls Repo 接続確認

```
http://${Vuls_Host}/vulsrepo/
```

84 changes: 78 additions & 6 deletions setup/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,79 @@
# Before building the docker
# Vuls on Docker

Since it's not on docker hub because blablabla, you have to :
* Edit your [config.toml](https://github.com/future-architect/vuls#step6-config) to match your infrastructure
* generate a keypair dedicated to this docker : ```ssh-keygen -t rsa -b 4096 -C "your_email@example.com"```
* it's **highly** recommanded to use a restrained `authorized_keys` files with this key to be sure that it will be only usable from a single IP (after all it's a root executed software) : ```from="1.2.3.4,1.2.3.5" ssh-rsa [...] your_email@example.com```
* Deploy your ssh key on the targetted machines
## Table of Contens

- [What's Vuls-On-Docker?](#whats-vuls-on-docker)
- [Server Setup](#setting-up-your-machine)
- Install Docker
- Instal Docker Compose
- [Start A Vuls Container](#start-a-vuls-container)
- [Vuls Setup](#setting-up-vuls)
- Locate a appropriate ssh-key
- Edit toml
- [Scan servers with Vuls-On-Docker](#scan-servers-with-vuls-on-docker)
- [See the results in a browser](#see-the-results-in-a-browser)

## What's Vuls-On-Docker

- This is a dockernized-Vuls with DockerRepo UI in it.
- It's designed to reduce the cost of installation and the dependencies that vuls requires.
- You can run install and run Vuls on your machine with only a few commands.
- The result can be viewed with a browser

## Setting up your machine

1. [Install Docker](https://docs.docker.com/engine/installation/)
2. [Install Docker-Compose](https://docs.docker.com/compose/install/)
3. Make sure that you can run the following commands before you move on.

```
$ docker version
$ docker-compose version
```

4. Create a working directory for Vuls

```
mkdir work
cd work
git clone https://github.com/hikachan/vuls.git
cd vuls/docker
```

## Start A Vuls Container

- Execute the following command to build and run a Vuls Container

``
docker-compose up -d
``

## Setting up Vuls

1. Locate ssh-keys of servers in (vuls/docker/conf/id_rsa)
2. Create and ajust config.toml(vuls/docker/conf/config.toml) to your environment

```
[servers]

[servers.172-31-4-82]
host = "172.31.4.82"
user = "ec2-user"
keyPath = "conf/id_rsa"
containers = ["container_name_a", "4aa37a8b63b9"]
```

## Scan servers with Vuls-On-Docker

- Use the embedded script to scan servers for vulsrepo(or run whatever with docker exec)

```
docker exec -t vuls vuls prepare -config=conf/config.toml
docker exec -t vuls scripts/scan_for_vulsrepo.sh
```

## See the results in a browser

```
http://${Vuls_Host}/vulsrepo/
```
Empty file added setup/docker/conf/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions setup/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '2'
services:
vuls:
container_name: vuls
build: ./dockerfile
image: vuls-docker:0.1
volumes:
- ./conf:/opt/vuls/conf
ports:
- "80:80"

68 changes: 68 additions & 0 deletions setup/docker/dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM buildpack-deps:jessie-scm

# golang Install
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
curl \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.6.2
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV GOLANG_DOWNLOAD_SHA256 e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a

RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"

# nginx Install
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
nginx \
nginx-module-xslt \
nginx-module-geoip \
nginx-module-image-filter \
nginx-module-perl \
nginx-module-njs \
gettext-base \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/*

RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

COPY nginx.conf /etc/nginx/nginx.conf

#Vuls Install
ENV VULS_ROOT /opt/vuls
RUN mkdir -p /var/log/vuls ${VULS_ROOT}/conf /root/.ssh/
RUN chmod 700 -R /var/log/vuls $VULS_ROOT
RUN go get github.com/kotakanbe/go-cve-dictionary
RUN go get github.com/future-architect/vuls

# Copy custom Scripts
COPY ./scripts/ ${VULS_ROOT}/scripts

#Vulrepo Install
RUN git clone https://github.com/usiusi360/vulsrepo /tmp/vulsrepo
RUN mkdir /usr/share/nginx/html/vulsrepo/
RUN cp -rp /tmp/vulsrepo/src/* /usr/share/nginx/html/vulsrepo
RUN rm -rf /tmp/vulsrepo

#Home
WORKDIR /opt/vuls
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]

32 changes: 32 additions & 0 deletions setup/docker/dockerfile/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

user root;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}
7 changes: 7 additions & 0 deletions setup/docker/dockerfile/scripts/scan_for_vulsrepo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
VULS_ROOT=/opt/vuls
VULS_CONF=${VULS_ROOT}/conf
NGINX_VULSREPO_ROOT=/usr/share/nginx/html/vulsrepo
cd $VULS_ROOT
vuls scan -report-json --cve-dictionary-dbpath=${VULS_ROOT}/cve.sqlite3 -config=${VULS_CONF}/config.toml
ln -sf ${VULS_ROOT}/results/current ${NGINX_VULSREPO_ROOT}/current
6 changes: 6 additions & 0 deletions setup/docker/dockerfile/scripts/update_cve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
VULS_ROOT=/opt/vuls
#VULS_CONF=${VULS_ROOT}/conf
cd $VULS_ROOT
for i in {2002..2016}; do go-cve-dictionary fetchnvd -years $i; done

2 changes: 0 additions & 2 deletions setup/docker/fetch.sh

This file was deleted.

1 change: 0 additions & 1 deletion setup/docker/id_rsa

This file was deleted.

1 change: 0 additions & 1 deletion setup/docker/id_rsa.pub

This file was deleted.

28 changes: 0 additions & 28 deletions setup/docker/run.sh

This file was deleted.