Skip to content

Commit

Permalink
Improve makefile, git hash with -v, fix README
Browse files Browse the repository at this point in the history
  • Loading branch information
kotakanbe committed Oct 12, 2016
1 parent b964d19 commit c89b714
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 134 deletions.
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.PHONY: \
glide \
deps \
update \
build \
install \
all \
vendor \
lint \
Expand All @@ -12,12 +17,27 @@

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)'

all: test
glide:
go get github.com/Masterminds/glide

deps: glide
glide install

update: glide
glide update

# vendor:
# @ go get -v github.com/mjibson/party
# party -d external -c -u
build: main.go deps
go build -ldflags "$(LDFLAGS)" -o vuls $<

install: main.go deps
go install -ldflags "$(LDFLAGS)"

all: test

lint:
@ go get -v github.com/golang/lint/golint
Expand Down
57 changes: 14 additions & 43 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

go-cve-dictionaryを既にインストール済みでupdateしたい場合は

```bash
$ go get -u 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 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分程度かかる。
Expand All @@ -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したい場合は
Expand Down Expand Up @@ -1074,45 +1069,21 @@ 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
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`以下に作成される
Expand Down
57 changes: 16 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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

Expand Down Expand Up @@ -987,48 +987,23 @@ $ 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
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
---
Expand Down
38 changes: 18 additions & 20 deletions glide.lock

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

9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(), "")
Expand All @@ -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))
}

Expand Down
24 changes: 0 additions & 24 deletions version/version.go

This file was deleted.

0 comments on commit c89b714

Please sign in to comment.