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

Release v0.1.0 #4

Merged
merged 6 commits into from
Oct 15, 2017
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@

.idea
*.iml
config.toml
config.toml
/vendor/
19 changes: 19 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
builds:
- binary: ec2-vuls-config
goos:
- windows
- darwin
- linux
goarch:
- amd64
- 386
archive:
format: zip
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
files:
- README.md
- README.ja.md
release:
github:
owner: ohswa0515
name: ec2-vuls-config
32 changes: 32 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.12.10"

[[constraint]]
name = "gopkg.in/urfave/cli.v1"
version = "1.20.0"
207 changes: 207 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
ec2-vuls-config
===

ec2-vuls-config は [Vuls](https://github.com/future-architect/vuls)スキャンのために、Amazon EC2インスタンスの情報を収集して設定ファイルを生成するのに役立つコマンドラインツールです。
EC2タグを指定することで、自動的にスキャン対象を選定し、設定ファイルを書き換えます。

# Installation

## Step1. スキャンしたいEC2インスタンスに`Name`タグと`vuls:scan`タグとその値を付与する

```console
Name : web-server-1
vuls:scan : true
```

## Step2. インストール

* Binary

[releases page](https://github.com/ohsawa0515/ec2-vuls-config/releases)からダウンロードできます。

* Go get

```console
$ go get -u github.com/ohsawa0515/ec2-vuls-config
$ go get -u github.com/golang/dep/...
$ dep ensure
```

## Step3. AWSクレデンシャルを設定

IAMポリシー例:

```json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:DescribeInstances"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
```

* Credential file (`$HOME/.aws/credentials`)

```console
[default]
aws_access_key_id = <YOUR_ACCESS_KEY_ID>
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
```

* Environment variable

```console
$ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
```

## Step4. AWSリージョンを設定

```console
$ export AWS_REGION=us-east-1
```


## Step5. 設定ファイル(config.toml)を用意する

設定ファイルについては、[vuls#configuration](https://github.com/future-architect/vuls#configuration) か [config.toml.sample](https://github.com/ohsawa0515/ec2-vuls-config/blob/master/config.toml.sample) をご参照ください。

## Step6. 実行

デフォルトで以下のフィルタ条件が適用されています。

- EC2インスタンスのステータスがRunning
- Linux (Windowsは選択されない)
- `vuls:scan` タグの値は `true` のみ

```console
$ ec2-vuls-config
```

実行後, 設定ファイル(config.toml)は以下のように追記されています。

```toml
[default]
port = "22"
user = "vuls"
keyPath = "/opt/vuls/.ssh/id_rsa"

[servers]

### Generate by ec2-vuls-config ###
# Updated 2000-01-01T00:01:00+09:00

[servers.web-server-1]
host = "192.0.2.11"

### ec2-vuls-config end ###
```

# Tags

`vuls:user`、` vuls:port`などのEC2タグを設定することで、設定ファイルにに反映させることができます。

`<...>` はタグ名です。

```toml
[servers]

[servers.<Name>]
host = "<<Private IP address of instance>>"
port = "<vuls:port>"
user = "<vuls:user>"
keyPath = "<vuls:keyPath>"

# Set value of tag as comma-separated.
cpeNames = [
"<vuls:cpeNames>",
]

# Set value of tag as comma-separated.
ignoreCves = [
"<vuls:ignoreCves>",
]

# Example

# `vuls:user` => vuls
# `vuls:port` => 22
# `vuls:keyPath` => /opt/vuls/.ssh/id_rsa
# `vuls:cpeNames` => cpe:/a:rubyonrails:ruby_on_rails:4.2.7.1,cpe:/a:rubyonrails:ruby_on_rails:4.2.8,cpe:/a:rubyonrails:ruby_on_rails:5.0.1
# `vuls:ignoreCves` => CVE-2014-2913,CVE-2016-6314

[servers.web-server-1]
host = "192.0.2.11"
user = "vuls"
port = "22"
keyPath = "/opt/vuls/.ssh/id_rsa"
cpeNames = [
"cpe:/a:rubyonrails:ruby_on_rails:4.2.7.1",
"cpe:/a:rubyonrails:ruby_on_rails:4.2.8",
"cpe:/a:rubyonrails:ruby_on_rails:5.0.1",
]
ignoreCves = [
"CVE-2014-2913",
"CVE-2016-6314",
]
```

# Command line options

## --config (-c)

読み込む設定ファイルのファイルパスを指定します。デフォルト: `$PWD/config.toml`

```console
$ ec2-vuls-config --config /path/to/config.toml
```

## --filters (-f)

デフォルトの条件に加えて、さらにフィルタリングしたい場合に使用します。フィルタリングは[describe-instances コマンド](http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html)のように指定できます。
`Name`タグと`Value`タグのセットで指定し、スペース区切りで複数指定可能。

* `web-server`というNameタグのインスタンスをスキャンしたい場合

```console
$ ec2-vuls-config --filters "Name=tag:Name,Values=web-server"
```

* `app-server`というNameタグがついている、かつインスタンスタイプが`c3.large`のインスタンスをスキャンしたい場合

```console
$ ec2-vuls-config --filters "Name=tag:Name,Values=app-server Name=instance-type,Values=r3.large"
```

## --out (-o)

設定ファイルの出力先を指定します。デフォルト: `$PWD/config.toml`

```console
$ ec2-vuls-config --out /path/to/config.toml
```


## --print (-p)

設定ファイルに書き込む代わりに標準出力します。

# Contribution

1. Fork ([https://github.com/ohsawa0515/ec2-vuls-config/fork](https://github.com/ohsawa0515/ec2-vuls-config/fork))
2. Create a feature branch
3. Commit your changes
4. Rebase your local changes against the master branch
5. Run test suite with the `go test ./...` command and confirm that it passes
6. Run `gofmt -s`
7. Create new Pull Request

# License

See [LICENSE](https://github.com/ohsawa0515/ec2-vuls-config/blob/master/LICENSE).
Loading