Improve makefile, -version shows git hash, fix README
This commit is contained in:
		
							
								
								
									
										28
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,9 @@
 | 
			
		||||
.PHONY: \
 | 
			
		||||
	glide \
 | 
			
		||||
	deps \
 | 
			
		||||
	update \
 | 
			
		||||
	build \
 | 
			
		||||
	install \
 | 
			
		||||
	all \
 | 
			
		||||
	vendor \
 | 
			
		||||
	lint \
 | 
			
		||||
@@ -12,13 +17,28 @@
 | 
			
		||||
 | 
			
		||||
SRCS = $(shell git ls-files '*.go')
 | 
			
		||||
PKGS = ./. ./config ./models ./report ./cveapi ./scan ./util ./commands ./cache
 | 
			
		||||
VERSION := $(shell git describe --tags --abbrev=0)
 | 
			
		||||
REVISION := $(shell git rev-parse --short HEAD)
 | 
			
		||||
LDFLAGS := -X 'main.version=$(VERSION)' \
 | 
			
		||||
	-X 'main.revision=$(REVISION)'
 | 
			
		||||
 | 
			
		||||
glide:
 | 
			
		||||
	go get github.com/Masterminds/glide
 | 
			
		||||
 | 
			
		||||
deps: glide
 | 
			
		||||
	glide install
 | 
			
		||||
 | 
			
		||||
update: glide
 | 
			
		||||
	glide update
 | 
			
		||||
 | 
			
		||||
build: main.go deps
 | 
			
		||||
	go build -ldflags "$(LDFLAGS)" -o vuls $<
 | 
			
		||||
 | 
			
		||||
install: main.go deps
 | 
			
		||||
	go install -ldflags "$(LDFLAGS)"
 | 
			
		||||
 | 
			
		||||
all: test
 | 
			
		||||
 | 
			
		||||
#  vendor:
 | 
			
		||||
#          @ go get -v github.com/mjibson/party
 | 
			
		||||
#          party -d external -c -u
 | 
			
		||||
 | 
			
		||||
lint:
 | 
			
		||||
	@ go get -v github.com/golang/lint/golint
 | 
			
		||||
	$(foreach file,$(SRCS),golint $(file) || exit;)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										57
									
								
								README.ja.md
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								README.ja.md
									
									
									
									
									
								
							@@ -148,26 +148,19 @@ $ source /etc/profile.d/goenv.sh
 | 
			
		||||
 | 
			
		||||
## Step4. Deploy [go-cve-dictionary](https://github.com/kotakanbe/go-cve-dictionary)
 | 
			
		||||
 | 
			
		||||
go get
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
$ sudo mkdir /var/log/vuls
 | 
			
		||||
$ sudo chown ec2-user /var/log/vuls
 | 
			
		||||
$ sudo chmod 700 /var/log/vuls
 | 
			
		||||
$ go get github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$
 | 
			
		||||
$ mkdir -p $GOPATH/src/github.com/kotakanbe
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe
 | 
			
		||||
$ git https://github.com/kotakanbe/go-cve-dictionary.git
 | 
			
		||||
$ cd go-cve-dictionary
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
バイナリは、`$GOPATH/bin`いかに生成される
 | 
			
		||||
 | 
			
		||||
go-cve-dictionaryを既にインストール済みでupdateしたい場合は
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
$ go get -u github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
で可能である。
 | 
			
		||||
 | 
			
		||||
go getでエラーが発生した場合は、以下の点を確認する。
 | 
			
		||||
- Gitのバージョンがv2以降か?
 | 
			
		||||
- Go依存パッケージの問題でgo getに失敗する場合は [deploying with glide](https://github.com/future-architect/vuls/blob/master/README.md#deploy-with-glide) を試す。
 | 
			
		||||
 | 
			
		||||
NVDから脆弱性データベースを取得する。  
 | 
			
		||||
環境によって異なるが、AWS上では10分程度かかる。
 | 
			
		||||
@@ -182,10 +175,12 @@ $ ls -alh cve.sqlite3
 | 
			
		||||
## Step5. Deploy Vuls
 | 
			
		||||
 | 
			
		||||
新規にターミナルを起動し、先ほど作成したEC2にSSH接続する。
 | 
			
		||||
 | 
			
		||||
go get
 | 
			
		||||
```
 | 
			
		||||
$ go get github.com/future-architect/vuls
 | 
			
		||||
$ mkdir -p $GOPATH/src/github.com/future-architect
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect
 | 
			
		||||
$ git clone https://github.com/future-architect/vuls.git
 | 
			
		||||
$ cd vuls
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
vulsを既にインストール済みでupdateしたい場合は
 | 
			
		||||
@@ -1074,28 +1069,6 @@ slack, emailは日本語対応済み TUIは日本語表示未対応
 | 
			
		||||
 | 
			
		||||
----
 | 
			
		||||
 | 
			
		||||
# Deploy With Glide
 | 
			
		||||
 | 
			
		||||
If an error occurred while go get, try deploying with glide.  
 | 
			
		||||
- Install [Glide](https://github.com/Masterminds/glide)
 | 
			
		||||
- Deploy go-cve-dictionary
 | 
			
		||||
```
 | 
			
		||||
$ go get -d github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
```
 | 
			
		||||
- Deploy vuls
 | 
			
		||||
```
 | 
			
		||||
$ go get -d github.com/future-architect/vuls
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect/vuls
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
```
 | 
			
		||||
- The binaries are created under $GOPARH/bin
 | 
			
		||||
 | 
			
		||||
----
 | 
			
		||||
 | 
			
		||||
# Update Vuls With Glide
 | 
			
		||||
 | 
			
		||||
- Update go-cve-dictionary  
 | 
			
		||||
@@ -1103,16 +1076,14 @@ If the DB schema was changed, please specify new SQLite3 DB file.
 | 
			
		||||
```
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ git pull
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
- Update vuls
 | 
			
		||||
```
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect/vuls
 | 
			
		||||
$ git pull
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
- バイナリファイルは`$GOPARH/bin`以下に作成される
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										57
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								README.md
									
									
									
									
									
								
							@@ -156,18 +156,18 @@ $ source /etc/profile.d/goenv.sh
 | 
			
		||||
 | 
			
		||||
## Step4. Deploy [go-cve-dictionary](https://github.com/kotakanbe/go-cve-dictionary)
 | 
			
		||||
 | 
			
		||||
go get
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
$ sudo mkdir /var/log/vuls
 | 
			
		||||
$ sudo chown ec2-user /var/log/vuls
 | 
			
		||||
$ sudo chmod 700 /var/log/vuls
 | 
			
		||||
$ go get github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$
 | 
			
		||||
$ mkdir -p $GOPATH/src/github.com/kotakanbe
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe
 | 
			
		||||
$ git clone https://github.com/kotakanbe/go-cve-dictionary.git
 | 
			
		||||
$ cd go-cve-dictionary
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
If an error occurred while go get, check the following points.
 | 
			
		||||
- Update Git
 | 
			
		||||
- try [deploying with glide](https://github.com/future-architect/vuls/blob/master/README.md#deploy-with-glide).
 | 
			
		||||
The binary was built under `$GOPARH/bin`
 | 
			
		||||
 | 
			
		||||
Fetch vulnerability data from NVD.  
 | 
			
		||||
It takes about 10 minutes (on AWS).  
 | 
			
		||||
@@ -183,14 +183,14 @@ $ ls -alh cve.sqlite3
 | 
			
		||||
 | 
			
		||||
Launch a new terminal and SSH to the ec2 instance.
 | 
			
		||||
 | 
			
		||||
go get
 | 
			
		||||
```
 | 
			
		||||
$ go get github.com/future-architect/vuls
 | 
			
		||||
$ mkdir -p $GOPATH/src/github.com/future-architect
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect
 | 
			
		||||
$ git clone https://github.com/future-architect/vuls.git
 | 
			
		||||
$ cd vuls
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
If an error occurred while go get, check the following points.
 | 
			
		||||
- Update Git
 | 
			
		||||
- try [deploying with glide](https://github.com/future-architect/vuls/blob/master/README.md#deploy-with-glide).
 | 
			
		||||
The binary was built under `$GOPARH/bin`
 | 
			
		||||
 | 
			
		||||
## Step6. Config
 | 
			
		||||
 | 
			
		||||
@@ -987,28 +987,6 @@ $ go-cve-dictionary fetchnvd -last2y
 | 
			
		||||
 | 
			
		||||
----
 | 
			
		||||
 | 
			
		||||
# Deploy With Glide
 | 
			
		||||
 | 
			
		||||
If an error occurred while go get, try deploying with glide.  
 | 
			
		||||
- Install [Glide](https://github.com/Masterminds/glide)
 | 
			
		||||
- Deploy go-cve-dictionary
 | 
			
		||||
```
 | 
			
		||||
$ go get -d github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
```
 | 
			
		||||
- Deploy vuls
 | 
			
		||||
```
 | 
			
		||||
$ go get -d github.com/future-architect/vuls
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect/vuls
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
```
 | 
			
		||||
- The binaries are created under $GOPARH/bin
 | 
			
		||||
 | 
			
		||||
----
 | 
			
		||||
 | 
			
		||||
# Update Vuls With Glide
 | 
			
		||||
 | 
			
		||||
- Update go-cve-dictionary  
 | 
			
		||||
@@ -1016,19 +994,16 @@ If the DB schema was changed, please specify new SQLite3 DB file.
 | 
			
		||||
```
 | 
			
		||||
$ cd $GOPATH/src/github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
$ git pull
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
- Update vuls
 | 
			
		||||
```
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect/vuls
 | 
			
		||||
$ git pull
 | 
			
		||||
$ glide install
 | 
			
		||||
$ go install
 | 
			
		||||
$ make install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Binary Files are created under $GOPARH/bin
 | 
			
		||||
Binary file was built under $GOPARH/bin
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								glide.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										38
									
								
								glide.lock
									
									
									
										generated
									
									
									
								
							@@ -1,10 +1,10 @@
 | 
			
		||||
hash: 28d14f88e90c0765c1b660ddde796e51e197239d353bb79bfc5d8f8cf9b5f9ee
 | 
			
		||||
updated: 2016-09-20T10:05:42.83736026+09:00
 | 
			
		||||
hash: 01cee4aa1d27c967f5f5165febfbd77fd0e89a6e7a9a89c84099c0d45dffd446
 | 
			
		||||
updated: 2016-10-12T15:28:25.843936367+09:00
 | 
			
		||||
imports:
 | 
			
		||||
- name: github.com/asaskevich/govalidator
 | 
			
		||||
  version: 593d64559f7600f29581a3ee42177f5dbded27a9
 | 
			
		||||
  version: 7b3beb6df3c42abd3509abfc3bcacc0fbfb7c877
 | 
			
		||||
- name: github.com/aws/aws-sdk-go
 | 
			
		||||
  version: bc572378d109481c50d45d9dba4490d80386e98e
 | 
			
		||||
  version: aad29423c2c09f0a1fa5346216bc041a4994eef4
 | 
			
		||||
  subpackages:
 | 
			
		||||
  - aws
 | 
			
		||||
  - aws/credentials
 | 
			
		||||
@@ -32,11 +32,11 @@ imports:
 | 
			
		||||
  - private/protocol/xml/xmlutil
 | 
			
		||||
  - private/protocol/query/queryutil
 | 
			
		||||
- name: github.com/Azure/azure-sdk-for-go
 | 
			
		||||
  version: 34467930a15f0d2872168deb11435b8ac3d863bb
 | 
			
		||||
  version: 91f3d4a4d024e3c0d4d9412916d05cf84504a616
 | 
			
		||||
  subpackages:
 | 
			
		||||
  - storage
 | 
			
		||||
- name: github.com/boltdb/bolt
 | 
			
		||||
  version: fff57c100f4dea1905678da7e90d92429dff2904
 | 
			
		||||
  version: 074dffcc83e9f421e261526d297cd93f22a34080
 | 
			
		||||
- name: github.com/BurntSushi/toml
 | 
			
		||||
  version: 99064174e013895bbd9b025c31100bd1d9b590ca
 | 
			
		||||
- name: github.com/cenkalti/backoff
 | 
			
		||||
@@ -53,15 +53,15 @@ imports:
 | 
			
		||||
  - util/strutil
 | 
			
		||||
  - util/wordwrap
 | 
			
		||||
- name: github.com/howeyc/gopass
 | 
			
		||||
  version: 3ca23474a7c7203e0a0a070fd33508f6efdb9b3d
 | 
			
		||||
  version: f5387c492211eb133053880d23dfae62aa14123d
 | 
			
		||||
- name: github.com/jinzhu/gorm
 | 
			
		||||
  version: 02f6ae3c4ed211472b0492cee02ff3ddfdc1830d
 | 
			
		||||
  version: 39165d498058a823126af3cbf4d2a3b0e1acf11e
 | 
			
		||||
- name: github.com/jinzhu/inflection
 | 
			
		||||
  version: 74387dc39a75e970e7a3ae6a3386b5bd2e5c5cff
 | 
			
		||||
- name: github.com/jmespath/go-jmespath
 | 
			
		||||
  version: bd40a432e4c76585ef6b72d3fd96fb9b6dc7b68d
 | 
			
		||||
- name: github.com/jroimartin/gocui
 | 
			
		||||
  version: 30f7d65597dc2c421ce452b164c36b7014ef94be
 | 
			
		||||
  version: 4e9ce9a8e26f2ef33dfe297dbdfca148733b6b9b
 | 
			
		||||
- name: github.com/k0kubun/pp
 | 
			
		||||
  version: f5dce6ed0ccf6c350f1679964ff6b61f3d6d2033
 | 
			
		||||
- name: github.com/kotakanbe/go-cve-dictionary
 | 
			
		||||
@@ -79,27 +79,27 @@ imports:
 | 
			
		||||
- name: github.com/kotakanbe/logrus-prefixed-formatter
 | 
			
		||||
  version: f4f7d41649cf1e75e736884da8d05324aa76ea25
 | 
			
		||||
- name: github.com/mattn/go-colorable
 | 
			
		||||
  version: ed8eb9e318d7a84ce5915b495b7d35e0cfe7b5a8
 | 
			
		||||
  version: 6c903ff4aa50920ca86087a280590b36b3152b9c
 | 
			
		||||
- name: github.com/mattn/go-isatty
 | 
			
		||||
  version: 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8
 | 
			
		||||
- name: github.com/mattn/go-runewidth
 | 
			
		||||
  version: d6bea18f789704b5f83375793155289da36a3c7f
 | 
			
		||||
  version: 737072b4e32b7a5018b4a7125da8d12de90e8045
 | 
			
		||||
- name: github.com/mattn/go-sqlite3
 | 
			
		||||
  version: 3fb7a0e792edd47bf0cf1e919dfc14e2be412e15
 | 
			
		||||
  version: e5a3c16c5c1d80b24f633e68aecd6b0702786d3d
 | 
			
		||||
- name: github.com/mgutz/ansi
 | 
			
		||||
  version: c286dcecd19ff979eeb73ea444e479b903f2cfcb
 | 
			
		||||
- name: github.com/moul/http2curl
 | 
			
		||||
  version: b1479103caacaa39319f75e7f57fc545287fca0d
 | 
			
		||||
- name: github.com/nsf/termbox-go
 | 
			
		||||
  version: e8f6d27f72a2f2bb598eb3579afd5ea364ef67f7
 | 
			
		||||
  version: b6acae516ace002cb8105a89024544a1480655a5
 | 
			
		||||
- name: github.com/parnurzeal/gorequest
 | 
			
		||||
  version: 2aea80ce763523ecc6452e61c3727ae9595a5809
 | 
			
		||||
  version: e37b9d1efacf7c94820b29b75dd7d0c2996b3fb1
 | 
			
		||||
- name: github.com/rifflock/lfshook
 | 
			
		||||
  version: f9d14dda07b109a7aa56f135c31b34062eb14392
 | 
			
		||||
  version: 3f9d976bd7402de39b46357069fb6325a974572e
 | 
			
		||||
- name: github.com/Sirupsen/logrus
 | 
			
		||||
  version: 3ec0642a7fb6488f65b06f9040adc67e3990296a
 | 
			
		||||
- name: golang.org/x/crypto
 | 
			
		||||
  version: 9e590154d2353f3f5e1b24da7275686040dcf491
 | 
			
		||||
  version: 4cd25d65a015cc83d41bf3454e6e8d6c116d16da
 | 
			
		||||
  subpackages:
 | 
			
		||||
  - ssh
 | 
			
		||||
  - ssh/agent
 | 
			
		||||
@@ -108,14 +108,12 @@ imports:
 | 
			
		||||
  - ed25519
 | 
			
		||||
  - ed25519/internal/edwards25519
 | 
			
		||||
- name: golang.org/x/net
 | 
			
		||||
  version: 9313baa13d9262e49d07b20ed57dceafcd7240cc
 | 
			
		||||
  version: cf4effbb9db1f3ef07f7e1891402991b6afbb276
 | 
			
		||||
  subpackages:
 | 
			
		||||
  - context
 | 
			
		||||
  - publicsuffix
 | 
			
		||||
- name: golang.org/x/sys
 | 
			
		||||
  version: 30de6d19a3bd89a5f38ae4028e23aaa5582648af
 | 
			
		||||
  version: 9bb9f0998d48b31547d975974935ae9b48c7a03c
 | 
			
		||||
  subpackages:
 | 
			
		||||
  - unix
 | 
			
		||||
- name: gopkg.in/alexcesaro/quotedprintable.v3
 | 
			
		||||
  version: 2caba252f4dc53eaf6b553000885530023f54623
 | 
			
		||||
devImports: []
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.go
									
									
									
									
									
								
							@@ -25,12 +25,17 @@ import (
 | 
			
		||||
	"golang.org/x/net/context"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/commands"
 | 
			
		||||
	"github.com/future-architect/vuls/version"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
 | 
			
		||||
	_ "github.com/mattn/go-sqlite3"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Version of Vuls
 | 
			
		||||
var version = "0.1.6"
 | 
			
		||||
 | 
			
		||||
// Revision of Git
 | 
			
		||||
var revision string
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	subcommands.Register(subcommands.HelpCommand(), "")
 | 
			
		||||
	subcommands.Register(subcommands.FlagsCommand(), "")
 | 
			
		||||
@@ -47,7 +52,7 @@ func main() {
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	if *v {
 | 
			
		||||
		fmt.Printf("%s %s\n", version.Name, version.Version)
 | 
			
		||||
		fmt.Printf("vuls %s %s\n", version, revision)
 | 
			
		||||
		os.Exit(int(subcommands.ExitSuccess))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
 | 
			
		||||
This program is free software: you can redistribute it and/or modify
 | 
			
		||||
it under the terms of the GNU General Public License as published by
 | 
			
		||||
the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package version
 | 
			
		||||
 | 
			
		||||
// Name is Vuls
 | 
			
		||||
const Name string = "vuls"
 | 
			
		||||
 | 
			
		||||
// Version of Vuls
 | 
			
		||||
const Version string = "0.1.6"
 | 
			
		||||
		Reference in New Issue
	
	Block a user