Compare commits
	
		
			122 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					89d58d1abc | ||
| 
						 | 
					d6b6969cb3 | ||
| 
						 | 
					e7bf6fa69d | ||
| 
						 | 
					6e51970b91 | ||
| 
						 | 
					56d7d43768 | ||
| 
						 | 
					256c99ffa2 | ||
| 
						 | 
					9c0bc3b13b | ||
| 
						 | 
					9b8a323d85 | ||
| 
						 | 
					3178c1e326 | ||
| 
						 | 
					321d68e03a | ||
| 
						 | 
					3d8753c621 | ||
| 
						 | 
					967c56909d | ||
| 
						 | 
					7c4831d2d1 | ||
| 
						 | 
					4b49e11a33 | ||
| 
						 | 
					d84a6a8627 | ||
| 
						 | 
					63b7f4a8db | ||
| 
						 | 
					ca2160264a | ||
| 
						 | 
					7842594f53 | ||
| 
						 | 
					7db056102c | ||
| 
						 | 
					a5a800fa0a | ||
| 
						 | 
					9147ec148d | ||
| 
						 | 
					b3260588c6 | ||
| 
						 | 
					7d31328271 | ||
| 
						 | 
					6e82981ee3 | ||
| 
						 | 
					9d7b115bb5 | ||
| 
						 | 
					8eae5002a3 | ||
| 
						 | 
					31bd6c0371 | ||
| 
						 | 
					7585f9d537 | ||
| 
						 | 
					76037cdf72 | ||
| 
						 | 
					98c5421edc | ||
| 
						 | 
					e63fc7e3f5 | ||
| 
						 | 
					6ed9cf3fb4 | ||
| 
						 | 
					9865eab2c0 | ||
| 
						 | 
					678e72a8b6 | ||
| 
						 | 
					ec41899089 | ||
| 
						 | 
					b2d913cc21 | ||
| 
						 | 
					bc86c24e6a | ||
| 
						 | 
					87a77dd95c | ||
| 
						 | 
					e8188f3432 | ||
| 
						 | 
					50506be546 | ||
| 
						 | 
					4ded028258 | ||
| 
						 | 
					6da8b3c4a1 | ||
| 
						 | 
					d5c92cbcb3 | ||
| 
						 | 
					ed5f98d6f0 | ||
| 
						 | 
					f854b8f908 | ||
| 
						 | 
					de7a6159d4 | ||
| 
						 | 
					6090a34037 | ||
| 
						 | 
					f566745479 | ||
| 
						 | 
					153234b623 | ||
| 
						 | 
					ac510d21ff | ||
| 
						 | 
					44fa2c5800 | ||
| 
						 | 
					d785fc2a54 | ||
| 
						 | 
					ea800e04bc | ||
| 
						 | 
					fe582ac635 | ||
| 
						 | 
					330edb3bce | ||
| 
						 | 
					212fec7115 | ||
| 
						 | 
					24d7021c47 | ||
| 
						 | 
					e3a01ff6a8 | ||
| 
						 | 
					81f2ba8a46 | ||
| 
						 | 
					9e9370b178 | ||
| 
						 | 
					ced6114a95 | ||
| 
						 | 
					3144faae5d | ||
| 
						 | 
					8960c67a82 | ||
| 
						 | 
					f8ca924434 | ||
| 
						 | 
					399a08775e | ||
| 
						 | 
					92f36ca558 | ||
| 
						 | 
					3dcc58205a | ||
| 
						 | 
					09779962cf | ||
| 
						 | 
					9cc78770a3 | ||
| 
						 | 
					f653ca9131 | ||
| 
						 | 
					6f9fd91849 | ||
| 
						 | 
					cb1aec4fc0 | ||
| 
						 | 
					7cebaf8a76 | ||
| 
						 | 
					241c943424 | ||
| 
						 | 
					d5d88d8cf0 | ||
| 
						 | 
					cf9d26068c | ||
| 
						 | 
					308a93dc72 | ||
| 
						 | 
					d6a7e65e4c | ||
| 
						 | 
					e0a5c5d3b8 | ||
| 
						 | 
					314f775243 | ||
| 
						 | 
					7a1644135a | ||
| 
						 | 
					5076326589 | ||
| 
						 | 
					ce56261b52 | ||
| 
						 | 
					baa0e897b2 | ||
| 
						 | 
					1d49c0e1ce | ||
| 
						 | 
					08755e446e | ||
| 
						 | 
					bb12d9dadb | ||
| 
						 | 
					fd1429fef0 | ||
| 
						 | 
					d3c421a4a8 | ||
| 
						 | 
					0c919da4b1 | ||
| 
						 | 
					9afbf1255f | ||
| 
						 | 
					50b105c4af | ||
| 
						 | 
					028508c1f7 | ||
| 
						 | 
					f0137a3695 | ||
| 
						 | 
					e6d3a1718c | ||
| 
						 | 
					86ba551e07 | ||
| 
						 | 
					26418be937 | ||
| 
						 | 
					092a19bdc1 | ||
| 
						 | 
					6d3398574c | ||
| 
						 | 
					b08969ad89 | ||
| 
						 | 
					0653656526 | ||
| 
						 | 
					7a5793c562 | ||
| 
						 | 
					562ff7807d | ||
| 
						 | 
					7971bdf7f7 | ||
| 
						 | 
					d926b7fd6d | ||
| 
						 | 
					c00404793a | ||
| 
						 | 
					a0e0ee6c1e | ||
| 
						 | 
					4ccbee705b | ||
| 
						 | 
					db43d55b2c | ||
| 
						 | 
					5a3a333eec | ||
| 
						 | 
					039edf1616 | ||
| 
						 | 
					47498bbf23 | ||
| 
						 | 
					cc28bf4ae2 | ||
| 
						 | 
					0e8736045e | ||
| 
						 | 
					19b581edef | ||
| 
						 | 
					295f6656d9 | ||
| 
						 | 
					1214d8c14d | ||
| 
						 | 
					b4cd96fc9a | ||
| 
						 | 
					3238a9b898 | ||
| 
						 | 
					c0f66320f6 | ||
| 
						 | 
					383220f384 | ||
| 
						 | 
					76a9c37e6b | 
							
								
								
									
										7
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
.dockerignore
 | 
			
		||||
Dockerfile
 | 
			
		||||
vendor/
 | 
			
		||||
cve.sqlite3*
 | 
			
		||||
oval.sqlite3*
 | 
			
		||||
setup/
 | 
			
		||||
img/
 | 
			
		||||
							
								
								
									
										46
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							@@ -1,7 +1,26 @@
 | 
			
		||||
 | 
			
		||||
# Environment
 | 
			
		||||
# What did you do? (required. The issue will be **closed** when not provided.)
 | 
			
		||||
 | 
			
		||||
## Vuls
 | 
			
		||||
 | 
			
		||||
# What did you expect to happen?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# What happened instead?
 | 
			
		||||
 | 
			
		||||
* Current Output
 | 
			
		||||
 | 
			
		||||
Please re-run the command using ```-debug``` and provide the output below.
 | 
			
		||||
 | 
			
		||||
# Steps to reproduce the behaviour
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Configuration (**MUST** fill this out):
 | 
			
		||||
 | 
			
		||||
* Go version (`go version`):
 | 
			
		||||
 | 
			
		||||
* Go environment (`go env`):
 | 
			
		||||
 | 
			
		||||
* Vuls environment:
 | 
			
		||||
 | 
			
		||||
Hash : ____
 | 
			
		||||
 | 
			
		||||
@@ -9,28 +28,11 @@ To check the commit hash of HEAD
 | 
			
		||||
$ vuls -v
 | 
			
		||||
 | 
			
		||||
or
 | 
			
		||||
 | 
			
		||||
$ cd $GOPATH/src/github.com/future-architect/vuls 
 | 
			
		||||
$ git rev-parse --short HEAD 
 | 
			
		||||
 | 
			
		||||
## OS
 | 
			
		||||
- Target Server: Write here
 | 
			
		||||
- Vuls Server: Write here
 | 
			
		||||
 | 
			
		||||
## Go
 | 
			
		||||
- Go version: here
 | 
			
		||||
 | 
			
		||||
# Current Output
 | 
			
		||||
 | 
			
		||||
Please re-run the command using ```-debug``` and provide the output below.
 | 
			
		||||
 | 
			
		||||
# Addition Details
 | 
			
		||||
 | 
			
		||||
Can you also please fill in each of the remaining sections.
 | 
			
		||||
 | 
			
		||||
## Expected Behavior
 | 
			
		||||
 | 
			
		||||
## Actual Behavior
 | 
			
		||||
 | 
			
		||||
## Steps to reproduce the behaviour
 | 
			
		||||
* config.toml:
 | 
			
		||||
 | 
			
		||||
* command:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							@@ -1,14 +1,26 @@
 | 
			
		||||
## What did you implement:
 | 
			
		||||
 | 
			
		||||
Closes #XXXXX
 | 
			
		||||
If this Pull Request is work in progress, Add a prefix of “[WIP]” in the title.
 | 
			
		||||
 | 
			
		||||
## How did you implement it:
 | 
			
		||||
# What did you implement:
 | 
			
		||||
 | 
			
		||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. 
 | 
			
		||||
 | 
			
		||||
## How can we verify it:
 | 
			
		||||
Fixes # (issue)
 | 
			
		||||
 | 
			
		||||
## Type of change
 | 
			
		||||
 | 
			
		||||
## Todos:
 | 
			
		||||
Please delete options that are not relevant.
 | 
			
		||||
 | 
			
		||||
- [ ] Bug fix (non-breaking change which fixes an issue)
 | 
			
		||||
- [ ] New feature (non-breaking change which adds functionality)
 | 
			
		||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
 | 
			
		||||
- [ ] This change requires a documentation update
 | 
			
		||||
 | 
			
		||||
# How Has This Been Tested?
 | 
			
		||||
 | 
			
		||||
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
 | 
			
		||||
 | 
			
		||||
# Checklist:
 | 
			
		||||
You don't have to satisfy all of the following.
 | 
			
		||||
 | 
			
		||||
- [ ] Write tests
 | 
			
		||||
@@ -21,4 +33,8 @@ You don't have to satisfy all of the following.
 | 
			
		||||
- [ ] Update the messages below
 | 
			
		||||
 | 
			
		||||
***Is this ready for review?:*** NO  
 | 
			
		||||
***Is it a breaking change?:*** NO
 | 
			
		||||
 | 
			
		||||
# Reference
 | 
			
		||||
 | 
			
		||||
* https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,6 +1,7 @@
 | 
			
		||||
vuls
 | 
			
		||||
.vscode
 | 
			
		||||
*.txt
 | 
			
		||||
*.json
 | 
			
		||||
*.sqlite3*
 | 
			
		||||
*.db
 | 
			
		||||
tags
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
language: go
 | 
			
		||||
 | 
			
		||||
go:
 | 
			
		||||
  - 1.8
 | 
			
		||||
  - "1.11.x"
 | 
			
		||||
 | 
			
		||||
after_success:
 | 
			
		||||
  - test -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
FROM golang:alpine as builder
 | 
			
		||||
 | 
			
		||||
RUN apk add --no-cache \
 | 
			
		||||
        git \
 | 
			
		||||
        make \
 | 
			
		||||
        gcc \
 | 
			
		||||
        musl-dev
 | 
			
		||||
 | 
			
		||||
ENV REPOSITORY github.com/future-architect/vuls
 | 
			
		||||
COPY . $GOPATH/src/$REPOSITORY
 | 
			
		||||
RUN cd $GOPATH/src/$REPOSITORY && make install
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FROM alpine:3.7
 | 
			
		||||
 | 
			
		||||
MAINTAINER hikachan sadayuki-matsuno
 | 
			
		||||
 | 
			
		||||
ENV LOGDIR /var/log/vuls
 | 
			
		||||
ENV WORKDIR /vuls
 | 
			
		||||
 | 
			
		||||
RUN apk add --no-cache \
 | 
			
		||||
        openssh-client \
 | 
			
		||||
        ca-certificates \
 | 
			
		||||
    && mkdir -p $WORKDIR $LOGDIR
 | 
			
		||||
 | 
			
		||||
COPY --from=builder /go/bin/vuls /usr/local/bin/
 | 
			
		||||
 | 
			
		||||
VOLUME [$WORKDIR, $LOGDIR]
 | 
			
		||||
WORKDIR $WORKDIR
 | 
			
		||||
ENV PWD $WORKDIR
 | 
			
		||||
 | 
			
		||||
ENTRYPOINT ["vuls"]
 | 
			
		||||
CMD ["--help"]
 | 
			
		||||
							
								
								
									
										27
									
								
								GNUmakefile
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								GNUmakefile
									
									
									
									
									
								
							@@ -15,21 +15,22 @@
 | 
			
		||||
	clean
 | 
			
		||||
 | 
			
		||||
SRCS = $(shell git ls-files '*.go')
 | 
			
		||||
PKGS = ./. ./cache ./commands ./config ./models ./oval ./report ./scan ./util 
 | 
			
		||||
PKGS = $(shell go list ./...)
 | 
			
		||||
VERSION := $(shell git describe --tags --abbrev=0)
 | 
			
		||||
REVISION := $(shell git rev-parse --short HEAD)
 | 
			
		||||
LDFLAGS := -X 'main.version=$(VERSION)' \
 | 
			
		||||
	-X 'main.revision=$(REVISION)'
 | 
			
		||||
BUILDTIME := $(shell date "+%Y%m%d_%H%M%S")
 | 
			
		||||
LDFLAGS := -X 'github.com/future-architect/vuls/config.Version=$(VERSION)' \
 | 
			
		||||
    -X 'github.com/future-architect/vuls/config.Revision=build-$(BUILDTIME)_$(REVISION)'
 | 
			
		||||
 | 
			
		||||
all: dep build test
 | 
			
		||||
all: dep build
 | 
			
		||||
 | 
			
		||||
dep:
 | 
			
		||||
	go get -u github.com/golang/dep/...
 | 
			
		||||
	dep ensure
 | 
			
		||||
	dep ensure -v
 | 
			
		||||
 | 
			
		||||
depup:
 | 
			
		||||
	go get -u github.com/golang/dep/...
 | 
			
		||||
	dep ensure -update
 | 
			
		||||
	dep ensure -update -v
 | 
			
		||||
 | 
			
		||||
build: main.go dep pretest
 | 
			
		||||
	go build -ldflags "$(LDFLAGS)" -o vuls $<
 | 
			
		||||
@@ -39,26 +40,28 @@ install: main.go dep pretest
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
lint:
 | 
			
		||||
	@ go get -v github.com/golang/lint/golint
 | 
			
		||||
	$(foreach file,$(SRCS),golint $(file) || exit;)
 | 
			
		||||
	@ go get -v golang.org/x/lint/golint
 | 
			
		||||
	golint $(PKGS)
 | 
			
		||||
 | 
			
		||||
vet:
 | 
			
		||||
	#  @-go get -v golang.org/x/tools/cmd/vet
 | 
			
		||||
	echo $(PKGS) | xargs go vet || exit;
 | 
			
		||||
	go vet ./... || exit;
 | 
			
		||||
 | 
			
		||||
fmt:
 | 
			
		||||
	gofmt -s -w $(SRCS)
 | 
			
		||||
 | 
			
		||||
mlint:
 | 
			
		||||
	$(foreach file,$(SRCS),gometalinter $(file) || exit;)
 | 
			
		||||
 | 
			
		||||
fmtcheck:
 | 
			
		||||
	$(foreach file,$(SRCS),gofmt -s -d $(file);)
 | 
			
		||||
 | 
			
		||||
pretest: lint vet fmtcheck
 | 
			
		||||
 | 
			
		||||
test: pretest
 | 
			
		||||
	go install
 | 
			
		||||
test: 
 | 
			
		||||
	echo $(PKGS) | xargs go test -cover -v || exit;
 | 
			
		||||
 | 
			
		||||
unused :
 | 
			
		||||
unused:
 | 
			
		||||
	$(foreach pkg,$(PKGS),unused $(pkg);)
 | 
			
		||||
 | 
			
		||||
cov:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1061
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1061
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										83
									
								
								Gopkg.toml
									
									
									
									
									
								
							
							
						
						
									
										83
									
								
								Gopkg.toml
									
									
									
									
									
								
							@@ -1,7 +1,6 @@
 | 
			
		||||
 | 
			
		||||
# Gopkg.toml example
 | 
			
		||||
#
 | 
			
		||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
 | 
			
		||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
 | 
			
		||||
# for detailed Gopkg.toml documentation.
 | 
			
		||||
#
 | 
			
		||||
# required = ["github.com/user/thing/cmd/thing"]
 | 
			
		||||
@@ -17,78 +16,26 @@
 | 
			
		||||
#   source = "github.com/myfork/project2"
 | 
			
		||||
#
 | 
			
		||||
# [[override]]
 | 
			
		||||
#  name = "github.com/x/y"
 | 
			
		||||
#  version = "2.4.0"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/BurntSushi/toml"
 | 
			
		||||
  version = "0.3.0"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/asaskevich/govalidator"
 | 
			
		||||
  version = "6.0.0"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/boltdb/bolt"
 | 
			
		||||
  version = "1.3.1"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/cenkalti/backoff"
 | 
			
		||||
  version = "1.0.0"
 | 
			
		||||
#   name = "github.com/x/y"
 | 
			
		||||
#   version = "2.4.0"
 | 
			
		||||
#
 | 
			
		||||
# [prune]
 | 
			
		||||
#   non-go = false
 | 
			
		||||
#   go-tests = true
 | 
			
		||||
#   unused-packages = true
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/knqyf263/gost"
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/google/subcommands"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/gosuri/uitable"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/howeyc/gopass"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/jroimartin/gocui"
 | 
			
		||||
  version = "0.3.0"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/k0kubun/pp"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/knqyf263/go-deb-version"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/knqyf263/go-rpm-version"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/kotakanbe/go-pingscanner"
 | 
			
		||||
  version = "0.1.0"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/kotakanbe/logrus-prefixed-formatter"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/parnurzeal/gorequest"
 | 
			
		||||
  version = "0.2.15"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/rifflock/lfshook"
 | 
			
		||||
  version = "1.7.0"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/sirupsen/logrus"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/kotakanbe/go-cve-dictionary"
 | 
			
		||||
  branch = "master"
 | 
			
		||||
 | 
			
		||||
[[constraint]]
 | 
			
		||||
  name = "github.com/mozqnet/go-exploitdb"
 | 
			
		||||
  branch = "master"
 | 
			
		||||
  name = "github.com/kotakanbe/goval-dictionary"
 | 
			
		||||
 | 
			
		||||
[prune]
 | 
			
		||||
  go-tests = true
 | 
			
		||||
  unused-packages = true
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								LICENSE
									
									
									
									
									
								
							@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
 | 
			
		||||
the "copyright" line and a pointer to where the full notice is found.
 | 
			
		||||
 | 
			
		||||
    Vuls - Vulnerability Scanner
 | 
			
		||||
    Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
    Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
 | 
			
		||||
  If the program does terminal interaction, make it output a short
 | 
			
		||||
notice like this when it starts in an interactive mode:
 | 
			
		||||
 | 
			
		||||
    Vuls  Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
    Vuls  Copyright (C) 2016  Future Corporation , Japan.
 | 
			
		||||
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
 | 
			
		||||
    This is free software, and you are welcome to redistribute it
 | 
			
		||||
    under certain conditions; type `show c' for details.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								NOTICE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								NOTICE
									
									
									
									
									
								
							@@ -1,2 +1,2 @@
 | 
			
		||||
Vuls Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Vuls Copyright (C) 2016  Future Corporation , Japan.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1942
									
								
								README.ja.md
									
									
									
									
									
								
							
							
						
						
									
										1942
									
								
								README.ja.md
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2897
									
								
								alert/alert_jp.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2897
									
								
								alert/alert_jp.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										920
									
								
								alert/alert_us.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										920
									
								
								alert/alert_us.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,920 @@
 | 
			
		||||
package alert
 | 
			
		||||
 | 
			
		||||
// AlertDictEn has USCERT alerts
 | 
			
		||||
var AlertDictEn = map[string]Alert{
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA08-352A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA08-352A",
 | 
			
		||||
		Title: `Microsoft Internet Explorer Data Binding Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA08-350A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA08-350A",
 | 
			
		||||
		Title: `Apple Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA08-344A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA08-344A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA08-340A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA08-340A",
 | 
			
		||||
		Title: `Sun Java Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA08-319A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA08-319A",
 | 
			
		||||
		Title: `Mozilla Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-132A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-132A",
 | 
			
		||||
		Title: `Microsoft PowerPoint Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-041A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-041A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-343A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-343A",
 | 
			
		||||
		Title: `Adobe Flash Vulnerabilities Affect Flash Player and Adobe AIR`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-218A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-218A",
 | 
			
		||||
		Title: `Apple Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-195A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-195A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-342A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-342A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-286B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-286B",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-160B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-160B",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-069A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-069A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-223A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-223A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-013A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-013A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple SMB Protocol Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-294A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-294A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-020A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-020A",
 | 
			
		||||
		Title: `Microsoft Windows Does Not Disable AutoRun Properly`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-133A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-133A",
 | 
			
		||||
		Title: `Apple Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-022A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-022A",
 | 
			
		||||
		Title: `Apple QuickTime Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-051A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-051A",
 | 
			
		||||
		Title: `Adobe Acrobat and Reader Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-015A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-015A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-251A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-251A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-209A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-209A",
 | 
			
		||||
		Title: `Microsoft Windows, Internet Explorer, and Active Template Library (ATL) Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-204A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-204A",
 | 
			
		||||
		Title: `Adobe Flash Vulnerability Affects Flash Player and Other Adobe Products`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-161A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-161A",
 | 
			
		||||
		Title: `Adobe Acrobat and Reader Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-133B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-133B",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat JavaScript Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-088A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-088A",
 | 
			
		||||
		Title: `Conficker Worm Targets Microsoft Windows Systems`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-314A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-314A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-105A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-105A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-104A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-104A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-286A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-286A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA09-187A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA09-187A",
 | 
			
		||||
		Title: `Microsoft Video ActiveX Control Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-238A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-238A",
 | 
			
		||||
		Title: `Microsoft Windows Insecurely Loads Dynamic Libraries`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-159B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-159B",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-103B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-103B",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-021A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-021A",
 | 
			
		||||
		Title: `Microsoft Internet Explorer Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-012A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-012A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-313A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-313A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-285A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-285A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-263A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-263A",
 | 
			
		||||
		Title: `Adobe Flash Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-103C": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-103C",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-040A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-040A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-194B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-194B",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-194A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-194A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-131A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-131A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-068A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-068A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-348A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-348A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-257A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-257A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-231A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-231A",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-222A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-222A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-162A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-162A",
 | 
			
		||||
		Title: `Adobe Flash and AIR Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-159A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-159A",
 | 
			
		||||
		Title: `Adobe Flash, Reader, and Acrobat Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-089A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-089A",
 | 
			
		||||
		Title: `Microsoft Internet Explorer Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-013A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-013A",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-287A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-287A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-279A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-279A",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Affected by Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-223A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-223A",
 | 
			
		||||
		Title: `Adobe Flash and AIR Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA10-012B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA10-012B",
 | 
			
		||||
		Title: `Microsoft Windows EOT Font and Adobe Flash Player 6 Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-165A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-165A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-067A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-067A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-039A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-039A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-222A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-222A",
 | 
			
		||||
		Title: `Adobe Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-193A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-193A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-201A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-201A",
 | 
			
		||||
		Title: `Oracle Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-166A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-166A",
 | 
			
		||||
		Title: `Adobe Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-130A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-130A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-312A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-312A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-286A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-286A",
 | 
			
		||||
		Title: `Apple Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-350A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-350A",
 | 
			
		||||
		Title: `Adobe Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-221A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-221A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-256A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-256A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-200A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-200A",
 | 
			
		||||
		Title: `Security Recommendations to Prevent Cyber Intrusions`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-102A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-102A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-011A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-011A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-347A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-347A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA11-284A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA11-284A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-262A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-262A",
 | 
			
		||||
		Title: `Microsoft Security Advisory for Internet Explorer Exploit`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-240A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-240A",
 | 
			
		||||
		Title: `Oracle Java 7 Security Manager Bypass Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-227A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-227A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-129A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-129A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-101B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-101B",
 | 
			
		||||
		Title: `Adobe Reader and Acrobat Security Updates and Architectural Improvements`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-010A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-010A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-006A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-006A",
 | 
			
		||||
		Title: `Wi-Fi Protected Setup (WPS) Vulnerable to Brute-Force Attack`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-265A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-265A",
 | 
			
		||||
		Title: `Microsoft Releases Patch for Internet Explorer Exploit`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-255A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-255A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-251A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-251A",
 | 
			
		||||
		Title: `Microsoft Update For Minimum Certificate Key Length`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-174A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-174A",
 | 
			
		||||
		Title: `Microsoft XML Core Services Attack Activity`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-164A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-164A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-101A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-101A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-318A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-318A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-283A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-283A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-346A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-346A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-192A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-192A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-073A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-073A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-045A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-045A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA12-024A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA12-024A",
 | 
			
		||||
		Title: `"Anonymous" DDoS Activity`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-134A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-134A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-043B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-043B",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-008A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-008A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-051A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-051A",
 | 
			
		||||
		Title: `Oracle Java Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-043A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-043A",
 | 
			
		||||
		Title: `Adobe Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-225A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-225A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-207A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-207A",
 | 
			
		||||
		Title: `Risks of Using the Intelligent Platform Management Interface (IPMI)`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-141A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-141A",
 | 
			
		||||
		Title: `Washington, DC Radio Station Web Site Compromises`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-175A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-175A",
 | 
			
		||||
		Title: `Risks of Default Passwords on the Internet`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-169A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-169A",
 | 
			
		||||
		Title: `Oracle Releases Updates for Javadoc and Other Java SE Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-168A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-168A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-100A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-100A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-088A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-088A",
 | 
			
		||||
		Title: `DNS Amplification Attacks`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-317A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-317A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-309A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-309A",
 | 
			
		||||
		Title: `CryptoLocker Ransomware Infections`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-288A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-288A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-064A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-064A",
 | 
			
		||||
		Title: `Oracle Java Contains Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-032A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-032A",
 | 
			
		||||
		Title: `Oracle Java Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-024A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-024A",
 | 
			
		||||
		Title: `Content Management Systems Security and Associated Risks`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-107A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-107A",
 | 
			
		||||
		Title: `Oracle Has Released Multiple Updates for Java SE`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-071A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-071A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-015A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-015A",
 | 
			
		||||
		Title: `Microsoft Releases Update for Internet Explorer Vulnerability CVE-2012-4792`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-010A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-010A",
 | 
			
		||||
		Title: `Oracle Java 7 Security Manager Bypass Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-253A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-253A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-193A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-193A",
 | 
			
		||||
		Title: `Exploit Tool Targets Vulnerabilities in McAfee ePolicy Orchestrator (ePO)`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA13-190A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA13-190A",
 | 
			
		||||
		Title: `Microsoft Updates for Multiple Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-323A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-323A",
 | 
			
		||||
		Title: `Microsoft Windows Kerberos KDC Remote Privilege Escalation Vulnerability `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-300A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-300A",
 | 
			
		||||
		Title: `Phishing Campaign Linked with “Dyre” Banking Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-295A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-295A",
 | 
			
		||||
		Title: `Crypto Ransomware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-318B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-318B",
 | 
			
		||||
		Title: `Microsoft Windows OLE Automation Array Remote Code Execution Vulnerability `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-317A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-317A",
 | 
			
		||||
		Title: `Apple iOS 'Masque Attack' Technique`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-290A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-290A",
 | 
			
		||||
		Title: `SSL 3.0 Protocol Vulnerability and POODLE Attack`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-017A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-017A",
 | 
			
		||||
		Title: `UDP-Based Amplification Attacks`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-002A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-002A",
 | 
			
		||||
		Title: `Malware Targeting Point of Sale Systems`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-318A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-318A",
 | 
			
		||||
		Title: `Microsoft Secure Channel (Schannel) Vulnerability (CVE-2014-6321) `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-310A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-310A",
 | 
			
		||||
		Title: `Microsoft Ending Support for Windows Server 2003 Operating System`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-268A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-268A",
 | 
			
		||||
		Title: `GNU Bourne-Again Shell (Bash) ‘Shellshock’ Vulnerability (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277 and CVE 2014-6278) `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-098A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-098A",
 | 
			
		||||
		Title: `OpenSSL 'Heartbleed' vulnerability (CVE-2014-0160)`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-353A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-353A",
 | 
			
		||||
		Title: `Targeted Destructive Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-329A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-329A",
 | 
			
		||||
		Title: `Regin Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-212A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-212A",
 | 
			
		||||
		Title: `Backoff Point-of-Sale Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-150A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-150A",
 | 
			
		||||
		Title: `GameOver Zeus P2P Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA14-013A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA14-013A",
 | 
			
		||||
		Title: `NTP Amplification Attacks Using CVE-2013-5211`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-195A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-195A",
 | 
			
		||||
		Title: `Adobe Flash and Microsoft Windows Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-337A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-337A",
 | 
			
		||||
		Title: `Dorkbot`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-240A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-240A",
 | 
			
		||||
		Title: `Controlling Outbound DNS Access`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-213A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-213A",
 | 
			
		||||
		Title: `Recent Email Phishing Campaigns – Mitigation and Response Recommendations`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-120A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-120A",
 | 
			
		||||
		Title: `Securing End-to-End Communications`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-119A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-119A",
 | 
			
		||||
		Title: `Top 30 Targeted High Risk Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-105A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-105A",
 | 
			
		||||
		Title: `Simda Botnet`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-103A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-103A",
 | 
			
		||||
		Title: `DNS Zone Transfer AXFR Requests May Leak Domain Information`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-098A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-098A",
 | 
			
		||||
		Title: `AAEH`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-314A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-314A",
 | 
			
		||||
		Title: `Compromised Web Servers and Web Shells - Threat Awareness and Guidance `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-286A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-286A",
 | 
			
		||||
		Title: `Dridex P2P Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA15-051A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA15-051A",
 | 
			
		||||
		Title: `Lenovo Superfish Adware Vulnerable to HTTPS Spoofing`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-187A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-187A",
 | 
			
		||||
		Title: `Symantec and Norton Security Products Contain Critical Vulnerabilities`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-144A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-144A",
 | 
			
		||||
		Title: `WPAD Name Collision Vulnerability`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-132A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-132A",
 | 
			
		||||
		Title: `Exploitation of SAP Business Applications`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-105A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-105A",
 | 
			
		||||
		Title: `Apple Ends Support for QuickTime for Windows; New Vulnerabilities Announced`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-091A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-091A",
 | 
			
		||||
		Title: `Ransomware and Recent Variants`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-336A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-336A",
 | 
			
		||||
		Title: `Avalanche (crimeware-as-a-service infrastructure)`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-288A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-288A",
 | 
			
		||||
		Title: `Heightened DDoS Threat Posed by Mirai and Other Botnets`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA16-250A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA16-250A",
 | 
			
		||||
		Title: `The Increasing Threat to Network Infrastructure Devices and Recommended Mitigations`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-117A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-117A",
 | 
			
		||||
		Title: `Intrusions Affecting Multiple Victims Across Multiple Sectors`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-318B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-318B",
 | 
			
		||||
		Title: `HIDDEN COBRA – North Korean Trojan: Volgmer`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-318A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-318A",
 | 
			
		||||
		Title: `HIDDEN COBRA – North Korean Remote Administration Tool: FALLCHILL`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-181A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-181A",
 | 
			
		||||
		Title: `Petya Ransomware `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-132A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-132A",
 | 
			
		||||
		Title: `Indicators Associated With WannaCry Ransomware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-075A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-075A",
 | 
			
		||||
		Title: `HTTPS Interception Weakens TLS Security`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-293A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-293A",
 | 
			
		||||
		Title: `Advanced Persistent Threat Activity Targeting Energy and Other Critical Infrastructure Sectors`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-164A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-164A",
 | 
			
		||||
		Title: `HIDDEN COBRA – North Korea’s DDoS Botnet Infrastructure`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-163A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-163A",
 | 
			
		||||
		Title: `CrashOverride Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA17-156A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA17-156A",
 | 
			
		||||
		Title: `Reducing the Risk of SNMP Abuse`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-141A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-141A",
 | 
			
		||||
		Title: `Side-Channel Vulnerability Variants 3a and 4`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-086A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-086A",
 | 
			
		||||
		Title: `Brute Force Attacks Conducted by Cyber Actors `,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-004A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-004A",
 | 
			
		||||
		Title: `Meltdown and Spectre Side-Channel Vulnerability Guidance`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-331A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-331A",
 | 
			
		||||
		Title: `3ve – Major Online Ad Fraud Operation`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/AA18-284A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/AA18-284A",
 | 
			
		||||
		Title: `Publicly Available Tools Seen in Cyber Incidents Worldwide`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-276B": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-276B",
 | 
			
		||||
		Title: `Advanced Persistent Threat Activity Exploiting Managed Service Providers`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-275A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-275A",
 | 
			
		||||
		Title: `HIDDEN COBRA – FASTCash Campaign`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-201A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-201A",
 | 
			
		||||
		Title: `Emotet Malware`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-276A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-276A",
 | 
			
		||||
		Title: `Using Rigorous Credential Control to Mitigate Trusted Network Exploitation`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-149A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-149A",
 | 
			
		||||
		Title: `HIDDEN COBRA – Joanap Backdoor Trojan and Brambul Server Message Block Worm`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-145A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-145A",
 | 
			
		||||
		Title: `Cyber Actors Target Home and Office Routers and Networked Devices Worldwide`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-106A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-106A",
 | 
			
		||||
		Title: `Russian State-Sponsored Cyber Actors Targeting Network Infrastructure Devices`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
	"https://www.us-cert.gov/ncas/alerts/TA18-074A": {
 | 
			
		||||
		URL:   "https://www.us-cert.gov/ncas/alerts/TA18-074A",
 | 
			
		||||
		Title: `Russian Government Cyber Activity Targeting Energy and Other Critical Infrastructure Sectors`,
 | 
			
		||||
		Team:  "us",
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										534
									
								
								alert/cve_jp.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										534
									
								
								alert/cve_jp.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,534 @@
 | 
			
		||||
package alert
 | 
			
		||||
 | 
			
		||||
// CveDictJa has CVE-ID key which included JPCERT alerts
 | 
			
		||||
var CveDictJa = map[string][]string{
 | 
			
		||||
	"CVE-2006-0003":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2006-0005":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2006-1173":    {"https://www.jpcert.or.jp/at/2006/at060008.html"},
 | 
			
		||||
	"CVE-2006-3014":    {"https://www.jpcert.or.jp/at/2006/at060009.html"},
 | 
			
		||||
	"CVE-2006-3059":    {"https://www.jpcert.or.jp/at/2006/at060009.html"},
 | 
			
		||||
	"CVE-2006-3086":    {"https://www.jpcert.or.jp/at/2006/at060009.html"},
 | 
			
		||||
	"CVE-2006-3643":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2006-3730":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2006-3877":    {"https://www.jpcert.or.jp/at/2007/at070005.html"},
 | 
			
		||||
	"CVE-2006-5198":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2006-5745":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2007-0015":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2007-0038":    {"https://www.jpcert.or.jp/at/2007/at070016.html"},
 | 
			
		||||
	"CVE-2008-4609":    {"https://www.jpcert.or.jp/at/2009/at090019.html"},
 | 
			
		||||
	"CVE-2010-0886":    {"https://www.jpcert.or.jp/at/2010/at100010.html"},
 | 
			
		||||
	"CVE-2010-0887":    {"https://www.jpcert.or.jp/at/2010/at100010.html"},
 | 
			
		||||
	"CVE-2011-1910":    {"https://www.jpcert.or.jp/at/2011/at110014.html"},
 | 
			
		||||
	"CVE-2011-2444":    {"https://www.jpcert.or.jp/at/2011/at110026.html"},
 | 
			
		||||
	"CVE-2011-2462":    {"https://www.jpcert.or.jp/at/2011/at110034.html"},
 | 
			
		||||
	"CVE-2011-2465":    {"https://www.jpcert.or.jp/at/2011/at110019.html"},
 | 
			
		||||
	"CVE-2011-3192":    {"https://www.jpcert.or.jp/at/2011/at110023.html"},
 | 
			
		||||
	"CVE-2011-3348":    {"https://www.jpcert.or.jp/at/2011/at110023.html"},
 | 
			
		||||
	"CVE-2011-3544":    {"https://www.jpcert.or.jp/at/2011/at110032.html"},
 | 
			
		||||
	"CVE-2011-4313":    {"https://www.jpcert.or.jp/at/2011/at110031.html"},
 | 
			
		||||
	"CVE-2012-0002":    {"https://www.jpcert.or.jp/at/2012/at120009.html"},
 | 
			
		||||
	"CVE-2012-0507":    {"https://www.jpcert.or.jp/at/2012/at120010.html"},
 | 
			
		||||
	"CVE-2012-0767":    {"https://www.jpcert.or.jp/at/2012/at120006.html"},
 | 
			
		||||
	"CVE-2012-0779":    {"https://www.jpcert.or.jp/at/2012/at120014.html"},
 | 
			
		||||
	"CVE-2012-0830":    {"https://www.jpcert.or.jp/at/2012/at120004.html"},
 | 
			
		||||
	"CVE-2012-2311":    {"https://www.jpcert.or.jp/at/2012/at120016.html"},
 | 
			
		||||
	"CVE-2012-4244":    {"https://www.jpcert.or.jp/at/2012/at120029.html"},
 | 
			
		||||
	"CVE-2012-4681":    {"https://www.jpcert.or.jp/at/2012/at120028.html"},
 | 
			
		||||
	"CVE-2012-4969":    {"https://www.jpcert.or.jp/at/2012/at120030.html"},
 | 
			
		||||
	"CVE-2012-5166":    {"https://www.jpcert.or.jp/at/2012/at120033.html"},
 | 
			
		||||
	"CVE-2013-0422":    {"https://www.jpcert.or.jp/at/2013/at130004.html"},
 | 
			
		||||
	"CVE-2013-1493":    {"https://www.jpcert.or.jp/at/2013/at130014.html"},
 | 
			
		||||
	"CVE-2013-2266":    {"https://www.jpcert.or.jp/at/2013/at130017.html"},
 | 
			
		||||
	"CVE-2013-2494":    {"https://www.jpcert.or.jp/at/2013/at130017.html"},
 | 
			
		||||
	"CVE-2013-3893":    {"https://www.jpcert.or.jp/at/2013/at130040.html", "https://www.jpcert.or.jp/at/2013/at130041.html"},
 | 
			
		||||
	"CVE-2013-3906":    {"https://www.jpcert.or.jp/at/2013/at130044.html"},
 | 
			
		||||
	"CVE-2013-3918":    {"https://www.jpcert.or.jp/at/2013/at130045.html"},
 | 
			
		||||
	"CVE-2013-3919":    {"https://www.jpcert.or.jp/at/2013/at130026.html"},
 | 
			
		||||
	"CVE-2013-4854":    {"https://www.jpcert.or.jp/at/2013/at130034.html"},
 | 
			
		||||
	"CVE-2014-0050":    {"https://www.jpcert.or.jp/at/2014/at140007.html"},
 | 
			
		||||
	"CVE-2014-0160":    {"https://www.jpcert.or.jp/at/2014/at140013.html"},
 | 
			
		||||
	"CVE-2014-0322":    {"https://www.jpcert.or.jp/at/2014/at140009.html"},
 | 
			
		||||
	"CVE-2014-1776":    {"https://www.jpcert.or.jp/at/2014/at140018.html", "https://www.jpcert.or.jp/at/2014/at140020.html"},
 | 
			
		||||
	"CVE-2014-3383":    {"https://www.jpcert.or.jp/at/2015/at150021.html"},
 | 
			
		||||
	"CVE-2014-3859":    {"https://www.jpcert.or.jp/at/2014/at140027.html"},
 | 
			
		||||
	"CVE-2014-4114":    {"https://www.jpcert.or.jp/at/2014/at140039.html"},
 | 
			
		||||
	"CVE-2014-6271":    {"https://www.jpcert.or.jp/at/2014/at140037.html", "https://www.jpcert.or.jp/at/2014/at140038.html"},
 | 
			
		||||
	"CVE-2014-6277":    {"https://www.jpcert.or.jp/at/2014/at140037.html"},
 | 
			
		||||
	"CVE-2014-6278":    {"https://www.jpcert.or.jp/at/2014/at140037.html"},
 | 
			
		||||
	"CVE-2014-6324":    {"https://www.jpcert.or.jp/at/2014/at140048.html"},
 | 
			
		||||
	"CVE-2014-6332":    {"https://www.jpcert.or.jp/at/2015/at150015.html"},
 | 
			
		||||
	"CVE-2014-6352":    {"https://www.jpcert.or.jp/at/2014/at140043.html"},
 | 
			
		||||
	"CVE-2014-7169":    {"https://www.jpcert.or.jp/at/2014/at140037.html"},
 | 
			
		||||
	"CVE-2014-7186":    {"https://www.jpcert.or.jp/at/2014/at140037.html"},
 | 
			
		||||
	"CVE-2014-7187":    {"https://www.jpcert.or.jp/at/2014/at140037.html"},
 | 
			
		||||
	"CVE-2014-8361":    {"https://www.jpcert.or.jp/at/2017/at170049.html"},
 | 
			
		||||
	"CVE-2014-8500":    {"https://www.jpcert.or.jp/at/2014/at140050.html"},
 | 
			
		||||
	"CVE-2014-9163":    {"https://www.jpcert.or.jp/at/2014/at140052.html"},
 | 
			
		||||
	"CVE-2015-0313":    {"https://www.jpcert.or.jp/at/2015/at150015.html"},
 | 
			
		||||
	"CVE-2015-1769":    {"https://www.jpcert.or.jp/at/2015/at150028.html"},
 | 
			
		||||
	"CVE-2015-5119":    {"https://www.jpcert.or.jp/at/2015/at150019.html"},
 | 
			
		||||
	"CVE-2015-5122":    {"https://www.jpcert.or.jp/at/2015/at150020.html"},
 | 
			
		||||
	"CVE-2015-5123":    {"https://www.jpcert.or.jp/at/2015/at150020.html"},
 | 
			
		||||
	"CVE-2015-5477":    {"https://www.jpcert.or.jp/at/2015/at150027.html"},
 | 
			
		||||
	"CVE-2015-5986":    {"https://www.jpcert.or.jp/at/2015/at150031.html"},
 | 
			
		||||
	"CVE-2015-6835":    {"https://www.jpcert.or.jp/at/2016/at160036.html"},
 | 
			
		||||
	"CVE-2015-7547":    {"https://www.jpcert.or.jp/at/2016/at160009.html"},
 | 
			
		||||
	"CVE-2015-7645":    {"https://www.jpcert.or.jp/at/2015/at150036.html", "https://www.jpcert.or.jp/at/2015/at150037.html"},
 | 
			
		||||
	"CVE-2015-8000":    {"https://www.jpcert.or.jp/at/2015/at150043.html"},
 | 
			
		||||
	"CVE-2015-8461":    {"https://www.jpcert.or.jp/at/2015/at150043.html"},
 | 
			
		||||
	"CVE-2015-8562":    {"https://www.jpcert.or.jp/at/2016/at160036.html"},
 | 
			
		||||
	"CVE-2015-8651":    {"https://www.jpcert.or.jp/at/2016/at160001.html"},
 | 
			
		||||
	"CVE-2015-8704":    {"https://www.jpcert.or.jp/at/2016/at160006.html"},
 | 
			
		||||
	"CVE-2015-8705":    {"https://www.jpcert.or.jp/at/2016/at160006.html"},
 | 
			
		||||
	"CVE-2016-0189":    {"https://www.jpcert.or.jp/at/2016/at160022.html"},
 | 
			
		||||
	"CVE-2016-0636":    {"https://www.jpcert.or.jp/at/2016/at160015.html"},
 | 
			
		||||
	"CVE-2016-0800":    {"https://www.jpcert.or.jp/at/2016/at160010.html"},
 | 
			
		||||
	"CVE-2016-1000109": {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-1000110": {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-1010":    {"https://www.jpcert.or.jp/at/2016/at160014.html"},
 | 
			
		||||
	"CVE-2016-1019":    {"https://www.jpcert.or.jp/at/2016/at160016.html"},
 | 
			
		||||
	"CVE-2016-1204":    {"https://www.jpcert.or.jp/at/2016/at160019.html"},
 | 
			
		||||
	"CVE-2016-1286":    {"https://www.jpcert.or.jp/at/2016/at160013.html", "https://www.jpcert.or.jp/at/2016/at160037.html"},
 | 
			
		||||
	"CVE-2016-2776":    {"https://www.jpcert.or.jp/at/2016/at160037.html"},
 | 
			
		||||
	"CVE-2016-3081":    {"https://www.jpcert.or.jp/at/2016/at160020.html"},
 | 
			
		||||
	"CVE-2016-3227":    {"https://www.jpcert.or.jp/at/2016/at160025.html"},
 | 
			
		||||
	"CVE-2016-3714":    {"https://www.jpcert.or.jp/at/2016/at160021.html"},
 | 
			
		||||
	"CVE-2016-3715":    {"https://www.jpcert.or.jp/at/2016/at160021.html"},
 | 
			
		||||
	"CVE-2016-3716":    {"https://www.jpcert.or.jp/at/2016/at160021.html"},
 | 
			
		||||
	"CVE-2016-3717":    {"https://www.jpcert.or.jp/at/2016/at160021.html"},
 | 
			
		||||
	"CVE-2016-3718":    {"https://www.jpcert.or.jp/at/2016/at160021.html"},
 | 
			
		||||
	"CVE-2016-4117":    {"https://www.jpcert.or.jp/at/2016/at160024.html"},
 | 
			
		||||
	"CVE-2016-4171":    {"https://www.jpcert.or.jp/at/2016/at160026.html"},
 | 
			
		||||
	"CVE-2016-4438":    {"https://www.jpcert.or.jp/at/2016/at160027.html"},
 | 
			
		||||
	"CVE-2016-5385":    {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-5386":    {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-5387":    {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-5388":    {"https://www.jpcert.or.jp/at/2016/at160031.html"},
 | 
			
		||||
	"CVE-2016-6307":    {"https://www.jpcert.or.jp/at/2016/at160038.html"},
 | 
			
		||||
	"CVE-2016-6309":    {"https://www.jpcert.or.jp/at/2016/at160038.html"},
 | 
			
		||||
	"CVE-2016-7189":    {"https://www.jpcert.or.jp/at/2016/at160039.html"},
 | 
			
		||||
	"CVE-2016-7836":    {"https://www.jpcert.or.jp/at/2016/at160051.html", "https://www.jpcert.or.jp/at/2017/at170023.html"},
 | 
			
		||||
	"CVE-2016-7855":    {"https://www.jpcert.or.jp/at/2016/at160039.html", "https://www.jpcert.or.jp/at/2016/at160043.html"},
 | 
			
		||||
	"CVE-2016-7892":    {"https://www.jpcert.or.jp/at/2016/at160048.html", "https://www.jpcert.or.jp/at/2016/at160049.html"},
 | 
			
		||||
	"CVE-2016-8864":    {"https://www.jpcert.or.jp/at/2016/at160044.html"},
 | 
			
		||||
	"CVE-2016-9131":    {"https://www.jpcert.or.jp/at/2017/at170004.html"},
 | 
			
		||||
	"CVE-2016-9147":    {"https://www.jpcert.or.jp/at/2017/at170004.html"},
 | 
			
		||||
	"CVE-2016-9444":    {"https://www.jpcert.or.jp/at/2017/at170004.html"},
 | 
			
		||||
	"CVE-2016-9778":    {"https://www.jpcert.or.jp/at/2017/at170004.html"},
 | 
			
		||||
	"CVE-2017-0093":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0106":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0145":    {"https://www.jpcert.or.jp/at/2017/at170020.html"},
 | 
			
		||||
	"CVE-2017-0158":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0160":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0161":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-0162":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0163":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0180":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0181":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0199":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0200":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0201":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0202":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0205":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0210":    {"https://www.jpcert.or.jp/at/2017/at170015.html"},
 | 
			
		||||
	"CVE-2017-0221":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0222":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0224":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0227":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0228":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0229":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0235":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0236":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0240":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0250":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-0261":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0263":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0266":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0272":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0277":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0278":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0279":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0283":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-0290":    {"https://www.jpcert.or.jp/at/2017/at170019.html"},
 | 
			
		||||
	"CVE-2017-0291":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-0292":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-0293":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-0294":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-0781":    {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-0782":    {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-0783":    {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-0785":    {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-1000250": {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-1000251": {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-10271":   {"https://www.jpcert.or.jp/at/2018/at180004.html"},
 | 
			
		||||
	"CVE-2017-10845":   {"https://www.jpcert.or.jp/at/2017/at170034.html"},
 | 
			
		||||
	"CVE-2017-10846":   {"https://www.jpcert.or.jp/at/2017/at170034.html"},
 | 
			
		||||
	"CVE-2017-11223":   {"https://www.jpcert.or.jp/at/2017/at170031.html"},
 | 
			
		||||
	"CVE-2017-11292":   {"https://www.jpcert.or.jp/at/2017/at170040.html"},
 | 
			
		||||
	"CVE-2017-11762":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11763":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11764":   {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-11766":   {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-11771":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11779":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11792":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11793":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11796":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11798":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11799":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11800":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11802":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11804":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11805":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11806":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11807":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11808":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11809":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11810":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11811":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11812":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11813":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11819":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11821":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11822":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11826":   {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-11836":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11837":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11838":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11839":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11840":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11841":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11843":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11845":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11846":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11855":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11856":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11858":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11861":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11862":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11866":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11869":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11870":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11871":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11873":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11882":   {"https://www.jpcert.or.jp/at/2017/at170044.html"},
 | 
			
		||||
	"CVE-2017-11886":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11888":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11889":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11890":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11893":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11894":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11895":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11901":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11903":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11905":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11907":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11908":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11909":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11910":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11911":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11912":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11914":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11918":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11930":   {"https://www.jpcert.or.jp/at/2017/at170048.html"},
 | 
			
		||||
	"CVE-2017-11937":   {"https://www.jpcert.or.jp/at/2017/at170046.html"},
 | 
			
		||||
	"CVE-2017-12615":   {"https://www.jpcert.or.jp/at/2017/at170038.html"},
 | 
			
		||||
	"CVE-2017-12616":   {"https://www.jpcert.or.jp/at/2017/at170038.html"},
 | 
			
		||||
	"CVE-2017-12617":   {"https://www.jpcert.or.jp/at/2017/at170038.html"},
 | 
			
		||||
	"CVE-2017-13872":   {"https://www.jpcert.or.jp/at/2017/at170045.html"},
 | 
			
		||||
	"CVE-2017-14315":   {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-3135":    {"https://www.jpcert.or.jp/at/2017/at170007.html"},
 | 
			
		||||
	"CVE-2017-3136":    {"https://www.jpcert.or.jp/at/2017/at170016.html"},
 | 
			
		||||
	"CVE-2017-3137":    {"https://www.jpcert.or.jp/at/2017/at170016.html"},
 | 
			
		||||
	"CVE-2017-3138":    {"https://www.jpcert.or.jp/at/2017/at170016.html"},
 | 
			
		||||
	"CVE-2017-3142":    {"https://www.jpcert.or.jp/at/2017/at170024.html"},
 | 
			
		||||
	"CVE-2017-3143":    {"https://www.jpcert.or.jp/at/2017/at170024.html"},
 | 
			
		||||
	"CVE-2017-3145":    {"https://www.jpcert.or.jp/at/2018/at180005.html"},
 | 
			
		||||
	"CVE-2017-5638":    {"https://www.jpcert.or.jp/at/2017/at170009.html"},
 | 
			
		||||
	"CVE-2017-6753":    {"https://www.jpcert.or.jp/at/2017/at170028.html"},
 | 
			
		||||
	"CVE-2017-8463":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8464":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8496":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8497":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8499":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8517":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8520":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8522":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8524":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8527":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8528":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8543":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8548":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8549":    {"https://www.jpcert.or.jp/at/2017/at170022.html"},
 | 
			
		||||
	"CVE-2017-8584":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8589":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8591":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8594":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8595":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8596":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8598":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8601":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8603":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8604":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8605":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8606":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8607":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8608":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8609":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8610":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8617":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8618":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8619":    {"https://www.jpcert.or.jp/at/2017/at170027.html"},
 | 
			
		||||
	"CVE-2017-8620":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8622":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8628":    {"https://www.jpcert.or.jp/at/2017/at170037.html"},
 | 
			
		||||
	"CVE-2017-8634":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8635":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8636":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8638":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8639":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8640":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8641":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8645":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8646":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8647":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8649":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8653":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8655":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8656":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8657":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8660":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8661":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8669":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8670":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8671":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8672":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8674":    {"https://www.jpcert.or.jp/at/2017/at170032.html"},
 | 
			
		||||
	"CVE-2017-8676":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8682":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8686":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8696":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8727":    {"https://www.jpcert.or.jp/at/2017/at170039.html"},
 | 
			
		||||
	"CVE-2017-8728":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8729":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8731":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8734":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8737":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8738":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8740":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8741":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8747":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8748":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8749":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8750":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8751":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8752":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8753":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8755":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8756":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8757":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-8759":    {"https://www.jpcert.or.jp/at/2017/at170036.html"},
 | 
			
		||||
	"CVE-2017-9791":    {"https://www.jpcert.or.jp/at/2017/at170025.html"},
 | 
			
		||||
	"CVE-2017-9805":    {"https://www.jpcert.or.jp/at/2017/at170033.html"},
 | 
			
		||||
	"CVE-2018-0171":    {"https://www.jpcert.or.jp/at/2018/at180013.html"},
 | 
			
		||||
	"CVE-2018-0758":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0762":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0763":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0767":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0769":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0770":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0772":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0773":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0774":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0775":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0776":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0777":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0778":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0780":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0781":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0797":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0800":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0802":    {"https://www.jpcert.or.jp/at/2018/at180002.html"},
 | 
			
		||||
	"CVE-2018-0825":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0834":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0835":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0837":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0838":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0840":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0852":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0856":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0857":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0859":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0860":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0861":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-0870":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0872":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0874":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0876":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0889":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0893":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0930":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0931":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0932":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0933":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0934":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0936":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0937":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0939":    {"https://www.jpcert.or.jp/at/2018/at180011.html"},
 | 
			
		||||
	"CVE-2018-0943":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0945":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0946":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0950":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0951":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0953":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0954":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0955":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0959":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0961":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-0965":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-0979":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0980":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0981":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0988":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0990":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0991":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0993":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0994":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0995":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-0996":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1000":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1004":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1010":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1012":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1013":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1015":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1016":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1018":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1019":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1020":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-1022":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-1023":    {"https://www.jpcert.or.jp/at/2018/at180016.html"},
 | 
			
		||||
	"CVE-2018-11776":   {"https://www.jpcert.or.jp/at/2018/at180036.html"},
 | 
			
		||||
	"CVE-2018-1270":    {"https://www.jpcert.or.jp/at/2018/at180014.html"},
 | 
			
		||||
	"CVE-2018-1271":    {"https://www.jpcert.or.jp/at/2018/at180014.html"},
 | 
			
		||||
	"CVE-2018-1272":    {"https://www.jpcert.or.jp/at/2018/at180014.html"},
 | 
			
		||||
	"CVE-2018-1273":    {"https://www.jpcert.or.jp/at/2018/at180017.html"},
 | 
			
		||||
	"CVE-2018-1274":    {"https://www.jpcert.or.jp/at/2018/at180017.html"},
 | 
			
		||||
	"CVE-2018-1275":    {"https://www.jpcert.or.jp/at/2018/at180014.html"},
 | 
			
		||||
	"CVE-2018-12794":   {"https://www.jpcert.or.jp/at/2018/at180039.html"},
 | 
			
		||||
	"CVE-2018-1336":    {"https://www.jpcert.or.jp/at/2018/at180030.html"},
 | 
			
		||||
	"CVE-2018-15442":   {"https://www.jpcert.or.jp/at/2018/at180043.html"},
 | 
			
		||||
	"CVE-2018-15979":   {"https://www.jpcert.or.jp/at/2018/at180045.html"},
 | 
			
		||||
	"CVE-2018-2628":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-2893":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-2894":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-2933":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-2983":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-2998":    {"https://www.jpcert.or.jp/at/2018/at180029.html"},
 | 
			
		||||
	"CVE-2018-4877":    {"https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-4878":    {"https://www.jpcert.or.jp/at/2018/at180006.html", "https://www.jpcert.or.jp/at/2018/at180008.html"},
 | 
			
		||||
	"CVE-2018-4945":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-5000":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-5001":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-5002":    {"https://www.jpcert.or.jp/at/2018/at180024.html", "https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-5740":    {"https://www.jpcert.or.jp/at/2018/at180031.html"},
 | 
			
		||||
	"CVE-2018-7600":    {"https://www.jpcert.or.jp/at/2018/at180012.html"},
 | 
			
		||||
	"CVE-2018-7602":    {"https://www.jpcert.or.jp/at/2018/at180019.html"},
 | 
			
		||||
	"CVE-2018-8034":    {"https://www.jpcert.or.jp/at/2018/at180030.html"},
 | 
			
		||||
	"CVE-2018-8037":    {"https://www.jpcert.or.jp/at/2018/at180030.html"},
 | 
			
		||||
	"CVE-2018-8110":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8111":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8114":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8120":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8122":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8128":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8130":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8133":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8137":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8139":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8154":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8174":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8178":    {"https://www.jpcert.or.jp/at/2018/at180021.html"},
 | 
			
		||||
	"CVE-2018-8213":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8225":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8229":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8231":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8236":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8242":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8249":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8251":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8262":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8266":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8267":    {"https://www.jpcert.or.jp/at/2018/at180025.html"},
 | 
			
		||||
	"CVE-2018-8273":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8274":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8275":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8279":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8280":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8286":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8288":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8290":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8291":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8294":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8296":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8301":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8302":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8324":    {"https://www.jpcert.or.jp/at/2018/at180028.html"},
 | 
			
		||||
	"CVE-2018-8332":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8344":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8345":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8350":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8355":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8367":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8371":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8372":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8373":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8377":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8380":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8381":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8385":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8387":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8390":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8397":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8403":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8414":    {"https://www.jpcert.or.jp/at/2018/at180034.html"},
 | 
			
		||||
	"CVE-2018-8420":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8421":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8439":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8440":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8447":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8453":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8456":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8457":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8459":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8460":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8461":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8464":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8465":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8466":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8467":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8473":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8475":    {"https://www.jpcert.or.jp/at/2018/at180038.html"},
 | 
			
		||||
	"CVE-2018-8476":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8489":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8490":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8491":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8494":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8505":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8509":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8510":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8511":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8513":    {"https://www.jpcert.or.jp/at/2018/at180041.html"},
 | 
			
		||||
	"CVE-2018-8541":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8542":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8543":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8544":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8551":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8553":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8555":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8556":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8557":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8588":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8589":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
	"CVE-2018-8609":    {"https://www.jpcert.or.jp/at/2018/at180046.html"},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										96
									
								
								alert/cve_us.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								alert/cve_us.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
package alert
 | 
			
		||||
 | 
			
		||||
// CveDictEn has CVE-ID key which included USCERT alerts
 | 
			
		||||
var CveDictEn = map[string][]string{
 | 
			
		||||
	"CVE-1999-0532": {"https://www.us-cert.gov/ncas/alerts/TA15-103A"},
 | 
			
		||||
	"CVE-2006-3227": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2008-0015": {"https://www.us-cert.gov/ncas/alerts/TA09-195A", "https://www.us-cert.gov/ncas/alerts/TA09-209A"},
 | 
			
		||||
	"CVE-2008-2244": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2009-0658": {"https://www.us-cert.gov/ncas/alerts/TA09-051A"},
 | 
			
		||||
	"CVE-2009-0927": {"https://www.us-cert.gov/ncas/alerts/TA13-141A"},
 | 
			
		||||
	"CVE-2009-1492": {"https://www.us-cert.gov/ncas/alerts/TA09-133B"},
 | 
			
		||||
	"CVE-2009-1493": {"https://www.us-cert.gov/ncas/alerts/TA09-133B"},
 | 
			
		||||
	"CVE-2009-1537": {"https://www.us-cert.gov/ncas/alerts/TA09-195A"},
 | 
			
		||||
	"CVE-2009-3103": {"https://www.us-cert.gov/ncas/alerts/TA17-181A"},
 | 
			
		||||
	"CVE-2009-3129": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2009-3674": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2009-3953": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2010-0018": {"https://www.us-cert.gov/ncas/alerts/TA10-012B"},
 | 
			
		||||
	"CVE-2010-0188": {"https://www.us-cert.gov/ncas/alerts/TA13-141A", "https://www.us-cert.gov/ncas/alerts/TA14-300A", "https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2010-0806": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2010-1297": {"https://www.us-cert.gov/ncas/alerts/TA10-162A", "https://www.us-cert.gov/ncas/alerts/TA10-159A"},
 | 
			
		||||
	"CVE-2010-2883": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2010-3333": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2011-0101": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2011-0611": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2011-2462": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2012-0158": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2012-1723": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2012-1856": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2012-1889": {"https://www.us-cert.gov/ncas/alerts/TA12-174A"},
 | 
			
		||||
	"CVE-2012-3174": {"https://www.us-cert.gov/ncas/alerts/TA13-010A"},
 | 
			
		||||
	"CVE-2012-4681": {"https://www.us-cert.gov/ncas/alerts/TA12-240A"},
 | 
			
		||||
	"CVE-2012-4792": {"https://www.us-cert.gov/ncas/alerts/TA13-015A", "https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-0074": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-0140": {"https://www.us-cert.gov/ncas/alerts/TA13-193A"},
 | 
			
		||||
	"CVE-2013-0141": {"https://www.us-cert.gov/ncas/alerts/TA13-193A"},
 | 
			
		||||
	"CVE-2013-0422": {"https://www.us-cert.gov/ncas/alerts/TA13-141A", "https://www.us-cert.gov/ncas/alerts/TA13-010A"},
 | 
			
		||||
	"CVE-2013-0625": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-0632": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-0809": {"https://www.us-cert.gov/ncas/alerts/TA13-064A"},
 | 
			
		||||
	"CVE-2013-1347": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-1493": {"https://www.us-cert.gov/ncas/alerts/TA13-064A"},
 | 
			
		||||
	"CVE-2013-1571": {"https://www.us-cert.gov/ncas/alerts/TA13-169A"},
 | 
			
		||||
	"CVE-2013-2465": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-2729": {"https://www.us-cert.gov/ncas/alerts/TA14-300A", "https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-3336": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2013-5211": {"https://www.us-cert.gov/ncas/alerts/TA14-017A", "https://www.us-cert.gov/ncas/alerts/TA14-013A"},
 | 
			
		||||
	"CVE-2013-5326": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-0160": {"https://www.us-cert.gov/ncas/alerts/TA14-098A", "https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-0322": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-0564": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-1761": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-1776": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-3393": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2014-3566": {"https://www.us-cert.gov/ncas/alerts/TA14-290A", "https://www.us-cert.gov/ncas/alerts/TA15-120A"},
 | 
			
		||||
	"CVE-2014-4114": {"https://www.us-cert.gov/ncas/alerts/TA15-119A"},
 | 
			
		||||
	"CVE-2014-6271": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-6277": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-6278": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-6321": {"https://www.us-cert.gov/ncas/alerts/TA14-318A"},
 | 
			
		||||
	"CVE-2014-6332": {"https://www.us-cert.gov/ncas/alerts/TA14-318B"},
 | 
			
		||||
	"CVE-2014-7169": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-7186": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-7187": {"https://www.us-cert.gov/ncas/alerts/TA14-268A"},
 | 
			
		||||
	"CVE-2014-8730": {"https://www.us-cert.gov/ncas/alerts/TA14-290A"},
 | 
			
		||||
	"CVE-2015-2387": {"https://www.us-cert.gov/ncas/alerts/TA15-195A"},
 | 
			
		||||
	"CVE-2015-5119": {"https://www.us-cert.gov/ncas/alerts/TA15-195A", "https://www.us-cert.gov/ncas/alerts/TA15-213A"},
 | 
			
		||||
	"CVE-2015-5122": {"https://www.us-cert.gov/ncas/alerts/TA15-195A"},
 | 
			
		||||
	"CVE-2015-5123": {"https://www.us-cert.gov/ncas/alerts/TA15-195A"},
 | 
			
		||||
	"CVE-2015-6585": {"https://www.us-cert.gov/ncas/alerts/TA17-164A"},
 | 
			
		||||
	"CVE-2015-8651": {"https://www.us-cert.gov/ncas/alerts/TA17-164A"},
 | 
			
		||||
	"CVE-2016-0034": {"https://www.us-cert.gov/ncas/alerts/TA17-164A"},
 | 
			
		||||
	"CVE-2016-1019": {"https://www.us-cert.gov/ncas/alerts/TA17-164A"},
 | 
			
		||||
	"CVE-2016-2207": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-2208": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-2209": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-2210": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-2211": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-3644": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-3645": {"https://www.us-cert.gov/ncas/alerts/TA16-187A"},
 | 
			
		||||
	"CVE-2016-4117": {"https://www.us-cert.gov/ncas/alerts/TA17-164A"},
 | 
			
		||||
	"CVE-2016-6366": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2016-6367": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2016-6415": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2016-6909": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2016-7089": {"https://www.us-cert.gov/ncas/alerts/TA16-250A"},
 | 
			
		||||
	"CVE-2017-0144": {"https://www.us-cert.gov/ncas/alerts/TA17-181A"},
 | 
			
		||||
	"CVE-2017-0145": {"https://www.us-cert.gov/ncas/alerts/TA17-181A"},
 | 
			
		||||
	"CVE-2017-3066": {"https://www.us-cert.gov/ncas/alerts/AA18-284A"},
 | 
			
		||||
	"CVE-2017-5715": {"https://www.us-cert.gov/ncas/alerts/TA18-141A", "https://www.us-cert.gov/ncas/alerts/TA18-004A"},
 | 
			
		||||
	"CVE-2017-5753": {"https://www.us-cert.gov/ncas/alerts/TA18-141A", "https://www.us-cert.gov/ncas/alerts/TA18-004A"},
 | 
			
		||||
	"CVE-2017-5754": {"https://www.us-cert.gov/ncas/alerts/TA18-141A", "https://www.us-cert.gov/ncas/alerts/TA18-004A"},
 | 
			
		||||
	"CVE-2018-1038": {"https://www.us-cert.gov/ncas/alerts/TA18-004A"},
 | 
			
		||||
	"CVE-2018-3639": {"https://www.us-cert.gov/ncas/alerts/TA18-141A"},
 | 
			
		||||
	"CVE-2018-3640": {"https://www.us-cert.gov/ncas/alerts/TA18-141A"},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								alert/util.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								alert/util.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
package alert
 | 
			
		||||
 | 
			
		||||
// GenerateAlertDict returns XCERT alert slice by cveID
 | 
			
		||||
func GenerateAlertDict(cveID string, lang string) (alerts []Alert) {
 | 
			
		||||
	if lang == "ja" {
 | 
			
		||||
		if keys, ok := CveDictJa[cveID]; ok {
 | 
			
		||||
			for _, key := range keys {
 | 
			
		||||
				alerts = append(alerts, AlertDictJa[key])
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return alerts
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// default language is English
 | 
			
		||||
	if keys, ok := CveDictEn[cveID]; ok {
 | 
			
		||||
		for _, key := range keys {
 | 
			
		||||
			alerts = append(alerts, AlertDictEn[key])
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return alerts
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								cache/bolt.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								cache/bolt.go
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -183,9 +183,6 @@ func (b Bolt) PutChangelog(servername, packName, changelog string) error {
 | 
			
		||||
		if bkt == nil {
 | 
			
		||||
			return fmt.Errorf("Failed to get Bucket: %s", servername)
 | 
			
		||||
		}
 | 
			
		||||
		if err := bkt.Put([]byte(packName), []byte(changelog)); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
		return bkt.Put([]byte(packName), []byte(changelog))
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								cache/bolt_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								cache/bolt_test.go
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								cache/db.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								cache/db.go
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -33,15 +33,8 @@ import (
 | 
			
		||||
// ConfigtestCmd is Subcommand
 | 
			
		||||
type ConfigtestCmd struct {
 | 
			
		||||
	configPath     string
 | 
			
		||||
	logDir         string
 | 
			
		||||
	askKeyPassword bool
 | 
			
		||||
	containersOnly bool
 | 
			
		||||
	deep           bool
 | 
			
		||||
	sshNative      bool
 | 
			
		||||
	httpProxy      string
 | 
			
		||||
	timeoutSec     int
 | 
			
		||||
 | 
			
		||||
	debug bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Name return subcommand name
 | 
			
		||||
@@ -54,7 +47,6 @@ func (*ConfigtestCmd) Synopsis() string { return "Test configuration" }
 | 
			
		||||
func (*ConfigtestCmd) Usage() string {
 | 
			
		||||
	return `configtest:
 | 
			
		||||
	configtest
 | 
			
		||||
			[-deep]
 | 
			
		||||
			[-config=/path/to/config.toml]
 | 
			
		||||
			[-log-dir=/path/to/log]
 | 
			
		||||
			[-ask-key-password]
 | 
			
		||||
@@ -63,6 +55,7 @@ func (*ConfigtestCmd) Usage() string {
 | 
			
		||||
			[-containers-only]
 | 
			
		||||
			[-http-proxy=http://192.168.0.1:8080]
 | 
			
		||||
			[-debug]
 | 
			
		||||
			[-vvv]
 | 
			
		||||
 | 
			
		||||
			[SERVER]...
 | 
			
		||||
`
 | 
			
		||||
@@ -75,48 +68,40 @@ func (p *ConfigtestCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := util.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&p.logDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.debug, "debug", false, "debug mode")
 | 
			
		||||
	f.StringVar(&c.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
	f.BoolVar(&c.Conf.Debug, "debug", false, "debug mode")
 | 
			
		||||
 | 
			
		||||
	f.IntVar(&p.timeoutSec, "timeout", 5*60, "Timeout(Sec)")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.askKeyPassword,
 | 
			
		||||
		"ask-key-password",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&p.askKeyPassword, "ask-key-password", false,
 | 
			
		||||
		"Ask ssh privatekey password before scanning",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.deep, "deep", false, "Config test for deep scan mode")
 | 
			
		||||
	f.StringVar(&c.Conf.HTTPProxy, "http-proxy", "",
 | 
			
		||||
		"http://proxy-url:port (default: empty)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.httpProxy,
 | 
			
		||||
		"http-proxy",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://proxy-url:port (default: empty)",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.sshNative,
 | 
			
		||||
		"ssh-native-insecure",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.SSHNative, "ssh-native-insecure", false,
 | 
			
		||||
		"Use Native Go implementation of SSH. Default: Use the external command")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.containersOnly,
 | 
			
		||||
		"containers-only",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.SSHConfig, "ssh-config", false,
 | 
			
		||||
		"Use SSH options specified in ssh_config preferentially")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.ContainersOnly, "containers-only", false,
 | 
			
		||||
		"Test containers only. Default: Test both of hosts and containers")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.Vvv, "vvv", false, "ssh -vvv")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
	// Setup Logger
 | 
			
		||||
	c.Conf.Debug = p.debug
 | 
			
		||||
	c.Conf.LogDir = p.logDir
 | 
			
		||||
	util.Log = util.NewCustomLogger(c.ServerInfo{})
 | 
			
		||||
 | 
			
		||||
	if err := mkdirDotVuls(); err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to create .vuls: %s", err)
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var keyPass string
 | 
			
		||||
	var err error
 | 
			
		||||
	if p.askKeyPassword {
 | 
			
		||||
@@ -134,10 +119,6 @@ func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfa
 | 
			
		||||
		util.Log.Errorf("Please check README: https://github.com/future-architect/vuls#configuration")
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
	c.Conf.SSHNative = p.sshNative
 | 
			
		||||
	c.Conf.HTTPProxy = p.httpProxy
 | 
			
		||||
	c.Conf.ContainersOnly = p.containersOnly
 | 
			
		||||
	c.Conf.Deep = p.deep
 | 
			
		||||
 | 
			
		||||
	var servernames []string
 | 
			
		||||
	if 0 < len(f.Args()) {
 | 
			
		||||
@@ -174,12 +155,22 @@ func (p *ConfigtestCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interfa
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Checking Scan Modes...")
 | 
			
		||||
	if err := scan.CheckScanModes(); err != nil {
 | 
			
		||||
		util.Log.Errorf("Fix config.toml: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Checking dependencies...")
 | 
			
		||||
	scan.CheckDependencies(p.timeoutSec)
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Checking sudo settings...")
 | 
			
		||||
	scan.CheckIfSudoNoPasswd(p.timeoutSec)
 | 
			
		||||
 | 
			
		||||
	scan.PrintSSHableServerNames()
 | 
			
		||||
	return subcommands.ExitSuccess
 | 
			
		||||
	util.Log.Info("It can be scanned with fast scan mode even if warn or err messages are displayed due to lack of dependent packages or sudo settings in fast-root or deep scan mode")
 | 
			
		||||
 | 
			
		||||
	if scan.PrintSSHableServerNames() {
 | 
			
		||||
		return subcommands.ExitSuccess
 | 
			
		||||
	}
 | 
			
		||||
	return subcommands.ExitFailure
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -90,62 +90,141 @@ func (p *DiscoverCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface
 | 
			
		||||
// Output the template of config.toml
 | 
			
		||||
func printConfigToml(ips []string) (err error) {
 | 
			
		||||
	const tomlTemplate = `
 | 
			
		||||
[slack]
 | 
			
		||||
hookURL      = "https://hooks.slack.com/services/abc123/defghijklmnopqrstuvwxyz"
 | 
			
		||||
#legacyToken  = "xoxp-11111111111-222222222222-3333333333"
 | 
			
		||||
channel      = "#channel-name"
 | 
			
		||||
#channel      = "${servername}"
 | 
			
		||||
iconEmoji    = ":ghost:"
 | 
			
		||||
authUser     = "username"
 | 
			
		||||
notifyUsers  = ["@username"]
 | 
			
		||||
 | 
			
		||||
[email]
 | 
			
		||||
smtpAddr      = "smtp.example.com"
 | 
			
		||||
smtpPort      = "587"
 | 
			
		||||
user          = "username"
 | 
			
		||||
password      = "password"
 | 
			
		||||
from          = "from@example.com"
 | 
			
		||||
to            = ["to@example.com"]
 | 
			
		||||
cc            = ["cc@example.com"]
 | 
			
		||||
subjectPrefix = "[vuls]"
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html
 | 
			
		||||
[cveDict]
 | 
			
		||||
type        = "sqlite3"
 | 
			
		||||
sqlite3Path = "/path/to/cve.sqlite3"
 | 
			
		||||
#url        = ""
 | 
			
		||||
 | 
			
		||||
[ovalDict]
 | 
			
		||||
type        = "sqlite3"
 | 
			
		||||
sqlite3Path = "/path/to/oval.sqlite3"
 | 
			
		||||
#url        = ""
 | 
			
		||||
 | 
			
		||||
[gost]
 | 
			
		||||
type        = "sqlite3"
 | 
			
		||||
sqlite3Path = "/path/to/gost.sqlite3"
 | 
			
		||||
#url        = ""
 | 
			
		||||
 | 
			
		||||
[exploit]
 | 
			
		||||
type        = "sqlite3"
 | 
			
		||||
sqlite3Path = "/path/to/go-exploitdb.sqlite3"
 | 
			
		||||
#url        = ""
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#slack-section
 | 
			
		||||
#[slack]
 | 
			
		||||
#hookURL      = "https://hooks.slack.com/services/abc123/defghijklmnopqrstuvwxyz"
 | 
			
		||||
##legacyToken = "xoxp-11111111111-222222222222-3333333333"
 | 
			
		||||
#channel      = "#channel-name"
 | 
			
		||||
##channel     = "${servername}"
 | 
			
		||||
#iconEmoji    = ":ghost:"
 | 
			
		||||
#authUser     = "username"
 | 
			
		||||
#notifyUsers  = ["@username"]
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#email-section
 | 
			
		||||
#[email]
 | 
			
		||||
#smtpAddr      = "smtp.example.com"
 | 
			
		||||
#smtpPort      = "587"
 | 
			
		||||
#user          = "username"
 | 
			
		||||
#password      = "password"
 | 
			
		||||
#from          = "from@example.com"
 | 
			
		||||
#to            = ["to@example.com"]
 | 
			
		||||
#cc            = ["cc@example.com"]
 | 
			
		||||
#subjectPrefix = "[vuls]"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#http-section
 | 
			
		||||
#[http]
 | 
			
		||||
#url = "http://localhost:11234"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#syslog-section
 | 
			
		||||
#[syslog]
 | 
			
		||||
#protocol    = "tcp"
 | 
			
		||||
#host        = "localhost"
 | 
			
		||||
#port        = "514"
 | 
			
		||||
#tag         = "vuls"
 | 
			
		||||
#facility    = "local0"
 | 
			
		||||
#severity    = "alert"
 | 
			
		||||
#verbose     = false
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-report.html#example-put-results-in-s3-bucket
 | 
			
		||||
#[aws]
 | 
			
		||||
#profile                = "default"
 | 
			
		||||
#region                 = "ap-northeast-1"
 | 
			
		||||
#s3Bucket               = "vuls"
 | 
			
		||||
#s3ResultsDir           = "/path/to/result"
 | 
			
		||||
#s3ServerSideEncryption = "AES256"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-report.html#example-put-results-in-azure-blob-storage<Paste>
 | 
			
		||||
#[azure]
 | 
			
		||||
#accountName   = "default"
 | 
			
		||||
#accountKey    = "xxxxxxxxxxxxxx"
 | 
			
		||||
#containerName = "vuls"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#stride-section
 | 
			
		||||
#[stride]
 | 
			
		||||
#hookURL   = "xxxxxxxxxxxxxxx"
 | 
			
		||||
#authToken = "xxxxxxxxxxxxxx"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#hipchat-section
 | 
			
		||||
#[hipchat]
 | 
			
		||||
#room      = "vuls"
 | 
			
		||||
#authToken = "xxxxxxxxxxxxxx"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#chatwork-section
 | 
			
		||||
#[chatwork]
 | 
			
		||||
#room     = "xxxxxxxxxxx"
 | 
			
		||||
#apiToken = "xxxxxxxxxxxxxxxxxx"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#telegram-section
 | 
			
		||||
#[telegram]
 | 
			
		||||
#chatID     = "xxxxxxxxxxx"
 | 
			
		||||
#token = "xxxxxxxxxxxxxxxxxx"
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#default-section
 | 
			
		||||
[default]
 | 
			
		||||
#port        = "22"
 | 
			
		||||
#user        = "username"
 | 
			
		||||
#keyPath     = "/home/username/.ssh/id_rsa"
 | 
			
		||||
#port               = "22"
 | 
			
		||||
#user               = "username"
 | 
			
		||||
#keyPath            = "/home/username/.ssh/id_rsa"
 | 
			
		||||
#scanMode           = ["fast", "fast-root", "deep", "offline"]
 | 
			
		||||
#cpeNames = [
 | 
			
		||||
#  "cpe:/a:rubyonrails:ruby_on_rails:4.2.1",
 | 
			
		||||
#]
 | 
			
		||||
#dependencyCheckXMLPath = "/tmp/dependency-check-report.xml"
 | 
			
		||||
#ignoreCves = ["CVE-2014-6271"]
 | 
			
		||||
#optional = [
 | 
			
		||||
#    ["key", "value"],
 | 
			
		||||
#]
 | 
			
		||||
#containers = ["${running}"]
 | 
			
		||||
 | 
			
		||||
#owaspDCXMLPath     = "/tmp/dependency-check-report.xml"
 | 
			
		||||
#ignoreCves         = ["CVE-2014-6271"]
 | 
			
		||||
#containerType      = "docker" #or "lxd" or "lxc" default: docker
 | 
			
		||||
#containersIncluded = ["${running}"]
 | 
			
		||||
#containersExcluded = ["container_name_a"]
 | 
			
		||||
 | 
			
		||||
# https://vuls.io/docs/en/usage-settings.html#servers-section
 | 
			
		||||
[servers]
 | 
			
		||||
{{- $names:=  .Names}}
 | 
			
		||||
{{range $i, $ip := .IPs}}
 | 
			
		||||
[servers.{{index $names $i}}]
 | 
			
		||||
host         = "{{$ip}}"
 | 
			
		||||
#port        = "22"
 | 
			
		||||
#user        = "root"
 | 
			
		||||
#keyPath     = "/home/username/.ssh/id_rsa"
 | 
			
		||||
#type 		 = "pseudo"
 | 
			
		||||
#cpeNames = [
 | 
			
		||||
#  "cpe:/a:rubyonrails:ruby_on_rails:4.2.1",
 | 
			
		||||
#]
 | 
			
		||||
#dependencyCheckXMLPath = "/tmp/dependency-check-report.xml"
 | 
			
		||||
#ignoreCves = ["CVE-2014-0160"]
 | 
			
		||||
#optional = [
 | 
			
		||||
#    ["key", "value"],
 | 
			
		||||
#]
 | 
			
		||||
#[servers.{{index $names $i}}.containers]
 | 
			
		||||
#type = "docker" #or "lxd" default: docker
 | 
			
		||||
#includes = ["${running}"]
 | 
			
		||||
#excludes = ["container_name_a", "4aa37a8b63b9"]
 | 
			
		||||
host                = "{{$ip}}"
 | 
			
		||||
#port               = "22"
 | 
			
		||||
#user               = "root"
 | 
			
		||||
#keyPath            = "/home/username/.ssh/id_rsa"
 | 
			
		||||
#scanMode           = ["fast", "fast-root", "deep", "offline"]
 | 
			
		||||
#type               = "pseudo"
 | 
			
		||||
#memo               = "DB Server"
 | 
			
		||||
#cpeNames           = [ "cpe:/a:rubyonrails:ruby_on_rails:4.2.1" ]
 | 
			
		||||
#owaspDCXMLPath     = "/path/to/dependency-check-report.xml"
 | 
			
		||||
#ignoreCves         = ["CVE-2014-0160"]
 | 
			
		||||
#containerType      = "docker" #or "lxd" or "lxc" default: docker
 | 
			
		||||
#containersIncluded = ["${running}"]
 | 
			
		||||
#containersExcluded = ["container_name_a"]
 | 
			
		||||
 | 
			
		||||
#[servers.{{index $names $i}}.containers.container_name_a]
 | 
			
		||||
#cpeNames       = [ "cpe:/a:rubyonrails:ruby_on_rails:4.2.1" ]
 | 
			
		||||
#owaspDCXMLPath = "/path/to/dependency-check-report.xml"
 | 
			
		||||
#ignoreCves     = ["CVE-2014-0160"]
 | 
			
		||||
 | 
			
		||||
#[servers.{{index $names $i}}.githubs."owner/repo"]
 | 
			
		||||
#token   = "yourToken"
 | 
			
		||||
 | 
			
		||||
#[servers.{{index $names $i}}.optional]
 | 
			
		||||
#key = "value1"
 | 
			
		||||
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -32,11 +32,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// HistoryCmd is Subcommand of list scanned results
 | 
			
		||||
type HistoryCmd struct {
 | 
			
		||||
	debug      bool
 | 
			
		||||
	debugSQL   bool
 | 
			
		||||
	resultsDir string
 | 
			
		||||
}
 | 
			
		||||
type HistoryCmd struct{}
 | 
			
		||||
 | 
			
		||||
// Name return subcommand name
 | 
			
		||||
func (*HistoryCmd) Name() string { return "history" }
 | 
			
		||||
@@ -56,19 +52,16 @@ func (*HistoryCmd) Usage() string {
 | 
			
		||||
 | 
			
		||||
// SetFlags set flag
 | 
			
		||||
func (p *HistoryCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	f.BoolVar(&p.debugSQL, "debug-sql", false, "SQL debug mode")
 | 
			
		||||
	f.BoolVar(&c.Conf.DebugSQL, "debug-sql", false, "SQL debug mode")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
	f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
	f.StringVar(&c.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *HistoryCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
 | 
			
		||||
	c.Conf.DebugSQL = p.debugSQL
 | 
			
		||||
	c.Conf.ResultsDir = p.resultsDir
 | 
			
		||||
 | 
			
		||||
	dirs, err := report.ListValidJSONDirs()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -20,69 +20,29 @@ package commands
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/exploit"
 | 
			
		||||
	"github.com/future-architect/vuls/gost"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/oval"
 | 
			
		||||
	"github.com/future-architect/vuls/report"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
	"github.com/k0kubun/pp"
 | 
			
		||||
	cvelog "github.com/kotakanbe/go-cve-dictionary/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ReportCmd is subcommand for reporting
 | 
			
		||||
type ReportCmd struct {
 | 
			
		||||
	lang       string
 | 
			
		||||
	debug      bool
 | 
			
		||||
	debugSQL   bool
 | 
			
		||||
	configPath string
 | 
			
		||||
	resultsDir string
 | 
			
		||||
	logDir     string
 | 
			
		||||
	refreshCve bool
 | 
			
		||||
 | 
			
		||||
	cvssScoreOver      float64
 | 
			
		||||
	ignoreUnscoredCves bool
 | 
			
		||||
	ignoreUnfixed      bool
 | 
			
		||||
 | 
			
		||||
	httpProxy string
 | 
			
		||||
 | 
			
		||||
	cveDBType string
 | 
			
		||||
	cveDBPath string
 | 
			
		||||
	cveDBURL  string
 | 
			
		||||
 | 
			
		||||
	ovalDBType string
 | 
			
		||||
	ovalDBPath string
 | 
			
		||||
	ovalDBURL  string
 | 
			
		||||
 | 
			
		||||
	toSlack     bool
 | 
			
		||||
	toEMail     bool
 | 
			
		||||
	toLocalFile bool
 | 
			
		||||
	toS3        bool
 | 
			
		||||
	toAzureBlob bool
 | 
			
		||||
 | 
			
		||||
	formatJSON        bool
 | 
			
		||||
	formatXML         bool
 | 
			
		||||
	formatOneEMail    bool
 | 
			
		||||
	formatOneLineText bool
 | 
			
		||||
	formatShortText   bool
 | 
			
		||||
	formatFullText    bool
 | 
			
		||||
 | 
			
		||||
	gzip bool
 | 
			
		||||
 | 
			
		||||
	awsProfile      string
 | 
			
		||||
	awsS3Bucket     string
 | 
			
		||||
	awsS3ResultsDir string
 | 
			
		||||
	awsRegion       string
 | 
			
		||||
 | 
			
		||||
	azureAccount   string
 | 
			
		||||
	azureKey       string
 | 
			
		||||
	azureContainer string
 | 
			
		||||
 | 
			
		||||
	pipe bool
 | 
			
		||||
 | 
			
		||||
	diff bool
 | 
			
		||||
	configPath  string
 | 
			
		||||
	cveDict     c.GoCveDictConf
 | 
			
		||||
	ovalDict    c.GovalDictConf
 | 
			
		||||
	gostConf    c.GostConf
 | 
			
		||||
	exploitConf c.ExploitConf
 | 
			
		||||
	httpConf    c.HTTPConf
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Name return subcommand name
 | 
			
		||||
@@ -100,39 +60,47 @@ func (*ReportCmd) Usage() string {
 | 
			
		||||
		[-results-dir=/path/to/results]
 | 
			
		||||
		[-log-dir=/path/to/log]
 | 
			
		||||
		[-refresh-cve]
 | 
			
		||||
		[-cvedb-type=sqlite3|mysql|postgres]
 | 
			
		||||
		[-cvedb-path=/path/to/cve.sqlite3]
 | 
			
		||||
		[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
 | 
			
		||||
		[-ovaldb-type=sqlite3|mysql]
 | 
			
		||||
		[-ovaldb-path=/path/to/oval.sqlite3]
 | 
			
		||||
		[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
 | 
			
		||||
		[-cvss-over=7]
 | 
			
		||||
		[-diff]
 | 
			
		||||
		[-ignore-unscored-cves]
 | 
			
		||||
		[-ignore-unfixed]
 | 
			
		||||
		[-ignore-github-dismissed]
 | 
			
		||||
		[-to-email]
 | 
			
		||||
		[-to-http]
 | 
			
		||||
		[-to-slack]
 | 
			
		||||
		[-to-stride]
 | 
			
		||||
		[-to-hipchat]
 | 
			
		||||
		[-to-chatwork]
 | 
			
		||||
		[-to-telegram]
 | 
			
		||||
		[-to-localfile]
 | 
			
		||||
		[-to-s3]
 | 
			
		||||
		[-to-azure-blob]
 | 
			
		||||
		[-to-saas]
 | 
			
		||||
		[-format-json]
 | 
			
		||||
		[-format-xml]
 | 
			
		||||
		[-format-one-email]
 | 
			
		||||
		[-format-one-line-text]
 | 
			
		||||
		[-format-short-text]
 | 
			
		||||
		[-format-list]
 | 
			
		||||
		[-format-full-text]
 | 
			
		||||
		[-gzip]
 | 
			
		||||
		[-aws-profile=default]
 | 
			
		||||
		[-aws-region=us-west-2]
 | 
			
		||||
		[-aws-s3-bucket=bucket_name]
 | 
			
		||||
		[-aws-s3-results-dir=/bucket/path/to/results]
 | 
			
		||||
		[-azure-account=account]
 | 
			
		||||
		[-azure-key=key]
 | 
			
		||||
		[-azure-container=container]
 | 
			
		||||
		[-uuid]
 | 
			
		||||
		[-http-proxy=http://192.168.0.1:8080]
 | 
			
		||||
		[-debug]
 | 
			
		||||
		[-debug-sql]
 | 
			
		||||
		[-pipe]
 | 
			
		||||
		[-cvedb-type=sqlite3|mysql|postgres|redis|http]
 | 
			
		||||
		[-cvedb-sqlite3-path=/path/to/cve.sqlite3]
 | 
			
		||||
		[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
 | 
			
		||||
		[-ovaldb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-ovaldb-sqlite3-path=/path/to/oval.sqlite3]
 | 
			
		||||
		[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
 | 
			
		||||
		[-gostdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-gostdb-sqlite3-path=/path/to/gost.sqlite3]
 | 
			
		||||
		[-gostdb-url=http://127.0.0.1:1325 or DB connection string]
 | 
			
		||||
		[-exploitdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-exploitdb-sqlite3-path=/path/to/exploitdb.sqlite3]
 | 
			
		||||
		[-exploitdb-url=http://127.0.0.1:1326 or DB connection string]
 | 
			
		||||
		[-http="http://vuls-report-server"]
 | 
			
		||||
 | 
			
		||||
		[RFC3339 datetime format under results dir]
 | 
			
		||||
`
 | 
			
		||||
@@ -140,204 +108,120 @@ func (*ReportCmd) Usage() string {
 | 
			
		||||
 | 
			
		||||
// SetFlags set flag
 | 
			
		||||
func (p *ReportCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	f.StringVar(&p.lang, "lang", "en", "[en|ja]")
 | 
			
		||||
	f.BoolVar(&p.debug, "debug", false, "debug mode")
 | 
			
		||||
	f.BoolVar(&p.debugSQL, "debug-sql", false, "SQL debug mode")
 | 
			
		||||
	f.StringVar(&c.Conf.Lang, "lang", "en", "[en|ja]")
 | 
			
		||||
	f.BoolVar(&c.Conf.Debug, "debug", false, "debug mode")
 | 
			
		||||
	f.BoolVar(&c.Conf.DebugSQL, "debug-sql", false, "SQL debug mode")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
 | 
			
		||||
	defaultConfPath := filepath.Join(wd, "config.toml")
 | 
			
		||||
	f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
 | 
			
		||||
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
	f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
	f.StringVar(&c.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := util.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&p.logDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
	f.StringVar(&c.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.refreshCve,
 | 
			
		||||
		"refresh-cve",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.RefreshCve, "refresh-cve", false,
 | 
			
		||||
		"Refresh CVE information in JSON file under results dir")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cveDBType,
 | 
			
		||||
		"cvedb-type",
 | 
			
		||||
		"sqlite3",
 | 
			
		||||
		"DB type for fetching CVE dictionary (sqlite3, mysql or postgres)")
 | 
			
		||||
 | 
			
		||||
	defaultCveDBPath := filepath.Join(wd, "cve.sqlite3")
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cveDBPath,
 | 
			
		||||
		"cvedb-path",
 | 
			
		||||
		defaultCveDBPath,
 | 
			
		||||
		"/path/to/sqlite3 (For get cve detail from cve.sqlite3)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cveDBURL,
 | 
			
		||||
		"cvedb-url",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://cve-dictionary.com:1323 or mysql connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBType,
 | 
			
		||||
		"ovaldb-type",
 | 
			
		||||
		"sqlite3",
 | 
			
		||||
		"DB type for fetching OVAL dictionary (sqlite3 or mysql)")
 | 
			
		||||
 | 
			
		||||
	defaultOvalDBPath := filepath.Join(wd, "oval.sqlite3")
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBPath,
 | 
			
		||||
		"ovaldb-path",
 | 
			
		||||
		defaultOvalDBPath,
 | 
			
		||||
		"/path/to/sqlite3 (For get oval detail from oval.sqlite3)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBURL,
 | 
			
		||||
		"ovaldb-url",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://goval-dictionary.com:1324 or mysql connection string")
 | 
			
		||||
 | 
			
		||||
	f.Float64Var(
 | 
			
		||||
		&p.cvssScoreOver,
 | 
			
		||||
		"cvss-over",
 | 
			
		||||
		0,
 | 
			
		||||
	f.Float64Var(&c.Conf.CvssScoreOver, "cvss-over", 0,
 | 
			
		||||
		"-cvss-over=6.5 means reporting CVSS Score 6.5 and over (default: 0 (means report all))")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.diff,
 | 
			
		||||
		"diff",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("Difference between previous result and current result "))
 | 
			
		||||
	f.BoolVar(&c.Conf.Diff, "diff", false,
 | 
			
		||||
		"Difference between previous result and current result ")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.ignoreUnscoredCves,
 | 
			
		||||
		"ignore-unscored-cves",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreUnscoredCves, "ignore-unscored-cves", false,
 | 
			
		||||
		"Don't report the unscored CVEs")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.ignoreUnfixed,
 | 
			
		||||
		"ignore-unfixed",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreUnfixed, "ignore-unfixed", false,
 | 
			
		||||
		"Don't report the unfixed CVEs")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreGitHubDismissed, "ignore-github-dismissed", false,
 | 
			
		||||
		"Don't report the dismissed CVEs on GitHub Security Alerts")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.httpProxy,
 | 
			
		||||
		"http-proxy",
 | 
			
		||||
		"",
 | 
			
		||||
		&c.Conf.HTTPProxy, "http-proxy", "",
 | 
			
		||||
		"http://proxy-url:port (default: empty)")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatJSON,
 | 
			
		||||
		"format-json",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("JSON format"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatXML,
 | 
			
		||||
		"format-xml",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("XML format"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatOneEMail,
 | 
			
		||||
		"format-one-email",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatJSON, "format-json", false, "JSON format")
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatXML, "format-xml", false, "XML format")
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatOneEMail, "format-one-email", false,
 | 
			
		||||
		"Send all the host report via only one EMail (Specify with -to-email)")
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatOneLineText, "format-one-line-text", false,
 | 
			
		||||
		"One line summary in plain text")
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatList, "format-list", false, "Display as list format")
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatFullText, "format-full-text", false,
 | 
			
		||||
		"Detail report in plain text")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatOneLineText,
 | 
			
		||||
		"format-one-line-text",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("One line summary in plain text"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatShortText,
 | 
			
		||||
		"format-short-text",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("Summary in plain text"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.formatFullText,
 | 
			
		||||
		"format-full-text",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("Detail report in plain text"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.gzip, "gzip", false, "gzip compression")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.toSlack, "to-slack", false, "Send report via Slack")
 | 
			
		||||
	f.BoolVar(&p.toEMail, "to-email", false, "Send report via Email")
 | 
			
		||||
	f.BoolVar(&p.toLocalFile,
 | 
			
		||||
		"to-localfile",
 | 
			
		||||
		false,
 | 
			
		||||
		fmt.Sprintf("Write report to localfile"))
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.toS3,
 | 
			
		||||
		"to-s3",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.ToSlack, "to-slack", false, "Send report via Slack")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToStride, "to-stride", false, "Send report via Stride")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToHipChat, "to-hipchat", false, "Send report via hipchat")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToChatWork, "to-chatwork", false, "Send report via chatwork")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToTelegram, "to-telegram", false, "Send report via Telegram")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToEmail, "to-email", false, "Send report via Email")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToSyslog, "to-syslog", false, "Send report via Syslog")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToLocalFile, "to-localfile", false, "Write report to localfile")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToS3, "to-s3", false,
 | 
			
		||||
		"Write report to S3 (bucket/yyyyMMdd_HHmm/servername.json/xml/txt)")
 | 
			
		||||
	f.StringVar(&p.awsProfile, "aws-profile", "default", "AWS profile to use")
 | 
			
		||||
	f.StringVar(&p.awsRegion, "aws-region", "us-east-1", "AWS region to use")
 | 
			
		||||
	f.StringVar(&p.awsS3Bucket, "aws-s3-bucket", "", "S3 bucket name")
 | 
			
		||||
	f.StringVar(&p.awsS3ResultsDir, "aws-s3-results-dir", "", "/bucket/path/to/results")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&p.toAzureBlob,
 | 
			
		||||
		"to-azure-blob",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.ToHTTP, "to-http", false, "Send report via HTTP POST")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToAzureBlob, "to-azure-blob", false,
 | 
			
		||||
		"Write report to Azure Storage blob (container/yyyyMMdd_HHmm/servername.json/xml/txt)")
 | 
			
		||||
	f.StringVar(&p.azureAccount,
 | 
			
		||||
		"azure-account",
 | 
			
		||||
		"",
 | 
			
		||||
		"Azure account name to use. AZURE_STORAGE_ACCOUNT environment variable is used if not specified")
 | 
			
		||||
	f.StringVar(&p.azureKey,
 | 
			
		||||
		"azure-key",
 | 
			
		||||
		"",
 | 
			
		||||
		"Azure account key to use. AZURE_STORAGE_ACCESS_KEY environment variable is used if not specified")
 | 
			
		||||
	f.StringVar(&p.azureContainer, "azure-container", "", "Azure storage container name")
 | 
			
		||||
	f.BoolVar(&c.Conf.ToSaas, "to-saas", false,
 | 
			
		||||
		"Upload report to Future Vuls(https://vuls.biz/) before report")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.GZIP, "gzip", false, "gzip compression")
 | 
			
		||||
	f.BoolVar(&c.Conf.UUID, "uuid", false,
 | 
			
		||||
		"Auto generate of scan target servers and then write to config.toml and scan result")
 | 
			
		||||
	f.BoolVar(&c.Conf.Pipe, "pipe", false, "Use args passed via PIPE")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.cveDict.Type, "cvedb-type", "",
 | 
			
		||||
		"DB type of go-cve-dictionary (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.cveDict.SQLite3Path, "cvedb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.cveDict.URL, "cvedb-url", "",
 | 
			
		||||
		"http://go-cve-dictionary.com:1323 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.ovalDict.Type, "ovaldb-type", "",
 | 
			
		||||
		"DB type of goval-dictionary (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.ovalDict.SQLite3Path, "ovaldb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.ovalDict.URL, "ovaldb-url", "",
 | 
			
		||||
		"http://goval-dictionary.com:1324 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.gostConf.Type, "gostdb-type", "",
 | 
			
		||||
		"DB type of gost (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.gostConf.SQLite3Path, "gostdb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.gostConf.URL, "gostdb-url", "",
 | 
			
		||||
		"http://gost.com:1325 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.exploitConf.Type, "exploitdb-type", "",
 | 
			
		||||
		"DB type of exploit (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.exploitConf.SQLite3Path, "exploitdb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.exploitConf.URL, "exploitdb-url", "",
 | 
			
		||||
		"http://exploit.com:1326 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.httpConf.URL, "http", "", "-to-http http://vuls-report")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.pipe,
 | 
			
		||||
		"pipe",
 | 
			
		||||
		false,
 | 
			
		||||
		"Use args passed via PIPE")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
	c.Conf.Debug = p.debug
 | 
			
		||||
	c.Conf.DebugSQL = p.debugSQL
 | 
			
		||||
	c.Conf.LogDir = p.logDir
 | 
			
		||||
	util.Log = util.NewCustomLogger(c.ServerInfo{})
 | 
			
		||||
	cvelog.SetLogger(c.Conf.LogDir, false, c.Conf.Debug, false)
 | 
			
		||||
 | 
			
		||||
	if err := c.Load(p.configPath, ""); err != nil {
 | 
			
		||||
		util.Log.Errorf("Error loading %s, %s", p.configPath, err)
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	c.Conf.Lang = p.lang
 | 
			
		||||
	c.Conf.ResultsDir = p.resultsDir
 | 
			
		||||
	c.Conf.RefreshCve = p.refreshCve
 | 
			
		||||
	c.Conf.Diff = p.diff
 | 
			
		||||
	c.Conf.CveDBType = p.cveDBType
 | 
			
		||||
	c.Conf.CveDBPath = p.cveDBPath
 | 
			
		||||
	c.Conf.CveDBURL = p.cveDBURL
 | 
			
		||||
	c.Conf.OvalDBType = p.ovalDBType
 | 
			
		||||
	c.Conf.OvalDBPath = p.ovalDBPath
 | 
			
		||||
	c.Conf.OvalDBURL = p.ovalDBURL
 | 
			
		||||
	c.Conf.CvssScoreOver = p.cvssScoreOver
 | 
			
		||||
	c.Conf.IgnoreUnscoredCves = p.ignoreUnscoredCves
 | 
			
		||||
	c.Conf.IgnoreUnfixed = p.ignoreUnfixed
 | 
			
		||||
	c.Conf.HTTPProxy = p.httpProxy
 | 
			
		||||
 | 
			
		||||
	c.Conf.FormatXML = p.formatXML
 | 
			
		||||
	c.Conf.FormatJSON = p.formatJSON
 | 
			
		||||
	c.Conf.FormatOneEMail = p.formatOneEMail
 | 
			
		||||
	c.Conf.FormatOneLineText = p.formatOneLineText
 | 
			
		||||
	c.Conf.FormatShortText = p.formatShortText
 | 
			
		||||
	c.Conf.FormatFullText = p.formatFullText
 | 
			
		||||
 | 
			
		||||
	c.Conf.GZIP = p.gzip
 | 
			
		||||
	c.Conf.Diff = p.diff
 | 
			
		||||
	c.Conf.Pipe = p.pipe
 | 
			
		||||
	c.Conf.CveDict.Overwrite(p.cveDict)
 | 
			
		||||
	c.Conf.OvalDict.Overwrite(p.ovalDict)
 | 
			
		||||
	c.Conf.Gost.Overwrite(p.gostConf)
 | 
			
		||||
	c.Conf.Exploit.Overwrite(p.exploitConf)
 | 
			
		||||
	c.Conf.HTTP.Overwrite(p.httpConf)
 | 
			
		||||
 | 
			
		||||
	var dir string
 | 
			
		||||
	var err error
 | 
			
		||||
	if p.diff {
 | 
			
		||||
	if c.Conf.Diff {
 | 
			
		||||
		dir, err = report.JSONDir([]string{})
 | 
			
		||||
	} else {
 | 
			
		||||
		dir, err = report.JSONDir(f.Args())
 | 
			
		||||
@@ -352,96 +236,185 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
 | 
			
		||||
		report.StdoutWriter{},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if p.toSlack {
 | 
			
		||||
	if c.Conf.ToSlack {
 | 
			
		||||
		reports = append(reports, report.SlackWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if p.toEMail {
 | 
			
		||||
	if c.Conf.ToStride {
 | 
			
		||||
		reports = append(reports, report.StrideWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToHipChat {
 | 
			
		||||
		reports = append(reports, report.HipChatWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToChatWork {
 | 
			
		||||
		reports = append(reports, report.ChatWorkWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToTelegram {
 | 
			
		||||
		reports = append(reports, report.TelegramWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToEmail {
 | 
			
		||||
		reports = append(reports, report.EMailWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if p.toLocalFile {
 | 
			
		||||
	if c.Conf.ToSyslog {
 | 
			
		||||
		reports = append(reports, report.SyslogWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToHTTP {
 | 
			
		||||
		reports = append(reports, report.HTTPRequestWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.ToLocalFile {
 | 
			
		||||
		reports = append(reports, report.LocalFileWriter{
 | 
			
		||||
			CurrentDir: dir,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if p.toS3 {
 | 
			
		||||
		c.Conf.AwsRegion = p.awsRegion
 | 
			
		||||
		c.Conf.AwsProfile = p.awsProfile
 | 
			
		||||
		c.Conf.S3Bucket = p.awsS3Bucket
 | 
			
		||||
		c.Conf.S3ResultsDir = p.awsS3ResultsDir
 | 
			
		||||
	if c.Conf.ToS3 {
 | 
			
		||||
		if err := report.CheckIfBucketExists(); err != nil {
 | 
			
		||||
			util.Log.Errorf("Check if there is a bucket beforehand: %s, err: %s", c.Conf.S3Bucket, err)
 | 
			
		||||
			util.Log.Errorf("Check if there is a bucket beforehand: %s, err: %s",
 | 
			
		||||
				c.Conf.AWS.S3Bucket, err)
 | 
			
		||||
			return subcommands.ExitUsageError
 | 
			
		||||
		}
 | 
			
		||||
		reports = append(reports, report.S3Writer{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if p.toAzureBlob {
 | 
			
		||||
		c.Conf.AzureAccount = p.azureAccount
 | 
			
		||||
		if len(c.Conf.AzureAccount) == 0 {
 | 
			
		||||
			c.Conf.AzureAccount = os.Getenv("AZURE_STORAGE_ACCOUNT")
 | 
			
		||||
	if c.Conf.ToAzureBlob {
 | 
			
		||||
		if len(c.Conf.Azure.AccountName) == 0 {
 | 
			
		||||
			c.Conf.Azure.AccountName = os.Getenv("AZURE_STORAGE_ACCOUNT")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		c.Conf.AzureKey = p.azureKey
 | 
			
		||||
		if len(c.Conf.AzureKey) == 0 {
 | 
			
		||||
			c.Conf.AzureKey = os.Getenv("AZURE_STORAGE_ACCESS_KEY")
 | 
			
		||||
		if len(c.Conf.Azure.AccountKey) == 0 {
 | 
			
		||||
			c.Conf.Azure.AccountKey = os.Getenv("AZURE_STORAGE_ACCESS_KEY")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		c.Conf.AzureContainer = p.azureContainer
 | 
			
		||||
		if len(c.Conf.AzureContainer) == 0 {
 | 
			
		||||
		if len(c.Conf.Azure.ContainerName) == 0 {
 | 
			
		||||
			util.Log.Error("Azure storage container name is required with -azure-container option")
 | 
			
		||||
			return subcommands.ExitUsageError
 | 
			
		||||
		}
 | 
			
		||||
		if err := report.CheckIfAzureContainerExists(); err != nil {
 | 
			
		||||
			util.Log.Errorf("Check if there is a container beforehand: %s, err: %s", c.Conf.AzureContainer, err)
 | 
			
		||||
			util.Log.Errorf("Check if there is a container beforehand: %s, err: %s",
 | 
			
		||||
				c.Conf.Azure.ContainerName, err)
 | 
			
		||||
			return subcommands.ExitUsageError
 | 
			
		||||
		}
 | 
			
		||||
		reports = append(reports, report.AzureBlobWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !(p.formatJSON || p.formatOneLineText ||
 | 
			
		||||
		p.formatShortText || p.formatFullText || p.formatXML) {
 | 
			
		||||
		c.Conf.FormatShortText = true
 | 
			
		||||
	if c.Conf.ToSaas {
 | 
			
		||||
		if !c.Conf.UUID {
 | 
			
		||||
			util.Log.Errorf("If you use the -to-saas option, you need to enable the uuid option")
 | 
			
		||||
			return subcommands.ExitUsageError
 | 
			
		||||
		}
 | 
			
		||||
		reports = append(reports, report.SaasWriter{})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !(c.Conf.FormatJSON || c.Conf.FormatOneLineText ||
 | 
			
		||||
		c.Conf.FormatList || c.Conf.FormatFullText || c.Conf.FormatXML) {
 | 
			
		||||
		c.Conf.FormatList = true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Validating config...")
 | 
			
		||||
	if !c.Conf.ValidateOnReport() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
	if err := report.CveClient.CheckHealth(); err != nil {
 | 
			
		||||
		util.Log.Errorf("CVE HTTP server is not running. err: %s", err)
 | 
			
		||||
		util.Log.Errorf("Run go-cve-dictionary as server mode before reporting or run with -cvedb-path option")
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
	if c.Conf.CveDBURL != "" {
 | 
			
		||||
		util.Log.Infof("cve-dictionary: %s", c.Conf.CveDBURL)
 | 
			
		||||
	} else {
 | 
			
		||||
		if c.Conf.CveDBType == "sqlite3" {
 | 
			
		||||
			util.Log.Infof("cve-dictionary: %s", c.Conf.CveDBPath)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.OvalDBURL != "" {
 | 
			
		||||
		err := oval.Base{}.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("OVAL HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run goval-dictionary as server mode before reporting or run with -ovaldb-path option")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var res models.ScanResults
 | 
			
		||||
	if res, err = report.LoadScanResults(dir); err != nil {
 | 
			
		||||
	var loaded models.ScanResults
 | 
			
		||||
	if loaded, err = report.LoadScanResults(dir); err != nil {
 | 
			
		||||
		util.Log.Error(err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("Loaded: %s", dir)
 | 
			
		||||
 | 
			
		||||
	if res, err = report.FillCveInfos(res, dir); err != nil {
 | 
			
		||||
		util.Log.Error(err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	var res models.ScanResults
 | 
			
		||||
	for _, r := range loaded {
 | 
			
		||||
		if len(r.Errors) == 0 {
 | 
			
		||||
			res = append(res, r)
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Warnf("Ignored since errors occurred during scanning: %s",
 | 
			
		||||
				r.ServerName)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, r := range res {
 | 
			
		||||
		util.Log.Debugf("%s: %s",
 | 
			
		||||
			r.ServerInfo(),
 | 
			
		||||
			pp.Sprintf("%s", c.Conf.Servers[r.ServerName]))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.UUID {
 | 
			
		||||
		// Ensure UUIDs of scan target servers in config.toml
 | 
			
		||||
		if err := report.EnsureUUIDs(p.configPath, res); err != nil {
 | 
			
		||||
			util.Log.Errorf("Failed to ensure UUIDs: %s", err)
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !c.Conf.ToSaas {
 | 
			
		||||
		util.Log.Info("Validating db config...")
 | 
			
		||||
		if !c.Conf.ValidateOnReportDB() {
 | 
			
		||||
			return subcommands.ExitUsageError
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.CveDict.URL != "" {
 | 
			
		||||
			if err := report.CveClient.CheckHealth(); err != nil {
 | 
			
		||||
				util.Log.Errorf("CVE HTTP server is not running. err: %s", err)
 | 
			
		||||
				util.Log.Errorf("Run go-cve-dictionary as server mode before reporting or run with `-cvedb-type=sqlite3 -cvedb-sqlite3-path` option instead of -cvedb-url")
 | 
			
		||||
				return subcommands.ExitFailure
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.OvalDict.URL != "" {
 | 
			
		||||
			err := oval.Base{}.CheckHTTPHealth()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				util.Log.Errorf("OVAL HTTP server is not running. err: %s", err)
 | 
			
		||||
				util.Log.Errorf("Run goval-dictionary as server mode before reporting or run with `-ovaldb-type=sqlite3 -ovaldb-sqlite3-path` option instead of -ovaldb-url")
 | 
			
		||||
				return subcommands.ExitFailure
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.Gost.URL != "" {
 | 
			
		||||
			util.Log.Infof("gost: %s", c.Conf.Gost.URL)
 | 
			
		||||
			err := gost.Base{}.CheckHTTPHealth()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				util.Log.Errorf("gost HTTP server is not running. err: %s", err)
 | 
			
		||||
				util.Log.Errorf("Run gost as server mode before reporting or run with `-gostdb-type=sqlite3 -gostdb-sqlite3-path` option instead of -gostdb-url")
 | 
			
		||||
				return subcommands.ExitFailure
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.Exploit.URL != "" {
 | 
			
		||||
			err := exploit.CheckHTTPHealth()
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				util.Log.Errorf("exploit HTTP server is not running. err: %s", err)
 | 
			
		||||
				util.Log.Errorf("Run go-exploitdb as server mode before reporting")
 | 
			
		||||
				return subcommands.ExitFailure
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		dbclient, locked, err := report.NewDBClient(report.DBClientConf{
 | 
			
		||||
			CveDictCnf:  c.Conf.CveDict,
 | 
			
		||||
			OvalDictCnf: c.Conf.OvalDict,
 | 
			
		||||
			GostCnf:     c.Conf.Gost,
 | 
			
		||||
			ExploitCnf:  c.Conf.Exploit,
 | 
			
		||||
			DebugSQL:    c.Conf.DebugSQL,
 | 
			
		||||
		})
 | 
			
		||||
		if locked {
 | 
			
		||||
			util.Log.Errorf("SQLite3 is locked. Close other DB connections and try again: %s", err)
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("Failed to init DB Clients: %s", err)
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
		defer dbclient.CloseDB()
 | 
			
		||||
 | 
			
		||||
		if res, err = report.FillCveInfos(*dbclient, res, dir); err != nil {
 | 
			
		||||
			util.Log.Error(err)
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, w := range reports {
 | 
			
		||||
@@ -450,5 +423,6 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return subcommands.ExitSuccess
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										104
									
								
								commands/scan.go
									
									
									
									
									
								
							
							
						
						
									
										104
									
								
								commands/scan.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -35,18 +35,8 @@ import (
 | 
			
		||||
 | 
			
		||||
// ScanCmd is Subcommand of host discovery mode
 | 
			
		||||
type ScanCmd struct {
 | 
			
		||||
	debug          bool
 | 
			
		||||
	configPath     string
 | 
			
		||||
	resultsDir     string
 | 
			
		||||
	logDir         string
 | 
			
		||||
	cacheDBPath    string
 | 
			
		||||
	httpProxy      string
 | 
			
		||||
	askKeyPassword bool
 | 
			
		||||
	containersOnly bool
 | 
			
		||||
	deep           bool
 | 
			
		||||
	skipBroken     bool
 | 
			
		||||
	sshNative      bool
 | 
			
		||||
	pipe           bool
 | 
			
		||||
	timeoutSec     int
 | 
			
		||||
	scanTimeoutSec int
 | 
			
		||||
}
 | 
			
		||||
@@ -61,12 +51,12 @@ func (*ScanCmd) Synopsis() string { return "Scan vulnerabilities" }
 | 
			
		||||
func (*ScanCmd) Usage() string {
 | 
			
		||||
	return `scan:
 | 
			
		||||
	scan
 | 
			
		||||
		[-deep]
 | 
			
		||||
		[-config=/path/to/config.toml]
 | 
			
		||||
		[-results-dir=/path/to/results]
 | 
			
		||||
		[-log-dir=/path/to/log]
 | 
			
		||||
		[-cachedb-path=/path/to/cache.db]
 | 
			
		||||
		[-ssh-native-insecure]
 | 
			
		||||
		[-ssh-config]
 | 
			
		||||
		[-containers-only]
 | 
			
		||||
		[-skip-broken]
 | 
			
		||||
		[-http-proxy=http://192.168.0.1:8080]
 | 
			
		||||
@@ -75,6 +65,7 @@ func (*ScanCmd) Usage() string {
 | 
			
		||||
		[-timeout-scan=7200]
 | 
			
		||||
		[-debug]
 | 
			
		||||
		[-pipe]
 | 
			
		||||
		[-vvv]
 | 
			
		||||
 | 
			
		||||
		[SERVER]...
 | 
			
		||||
`
 | 
			
		||||
@@ -82,93 +73,63 @@ func (*ScanCmd) Usage() string {
 | 
			
		||||
 | 
			
		||||
// SetFlags set flag
 | 
			
		||||
func (p *ScanCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	f.BoolVar(&p.debug, "debug", false, "debug mode")
 | 
			
		||||
	f.BoolVar(&c.Conf.Debug, "debug", false, "debug mode")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
 | 
			
		||||
	defaultConfPath := filepath.Join(wd, "config.toml")
 | 
			
		||||
	f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
 | 
			
		||||
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
	f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
	f.StringVar(&c.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := util.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&p.logDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
	f.StringVar(&c.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
 | 
			
		||||
	defaultCacheDBPath := filepath.Join(wd, "cache.db")
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cacheDBPath,
 | 
			
		||||
		"cachedb-path",
 | 
			
		||||
		defaultCacheDBPath,
 | 
			
		||||
	f.StringVar(&c.Conf.CacheDBPath, "cachedb-path", defaultCacheDBPath,
 | 
			
		||||
		"/path/to/cache.db (local cache of changelog for Ubuntu/Debian)")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.sshNative,
 | 
			
		||||
		"ssh-native-insecure",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.SSHNative, "ssh-native-insecure", false,
 | 
			
		||||
		"Use Native Go implementation of SSH. Default: Use the external command")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.containersOnly,
 | 
			
		||||
		"containers-only",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.SSHConfig, "ssh-config", false,
 | 
			
		||||
		"Use SSH options specified in ssh_config preferentially")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.ContainersOnly, "containers-only", false,
 | 
			
		||||
		"Scan containers only. Default: Scan both of hosts and containers")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.skipBroken,
 | 
			
		||||
		"skip-broken",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.SkipBroken, "skip-broken", false,
 | 
			
		||||
		"[For CentOS] yum update changelog with --skip-broken option")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.httpProxy,
 | 
			
		||||
		"http-proxy",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://proxy-url:port (default: empty)",
 | 
			
		||||
	)
 | 
			
		||||
	f.StringVar(&c.Conf.HTTPProxy, "http-proxy", "",
 | 
			
		||||
		"http://proxy-url:port (default: empty)")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.askKeyPassword,
 | 
			
		||||
		"ask-key-password",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&p.askKeyPassword, "ask-key-password", false,
 | 
			
		||||
		"Ask ssh privatekey password before scanning",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.deep,
 | 
			
		||||
		"deep",
 | 
			
		||||
		false,
 | 
			
		||||
		"Deep scan mode. Scan accuracy improves and scanned information becomes richer. Since analysis of changelog, issue commands requiring sudo, but it may be slower and high load on the target server")
 | 
			
		||||
	f.BoolVar(&c.Conf.Pipe, "pipe", false, "Use stdin via PIPE")
 | 
			
		||||
	f.BoolVar(&c.Conf.Vvv, "vvv", false, "ssh -vvv")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.pipe,
 | 
			
		||||
		"pipe",
 | 
			
		||||
		false,
 | 
			
		||||
		"Use stdin via PIPE")
 | 
			
		||||
 | 
			
		||||
	f.IntVar(
 | 
			
		||||
		&p.timeoutSec,
 | 
			
		||||
		"timeout",
 | 
			
		||||
		5*60,
 | 
			
		||||
	f.IntVar(&p.timeoutSec, "timeout", 5*60,
 | 
			
		||||
		"Number of seconds for processing other than scan",
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	f.IntVar(
 | 
			
		||||
		&p.scanTimeoutSec,
 | 
			
		||||
		"timeout-scan",
 | 
			
		||||
		120*60,
 | 
			
		||||
	f.IntVar(&p.scanTimeoutSec, "timeout-scan", 120*60,
 | 
			
		||||
		"Number of seconds for scanning vulnerabilities for all servers",
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
 | 
			
		||||
	// Setup Logger
 | 
			
		||||
	c.Conf.Debug = p.debug
 | 
			
		||||
	c.Conf.LogDir = p.logDir
 | 
			
		||||
	util.Log = util.NewCustomLogger(c.ServerInfo{})
 | 
			
		||||
 | 
			
		||||
	if err := mkdirDotVuls(); err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to create .vuls: %s", err)
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var keyPass string
 | 
			
		||||
	var err error
 | 
			
		||||
	if p.askKeyPassword {
 | 
			
		||||
@@ -190,7 +151,6 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
 | 
			
		||||
	util.Log.Info("Start scanning")
 | 
			
		||||
	util.Log.Infof("config: %s", p.configPath)
 | 
			
		||||
 | 
			
		||||
	c.Conf.Pipe = p.pipe
 | 
			
		||||
	var servernames []string
 | 
			
		||||
	if 0 < len(f.Args()) {
 | 
			
		||||
		servernames = f.Args()
 | 
			
		||||
@@ -226,14 +186,6 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Debugf("%s", pp.Sprintf("%v", target))
 | 
			
		||||
 | 
			
		||||
	c.Conf.ResultsDir = p.resultsDir
 | 
			
		||||
	c.Conf.CacheDBPath = p.cacheDBPath
 | 
			
		||||
	c.Conf.SSHNative = p.sshNative
 | 
			
		||||
	c.Conf.HTTPProxy = p.httpProxy
 | 
			
		||||
	c.Conf.ContainersOnly = p.containersOnly
 | 
			
		||||
	c.Conf.Deep = p.deep
 | 
			
		||||
	c.Conf.SkipBroken = p.skipBroken
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Validating config...")
 | 
			
		||||
	if !c.Conf.ValidateOnScan() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
@@ -245,6 +197,12 @@ func (p *ScanCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Checking Scan Modes... ")
 | 
			
		||||
	if err := scan.CheckScanModes(); err != nil {
 | 
			
		||||
		util.Log.Errorf("Fix config.toml: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Detecting Platforms... ")
 | 
			
		||||
	scan.DetectPlatforms(p.timeoutSec)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										239
									
								
								commands/server.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										239
									
								
								commands/server.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,239 @@
 | 
			
		||||
/* 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 commands
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	// "github.com/future-architect/vuls/Server"
 | 
			
		||||
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/exploit"
 | 
			
		||||
	"github.com/future-architect/vuls/gost"
 | 
			
		||||
	"github.com/future-architect/vuls/oval"
 | 
			
		||||
	"github.com/future-architect/vuls/report"
 | 
			
		||||
	"github.com/future-architect/vuls/server"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
	cvelog "github.com/kotakanbe/go-cve-dictionary/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ServerCmd is subcommand for server
 | 
			
		||||
type ServerCmd struct {
 | 
			
		||||
	configPath  string
 | 
			
		||||
	listen      string
 | 
			
		||||
	cveDict     c.GoCveDictConf
 | 
			
		||||
	ovalDict    c.GovalDictConf
 | 
			
		||||
	gostConf    c.GostConf
 | 
			
		||||
	exploitConf c.ExploitConf
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Name return subcommand name
 | 
			
		||||
func (*ServerCmd) Name() string { return "server" }
 | 
			
		||||
 | 
			
		||||
// Synopsis return synopsis
 | 
			
		||||
func (*ServerCmd) Synopsis() string { return "Server" }
 | 
			
		||||
 | 
			
		||||
// Usage return usage
 | 
			
		||||
func (*ServerCmd) Usage() string {
 | 
			
		||||
	return `Server:
 | 
			
		||||
	Server
 | 
			
		||||
		[-lang=en|ja]
 | 
			
		||||
		[-config=/path/to/config.toml]
 | 
			
		||||
		[-log-dir=/path/to/log]
 | 
			
		||||
		[-cvss-over=7]
 | 
			
		||||
		[-ignore-unscored-cves]
 | 
			
		||||
		[-ignore-unfixed]
 | 
			
		||||
		[-to-localfile]
 | 
			
		||||
		[-format-json]
 | 
			
		||||
		[-http-proxy=http://192.168.0.1:8080]
 | 
			
		||||
		[-debug]
 | 
			
		||||
		[-debug-sql]
 | 
			
		||||
		[-listen=localhost:5515]
 | 
			
		||||
		[-cvedb-type=sqlite3|mysql|postgres|redis|http]
 | 
			
		||||
		[-cvedb-sqlite3-path=/path/to/cve.sqlite3]
 | 
			
		||||
		[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
 | 
			
		||||
		[-ovaldb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-ovaldb-sqlite3-path=/path/to/oval.sqlite3]
 | 
			
		||||
		[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
 | 
			
		||||
		[-gostdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-gostdb-sqlite3-path=/path/to/gost.sqlite3]
 | 
			
		||||
		[-gostdb-url=http://127.0.0.1:1325 or DB connection string]
 | 
			
		||||
		[-exploitdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-exploitdb-sqlite3-path=/path/to/exploitdb.sqlite3]
 | 
			
		||||
		[-exploitdb-url=http://127.0.0.1:1326 or DB connection string]
 | 
			
		||||
 | 
			
		||||
		[RFC3339 datetime format under results dir]
 | 
			
		||||
`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetFlags set flag
 | 
			
		||||
func (p *ServerCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	f.StringVar(&c.Conf.Lang, "lang", "en", "[en|ja]")
 | 
			
		||||
	f.BoolVar(&c.Conf.Debug, "debug", false, "debug mode")
 | 
			
		||||
	f.BoolVar(&c.Conf.DebugSQL, "debug-sql", false, "SQL debug mode")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
	defaultConfPath := filepath.Join(wd, "config.toml")
 | 
			
		||||
	f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
 | 
			
		||||
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
	f.StringVar(&c.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := util.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&c.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
 | 
			
		||||
	f.Float64Var(&c.Conf.CvssScoreOver, "cvss-over", 0,
 | 
			
		||||
		"-cvss-over=6.5 means Servering CVSS Score 6.5 and over (default: 0 (means Server all))")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreUnscoredCves, "ignore-unscored-cves", false,
 | 
			
		||||
		"Don't Server the unscored CVEs")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreUnfixed, "ignore-unfixed", false,
 | 
			
		||||
		"Don't Server the unfixed CVEs")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&c.Conf.HTTPProxy, "http-proxy", "",
 | 
			
		||||
		"http://proxy-url:port (default: empty)")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.FormatJSON, "format-json", false, "JSON format")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.ToLocalFile, "to-localfile", false, "Write report to localfile")
 | 
			
		||||
	f.StringVar(&p.listen, "listen", "localhost:5515",
 | 
			
		||||
		"host:port (default: localhost:5515)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.cveDict.Type, "cvedb-type", "",
 | 
			
		||||
		"DB type of go-cve-dictionary (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.cveDict.SQLite3Path, "cvedb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.cveDict.URL, "cvedb-url", "",
 | 
			
		||||
		"http://go-cve-dictionary.com:1323 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.ovalDict.Type, "ovaldb-type", "",
 | 
			
		||||
		"DB type of goval-dictionary (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.ovalDict.SQLite3Path, "ovaldb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.ovalDict.URL, "ovaldb-url", "",
 | 
			
		||||
		"http://goval-dictionary.com:1324 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.gostConf.Type, "gostdb-type", "",
 | 
			
		||||
		"DB type of gost (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.gostConf.SQLite3Path, "gostdb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.gostConf.URL, "gostdb-url", "",
 | 
			
		||||
		"http://gost.com:1325 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.exploitConf.Type, "exploitdb-type", "",
 | 
			
		||||
		"DB type of exploit (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.exploitConf.SQLite3Path, "exploitdb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.exploitConf.URL, "exploitdb-url", "",
 | 
			
		||||
		"http://exploit.com:1326 or DB connection string")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
func (p *ServerCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
 | 
			
		||||
	util.Log = util.NewCustomLogger(c.ServerInfo{})
 | 
			
		||||
	cvelog.SetLogger(c.Conf.LogDir, false, c.Conf.Debug, false)
 | 
			
		||||
 | 
			
		||||
	if err := c.Load(p.configPath, ""); err != nil {
 | 
			
		||||
		util.Log.Errorf("Error loading %s, %s", p.configPath, err)
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	c.Conf.CveDict.Overwrite(p.cveDict)
 | 
			
		||||
	c.Conf.OvalDict.Overwrite(p.ovalDict)
 | 
			
		||||
	c.Conf.Gost.Overwrite(p.gostConf)
 | 
			
		||||
	c.Conf.Exploit.Overwrite(p.exploitConf)
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Validating config...")
 | 
			
		||||
	if !c.Conf.ValidateOnReport() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Validating db config...")
 | 
			
		||||
	if !c.Conf.ValidateOnReportDB() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.CveDict.URL != "" {
 | 
			
		||||
		if err := report.CveClient.CheckHealth(); err != nil {
 | 
			
		||||
			util.Log.Errorf("CVE HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run go-cve-dictionary as server mode before reporting or run with `-cvedb-type=sqlite3 -cvedb-sqlite3-path` option instead of -cvedb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.OvalDict.URL != "" {
 | 
			
		||||
		err := oval.Base{}.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("OVAL HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run goval-dictionary as server mode before reporting or run with `-ovaldb-type=sqlite3 -ovaldb-sqlite3-path` option instead of -ovaldb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.Gost.URL != "" {
 | 
			
		||||
		util.Log.Infof("gost: %s", c.Conf.Gost.URL)
 | 
			
		||||
		err := gost.Base{}.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("gost HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run gost as server mode before reporting or run with `-gostdb-type=sqlite3 -gostdb-sqlite3-path` option instead of -gostdb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.Exploit.URL != "" {
 | 
			
		||||
		err := exploit.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("exploit HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run go-exploitdb as server mode before reporting")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dbclient, locked, err := report.NewDBClient(report.DBClientConf{
 | 
			
		||||
		CveDictCnf:  c.Conf.CveDict,
 | 
			
		||||
		OvalDictCnf: c.Conf.OvalDict,
 | 
			
		||||
		GostCnf:     c.Conf.Gost,
 | 
			
		||||
		ExploitCnf:  c.Conf.Exploit,
 | 
			
		||||
		DebugSQL:    c.Conf.DebugSQL,
 | 
			
		||||
	})
 | 
			
		||||
	if locked {
 | 
			
		||||
		util.Log.Errorf("SQLite3 is locked. Close other DB connections and try again: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to init DB Clients: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defer dbclient.CloseDB()
 | 
			
		||||
 | 
			
		||||
	http.Handle("/vuls", server.VulsHandler{DBclient: *dbclient})
 | 
			
		||||
	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		fmt.Fprintf(w, "ok")
 | 
			
		||||
	})
 | 
			
		||||
	util.Log.Infof("Listening on %s", p.listen)
 | 
			
		||||
	if err := http.ListenAndServe(p.listen, nil); err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to start server: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
	return subcommands.ExitSuccess
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										251
									
								
								commands/tui.go
									
									
									
									
									
								
							
							
						
						
									
										251
									
								
								commands/tui.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -24,36 +24,23 @@ import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/exploit"
 | 
			
		||||
	"github.com/future-architect/vuls/gost"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/oval"
 | 
			
		||||
	"github.com/future-architect/vuls/report"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
	cvelog "github.com/kotakanbe/go-cve-dictionary/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TuiCmd is Subcommand of host discovery mode
 | 
			
		||||
type TuiCmd struct {
 | 
			
		||||
	lang       string
 | 
			
		||||
	debugSQL   bool
 | 
			
		||||
	debug      bool
 | 
			
		||||
	configPath string
 | 
			
		||||
	logDir     string
 | 
			
		||||
 | 
			
		||||
	resultsDir string
 | 
			
		||||
	refreshCve bool
 | 
			
		||||
 | 
			
		||||
	cvedbtype        string
 | 
			
		||||
	cvedbpath        string
 | 
			
		||||
	cveDictionaryURL string
 | 
			
		||||
 | 
			
		||||
	ovalDBType string
 | 
			
		||||
	ovalDBPath string
 | 
			
		||||
	ovalDBURL  string
 | 
			
		||||
 | 
			
		||||
	cvssScoreOver      float64
 | 
			
		||||
	ignoreUnscoredCves bool
 | 
			
		||||
	ignoreUnfixed      bool
 | 
			
		||||
 | 
			
		||||
	pipe bool
 | 
			
		||||
	configPath  string
 | 
			
		||||
	cveDict     c.GoCveDictConf
 | 
			
		||||
	ovalDict    c.GovalDictConf
 | 
			
		||||
	gostConf    c.GostConf
 | 
			
		||||
	exploitConf c.ExploitConf
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Name return subcommand name
 | 
			
		||||
@@ -68,13 +55,8 @@ func (*TuiCmd) Usage() string {
 | 
			
		||||
	tui
 | 
			
		||||
		[-refresh-cve]
 | 
			
		||||
		[-config=/path/to/config.toml]
 | 
			
		||||
		[-cvedb-type=sqlite3|mysql|postgres]
 | 
			
		||||
		[-cvedb-path=/path/to/cve.sqlite3]
 | 
			
		||||
		[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
 | 
			
		||||
		[-ovaldb-type=sqlite3|mysql]
 | 
			
		||||
		[-ovaldb-path=/path/to/oval.sqlite3]
 | 
			
		||||
		[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
 | 
			
		||||
		[-cvss-over=7]
 | 
			
		||||
		[-diff]
 | 
			
		||||
		[-ignore-unscored-cves]
 | 
			
		||||
		[-ignore-unfixed]
 | 
			
		||||
		[-results-dir=/path/to/results]
 | 
			
		||||
@@ -82,6 +64,18 @@ func (*TuiCmd) Usage() string {
 | 
			
		||||
		[-debug]
 | 
			
		||||
		[-debug-sql]
 | 
			
		||||
		[-pipe]
 | 
			
		||||
		[-cvedb-type=sqlite3|mysql|postgres|redis|http]
 | 
			
		||||
		[-cvedb-sqlite3-path=/path/to/cve.sqlite3]
 | 
			
		||||
		[-cvedb-url=http://127.0.0.1:1323 or DB connection string]
 | 
			
		||||
		[-ovaldb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-ovaldb-sqlite3-path=/path/to/oval.sqlite3]
 | 
			
		||||
		[-ovaldb-url=http://127.0.0.1:1324 or DB connection string]
 | 
			
		||||
		[-gostdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-gostdb-sqlite3-path=/path/to/gost.sqlite3]
 | 
			
		||||
		[-gostdb-url=http://127.0.0.1:1325 or DB connection string]
 | 
			
		||||
		[-exploitdb-type=sqlite3|mysql|redis|http]
 | 
			
		||||
		[-exploitdb-sqlite3-path=/path/to/exploitdb.sqlite3]
 | 
			
		||||
		[-exploitdb-url=http://127.0.0.1:1326 or DB connection string]
 | 
			
		||||
 | 
			
		||||
`
 | 
			
		||||
}
 | 
			
		||||
@@ -89,86 +83,61 @@ func (*TuiCmd) Usage() string {
 | 
			
		||||
// SetFlags set flag
 | 
			
		||||
func (p *TuiCmd) SetFlags(f *flag.FlagSet) {
 | 
			
		||||
	//  f.StringVar(&p.lang, "lang", "en", "[en|ja]")
 | 
			
		||||
	f.BoolVar(&p.debugSQL, "debug-sql", false, "debug SQL")
 | 
			
		||||
	f.BoolVar(&p.debug, "debug", false, "debug mode")
 | 
			
		||||
	f.BoolVar(&c.Conf.DebugSQL, "debug-sql", false, "debug SQL")
 | 
			
		||||
	f.BoolVar(&c.Conf.Debug, "debug", false, "debug mode")
 | 
			
		||||
 | 
			
		||||
	defaultLogDir := util.GetDefaultLogDir()
 | 
			
		||||
	f.StringVar(&p.logDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
	f.StringVar(&c.Conf.LogDir, "log-dir", defaultLogDir, "/path/to/log")
 | 
			
		||||
 | 
			
		||||
	wd, _ := os.Getwd()
 | 
			
		||||
	defaultResultsDir := filepath.Join(wd, "results")
 | 
			
		||||
	f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
	f.StringVar(&c.Conf.ResultsDir, "results-dir", defaultResultsDir, "/path/to/results")
 | 
			
		||||
 | 
			
		||||
	defaultConfPath := filepath.Join(wd, "config.toml")
 | 
			
		||||
	f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.refreshCve,
 | 
			
		||||
		"refresh-cve",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.RefreshCve, "refresh-cve", false,
 | 
			
		||||
		"Refresh CVE information in JSON file under results dir")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cvedbtype,
 | 
			
		||||
		"cvedb-type",
 | 
			
		||||
		"sqlite3",
 | 
			
		||||
		"DB type for fetching CVE dictionary (sqlite3, mysql or postgres)")
 | 
			
		||||
 | 
			
		||||
	defaultCveDBPath := filepath.Join(wd, "cve.sqlite3")
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cvedbpath,
 | 
			
		||||
		"cvedb-path",
 | 
			
		||||
		defaultCveDBPath,
 | 
			
		||||
		"/path/to/sqlite3 (For get cve detail from cve.sqlite3)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.cveDictionaryURL,
 | 
			
		||||
		"cvedb-url",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://cve-dictionary.example.com:1323 or mysql connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBType,
 | 
			
		||||
		"ovaldb-type",
 | 
			
		||||
		"sqlite3",
 | 
			
		||||
		"DB type for fetching OVAL dictionary (sqlite3 or mysql)")
 | 
			
		||||
 | 
			
		||||
	defaultOvalDBPath := filepath.Join(wd, "oval.sqlite3")
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBPath,
 | 
			
		||||
		"ovaldb-path",
 | 
			
		||||
		defaultOvalDBPath,
 | 
			
		||||
		"/path/to/sqlite3 (For get oval detail from oval.sqlite3)")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(
 | 
			
		||||
		&p.ovalDBURL,
 | 
			
		||||
		"ovaldb-url",
 | 
			
		||||
		"",
 | 
			
		||||
		"http://goval-dictionary.example.com:1324 or mysql connection string")
 | 
			
		||||
 | 
			
		||||
	f.Float64Var(
 | 
			
		||||
		&p.cvssScoreOver,
 | 
			
		||||
		"cvss-over",
 | 
			
		||||
		0,
 | 
			
		||||
	f.Float64Var(&c.Conf.CvssScoreOver, "cvss-over", 0,
 | 
			
		||||
		"-cvss-over=6.5 means reporting CVSS Score 6.5 and over (default: 0 (means report all))")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(&c.Conf.Diff, "diff", false,
 | 
			
		||||
		"Difference between previous result and current result ")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.ignoreUnscoredCves,
 | 
			
		||||
		"ignore-unscored-cves",
 | 
			
		||||
		false,
 | 
			
		||||
		&c.Conf.IgnoreUnscoredCves, "ignore-unscored-cves", false,
 | 
			
		||||
		"Don't report the unscored CVEs")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.ignoreUnfixed,
 | 
			
		||||
		"ignore-unfixed",
 | 
			
		||||
		false,
 | 
			
		||||
	f.BoolVar(&c.Conf.IgnoreUnfixed, "ignore-unfixed", false,
 | 
			
		||||
		"Don't report the unfixed CVEs")
 | 
			
		||||
 | 
			
		||||
	f.BoolVar(
 | 
			
		||||
		&p.pipe,
 | 
			
		||||
		"pipe",
 | 
			
		||||
		false,
 | 
			
		||||
		"Use stdin via PIPE")
 | 
			
		||||
	f.BoolVar(&c.Conf.Pipe, "pipe", false, "Use stdin via PIPE")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.cveDict.Type, "cvedb-type", "",
 | 
			
		||||
		"DB type of go-cve-dictionary (sqlite3, mysql, postgres or redis)")
 | 
			
		||||
	f.StringVar(&p.cveDict.SQLite3Path, "cvedb-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.cveDict.URL, "cvedb-url", "",
 | 
			
		||||
		"http://go-cve-dictionary.com:1323 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.ovalDict.Type, "ovaldb-type", "",
 | 
			
		||||
		"DB type of goval-dictionary (sqlite3, mysql, postgres or redis)")
 | 
			
		||||
	f.StringVar(&p.ovalDict.SQLite3Path, "ovaldb-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.ovalDict.URL, "ovaldb-url", "",
 | 
			
		||||
		"http://goval-dictionary.com:1324 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.gostConf.Type, "gostdb-type", "",
 | 
			
		||||
		"DB type of gost (sqlite3, mysql, postgres or redis)")
 | 
			
		||||
	f.StringVar(&p.gostConf.SQLite3Path, "gostdb-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.gostConf.URL, "gostdb-url", "",
 | 
			
		||||
		"http://gost.com:1325 or DB connection string")
 | 
			
		||||
 | 
			
		||||
	f.StringVar(&p.exploitConf.Type, "exploitdb-type", "",
 | 
			
		||||
		"DB type of exploit (sqlite3, mysql, postgres, redis or http)")
 | 
			
		||||
	f.StringVar(&p.exploitConf.SQLite3Path, "exploitdb-sqlite3-path", "", "/path/to/sqlite3")
 | 
			
		||||
	f.StringVar(&p.exploitConf.URL, "exploitdb-url", "",
 | 
			
		||||
		"http://exploit.com:1326 or DB connection string")
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute execute
 | 
			
		||||
@@ -176,41 +145,36 @@ func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) s
 | 
			
		||||
	c.Conf.Lang = "en"
 | 
			
		||||
 | 
			
		||||
	// Setup Logger
 | 
			
		||||
	c.Conf.Debug = p.debug
 | 
			
		||||
	c.Conf.DebugSQL = p.debugSQL
 | 
			
		||||
	c.Conf.LogDir = p.logDir
 | 
			
		||||
	util.Log = util.NewCustomLogger(c.ServerInfo{})
 | 
			
		||||
	log := util.Log
 | 
			
		||||
	cvelog.SetLogger(c.Conf.LogDir, false, c.Conf.Debug, false)
 | 
			
		||||
 | 
			
		||||
	if err := c.Load(p.configPath, ""); err != nil {
 | 
			
		||||
		util.Log.Errorf("Error loading %s, %s", p.configPath, err)
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	c.Conf.ResultsDir = p.resultsDir
 | 
			
		||||
	c.Conf.CveDBType = p.cvedbtype
 | 
			
		||||
	c.Conf.CveDBPath = p.cvedbpath
 | 
			
		||||
	c.Conf.CveDBURL = p.cveDictionaryURL
 | 
			
		||||
	c.Conf.OvalDBType = p.ovalDBType
 | 
			
		||||
	c.Conf.OvalDBPath = p.ovalDBPath
 | 
			
		||||
	c.Conf.OvalDBURL = p.ovalDBURL
 | 
			
		||||
	c.Conf.CvssScoreOver = p.cvssScoreOver
 | 
			
		||||
	c.Conf.IgnoreUnscoredCves = p.ignoreUnscoredCves
 | 
			
		||||
	c.Conf.IgnoreUnfixed = p.ignoreUnfixed
 | 
			
		||||
	c.Conf.RefreshCve = p.refreshCve
 | 
			
		||||
	c.Conf.CveDict.Overwrite(p.cveDict)
 | 
			
		||||
	c.Conf.OvalDict.Overwrite(p.ovalDict)
 | 
			
		||||
	c.Conf.Gost.Overwrite(p.gostConf)
 | 
			
		||||
	c.Conf.Exploit.Overwrite(p.exploitConf)
 | 
			
		||||
 | 
			
		||||
	log.Info("Validating config...")
 | 
			
		||||
	if !c.Conf.ValidateOnTui() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	var dir string
 | 
			
		||||
	var err error
 | 
			
		||||
	if c.Conf.Diff {
 | 
			
		||||
		dir, err = report.JSONDir([]string{})
 | 
			
		||||
	} else {
 | 
			
		||||
		dir, err = report.JSONDir(f.Args())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	c.Conf.Pipe = p.pipe
 | 
			
		||||
 | 
			
		||||
	dir, err := report.JSONDir(f.Args())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to read from JSON: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Info("Validating config...")
 | 
			
		||||
	if !c.Conf.ValidateOnTui() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var res models.ScanResults
 | 
			
		||||
	if res, err = report.LoadScanResults(dir); err != nil {
 | 
			
		||||
		util.Log.Error(err)
 | 
			
		||||
@@ -218,7 +182,66 @@ func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) s
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("Loaded: %s", dir)
 | 
			
		||||
 | 
			
		||||
	if res, err = report.FillCveInfos(res, dir); err != nil {
 | 
			
		||||
	util.Log.Info("Validating db config...")
 | 
			
		||||
	if !c.Conf.ValidateOnReportDB() {
 | 
			
		||||
		return subcommands.ExitUsageError
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.CveDict.URL != "" {
 | 
			
		||||
		if err := report.CveClient.CheckHealth(); err != nil {
 | 
			
		||||
			util.Log.Errorf("CVE HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run go-cve-dictionary as server mode before reporting or run with `-cvedb-type=sqlite3 -cvedb-sqlite3-path` option instead of -cvedb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.OvalDict.URL != "" {
 | 
			
		||||
		err := oval.Base{}.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("OVAL HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run goval-dictionary as server mode before reporting or run with `-ovaldb-type=sqlite3 -ovaldb-sqlite3-path` option instead of -ovaldb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.Gost.URL != "" {
 | 
			
		||||
		util.Log.Infof("gost: %s", c.Conf.Gost.URL)
 | 
			
		||||
		err := gost.Base{}.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("gost HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run gost as server mode before reporting or run with `-gostdb-type=sqlite3 -gostdb-sqlite3-path` option instead of -gostdb-url")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.Exploit.URL != "" {
 | 
			
		||||
		err := exploit.CheckHTTPHealth()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("exploit HTTP server is not running. err: %s", err)
 | 
			
		||||
			util.Log.Errorf("Run go-exploitdb as server mode before reporting")
 | 
			
		||||
			return subcommands.ExitFailure
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	dbclient, locked, err := report.NewDBClient(report.DBClientConf{
 | 
			
		||||
		CveDictCnf:  c.Conf.CveDict,
 | 
			
		||||
		OvalDictCnf: c.Conf.OvalDict,
 | 
			
		||||
		GostCnf:     c.Conf.Gost,
 | 
			
		||||
		ExploitCnf:  c.Conf.Exploit,
 | 
			
		||||
		DebugSQL:    c.Conf.DebugSQL,
 | 
			
		||||
	})
 | 
			
		||||
	if locked {
 | 
			
		||||
		util.Log.Errorf("SQLite3 is locked. Close other DB connections and try again: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		util.Log.Errorf("Failed to init DB Clients: %s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defer dbclient.CloseDB()
 | 
			
		||||
 | 
			
		||||
	if res, err = report.FillCveInfos(*dbclient, res, dir); err != nil {
 | 
			
		||||
		util.Log.Error(err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -19,8 +19,11 @@ package commands
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	"github.com/howeyc/gopass"
 | 
			
		||||
	homedir "github.com/mitchellh/go-homedir"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func getPasswd(prompt string) (string, error) {
 | 
			
		||||
@@ -31,8 +34,22 @@ func getPasswd(prompt string) (string, error) {
 | 
			
		||||
			return "", fmt.Errorf("Failed to read password")
 | 
			
		||||
		}
 | 
			
		||||
		if 0 < len(pass) {
 | 
			
		||||
			return string(pass[:]), nil
 | 
			
		||||
			return string(pass), nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func mkdirDotVuls() error {
 | 
			
		||||
	home, err := homedir.Dir()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	dotVuls := filepath.Join(home, ".vuls")
 | 
			
		||||
	if _, err := os.Stat(dotVuls); os.IsNotExist(err) {
 | 
			
		||||
		if err := os.Mkdir(dotVuls, 0700); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1009
									
								
								config/config.go
									
									
									
									
									
								
							
							
						
						
									
										1009
									
								
								config/config.go
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										103
									
								
								config/config_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								config/config_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,103 @@
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSyslogConfValidate(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		conf              SyslogConf
 | 
			
		||||
		expectedErrLength int
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			conf:              SyslogConf{},
 | 
			
		||||
			expectedErrLength: 0,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			conf: SyslogConf{
 | 
			
		||||
				Protocol: "tcp",
 | 
			
		||||
				Port:     "5140",
 | 
			
		||||
			},
 | 
			
		||||
			expectedErrLength: 0,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			conf: SyslogConf{
 | 
			
		||||
				Protocol: "udp",
 | 
			
		||||
				Port:     "12345",
 | 
			
		||||
				Severity: "emerg",
 | 
			
		||||
				Facility: "user",
 | 
			
		||||
			},
 | 
			
		||||
			expectedErrLength: 0,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			conf: SyslogConf{
 | 
			
		||||
				Protocol: "foo",
 | 
			
		||||
				Port:     "514",
 | 
			
		||||
			},
 | 
			
		||||
			expectedErrLength: 1,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			conf: SyslogConf{
 | 
			
		||||
				Protocol: "invalid",
 | 
			
		||||
				Port:     "-1",
 | 
			
		||||
			},
 | 
			
		||||
			expectedErrLength: 2,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			conf: SyslogConf{
 | 
			
		||||
				Protocol: "invalid",
 | 
			
		||||
				Port:     "invalid",
 | 
			
		||||
				Severity: "invalid",
 | 
			
		||||
				Facility: "invalid",
 | 
			
		||||
			},
 | 
			
		||||
			expectedErrLength: 4,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		Conf.ToSyslog = true
 | 
			
		||||
		errs := tt.conf.Validate()
 | 
			
		||||
		if len(errs) != tt.expectedErrLength {
 | 
			
		||||
			t.Errorf("test: %d, expected %d, actual %d", i, tt.expectedErrLength, len(errs))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMajorVersion(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  Distro
 | 
			
		||||
		out int
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: Distro{
 | 
			
		||||
				Family:  Amazon,
 | 
			
		||||
				Release: "2 (2017.12)",
 | 
			
		||||
			},
 | 
			
		||||
			out: 2,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: Distro{
 | 
			
		||||
				Family:  Amazon,
 | 
			
		||||
				Release: "2017.12",
 | 
			
		||||
			},
 | 
			
		||||
			out: 1,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: Distro{
 | 
			
		||||
				Family:  CentOS,
 | 
			
		||||
				Release: "7.10",
 | 
			
		||||
			},
 | 
			
		||||
			out: 7,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		ver, err := tt.in.MajorVersion()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Errorf("[%d] err occurred: %s", i, err)
 | 
			
		||||
		}
 | 
			
		||||
		if tt.out != ver {
 | 
			
		||||
			t.Errorf("[%d] expected %d, actual %d", i, tt.out, ver)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -20,30 +20,39 @@ package config
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/BurntSushi/toml"
 | 
			
		||||
	"github.com/future-architect/vuls/contrib/owasp-dependency-check/parser"
 | 
			
		||||
	log "github.com/sirupsen/logrus"
 | 
			
		||||
	"github.com/knqyf263/go-cpe/naming"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TOMLLoader loads config
 | 
			
		||||
type TOMLLoader struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Load load the configuraiton TOML file specified by path arg.
 | 
			
		||||
// Load load the configuration TOML file specified by path arg.
 | 
			
		||||
func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
	if Conf.Debug {
 | 
			
		||||
		log.SetLevel(log.DebugLevel)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var conf Config
 | 
			
		||||
	if _, err := toml.DecodeFile(pathToToml, &conf); err != nil {
 | 
			
		||||
		log.Error("Load config failed", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Conf.EMail = conf.EMail
 | 
			
		||||
	Conf.Slack = conf.Slack
 | 
			
		||||
	Conf.Stride = conf.Stride
 | 
			
		||||
	Conf.HipChat = conf.HipChat
 | 
			
		||||
	Conf.ChatWork = conf.ChatWork
 | 
			
		||||
	Conf.Telegram = conf.Telegram
 | 
			
		||||
	Conf.Saas = conf.Saas
 | 
			
		||||
	Conf.Syslog = conf.Syslog
 | 
			
		||||
	Conf.HTTP = conf.HTTP
 | 
			
		||||
	Conf.AWS = conf.AWS
 | 
			
		||||
	Conf.Azure = conf.Azure
 | 
			
		||||
 | 
			
		||||
	Conf.CveDict = conf.CveDict
 | 
			
		||||
	Conf.OvalDict = conf.OvalDict
 | 
			
		||||
	Conf.Gost = conf.Gost
 | 
			
		||||
	Conf.Exploit = conf.Exploit
 | 
			
		||||
 | 
			
		||||
	d := conf.Default
 | 
			
		||||
	Conf.Default = d
 | 
			
		||||
@@ -54,17 +63,16 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	i := 0
 | 
			
		||||
	for name, v := range conf.Servers {
 | 
			
		||||
	for serverName, v := range conf.Servers {
 | 
			
		||||
		if 0 < len(v.KeyPassword) {
 | 
			
		||||
			log.Warn("[Deprecated] KEYPASSWORD IN CONFIG FILE ARE UNSECURE. REMOVE THEM IMMEDIATELY FOR A SECURITY REASONS. THEY WILL BE REMOVED IN A FUTURE RELEASE.")
 | 
			
		||||
			return fmt.Errorf("[Deprecated] KEYPASSWORD IN CONFIG FILE ARE UNSECURE. REMOVE THEM IMMEDIATELY FOR A SECURITY REASONS. THEY WILL BE REMOVED IN A FUTURE RELEASE: %s", serverName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s := ServerInfo{ServerName: name}
 | 
			
		||||
 | 
			
		||||
		s := ServerInfo{ServerName: serverName}
 | 
			
		||||
		if v.Type != ServerTypePseudo {
 | 
			
		||||
			s.Host = v.Host
 | 
			
		||||
			if len(s.Host) == 0 {
 | 
			
		||||
				return fmt.Errorf("%s is invalid. host is empty", name)
 | 
			
		||||
				return fmt.Errorf("%s is invalid. host is empty", serverName)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			switch {
 | 
			
		||||
@@ -83,7 +91,7 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
				s.User = d.User
 | 
			
		||||
			default:
 | 
			
		||||
				if s.Port != "local" {
 | 
			
		||||
					return fmt.Errorf("%s is invalid. User is empty", name)
 | 
			
		||||
					return fmt.Errorf("%s is invalid. User is empty", serverName)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -94,42 +102,87 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
			if s.KeyPath != "" {
 | 
			
		||||
				if _, err := os.Stat(s.KeyPath); err != nil {
 | 
			
		||||
					return fmt.Errorf(
 | 
			
		||||
						"%s is invalid. keypath: %s not exists", name, s.KeyPath)
 | 
			
		||||
						"%s is invalid. keypath: %s not exists", serverName, s.KeyPath)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//  s.KeyPassword = keyPass
 | 
			
		||||
			s.KeyPassword = v.KeyPassword
 | 
			
		||||
			if len(s.KeyPassword) == 0 {
 | 
			
		||||
				s.KeyPassword = d.KeyPassword
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.ScanMode = v.ScanMode
 | 
			
		||||
		if len(s.ScanMode) == 0 {
 | 
			
		||||
			s.ScanMode = d.ScanMode
 | 
			
		||||
			if len(s.ScanMode) == 0 {
 | 
			
		||||
				s.ScanMode = []string{"fast"}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for _, m := range s.ScanMode {
 | 
			
		||||
			switch m {
 | 
			
		||||
			case "fast":
 | 
			
		||||
				s.Mode.Set(Fast)
 | 
			
		||||
			case "fast-root":
 | 
			
		||||
				s.Mode.Set(FastRoot)
 | 
			
		||||
			case "deep":
 | 
			
		||||
				s.Mode.Set(Deep)
 | 
			
		||||
			case "offline":
 | 
			
		||||
				s.Mode.Set(Offline)
 | 
			
		||||
			default:
 | 
			
		||||
				return fmt.Errorf("scanMode: %s of %s is invalie. Specify -fast, -fast-root, -deep or offline", m, serverName)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if err := s.Mode.validate(); err != nil {
 | 
			
		||||
			return fmt.Errorf("%s in %s", err, serverName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.CpeNames = v.CpeNames
 | 
			
		||||
		if len(s.CpeNames) == 0 {
 | 
			
		||||
			s.CpeNames = d.CpeNames
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.DependencyCheckXMLPath = v.DependencyCheckXMLPath
 | 
			
		||||
		if len(s.DependencyCheckXMLPath) == 0 {
 | 
			
		||||
			s.DependencyCheckXMLPath = d.DependencyCheckXMLPath
 | 
			
		||||
		for i, n := range s.CpeNames {
 | 
			
		||||
			uri, err := toCpeURI(n)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return fmt.Errorf("Failed to parse CPENames %s in %s: %s", n, serverName, err)
 | 
			
		||||
			}
 | 
			
		||||
			s.CpeNames[i] = uri
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Load CPEs from OWASP Dependency Check XML
 | 
			
		||||
		if len(s.DependencyCheckXMLPath) != 0 {
 | 
			
		||||
			cpes, err := parser.Parse(s.DependencyCheckXMLPath)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return fmt.Errorf(
 | 
			
		||||
					"Failed to read OWASP Dependency Check XML: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
			log.Debugf("Loaded from OWASP Dependency Check XML: %s",
 | 
			
		||||
				s.ServerName)
 | 
			
		||||
			s.CpeNames = append(s.CpeNames, cpes...)
 | 
			
		||||
		s.ContainersIncluded = v.ContainersIncluded
 | 
			
		||||
		if len(s.ContainersIncluded) == 0 {
 | 
			
		||||
			s.ContainersIncluded = d.ContainersIncluded
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.ContainersExcluded = v.ContainersExcluded
 | 
			
		||||
		if len(s.ContainersExcluded) == 0 {
 | 
			
		||||
			s.ContainersExcluded = d.ContainersExcluded
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.ContainerType = v.ContainerType
 | 
			
		||||
		if len(s.ContainerType) == 0 {
 | 
			
		||||
			s.ContainerType = d.ContainerType
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.Containers = v.Containers
 | 
			
		||||
		if len(s.Containers.Includes) == 0 {
 | 
			
		||||
			s.Containers = d.Containers
 | 
			
		||||
		for contName, cont := range s.Containers {
 | 
			
		||||
			cont.IgnoreCves = append(cont.IgnoreCves, d.IgnoreCves...)
 | 
			
		||||
			s.Containers[contName] = cont
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(v.DependencyCheckXMLPath) != 0 || len(d.DependencyCheckXMLPath) != 0 {
 | 
			
		||||
			return fmt.Errorf("[DEPRECATED] dependencyCheckXMLPath IS DEPRECATED. USE owaspDCXMLPath INSTEAD: %s", serverName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.OwaspDCXMLPath = v.OwaspDCXMLPath
 | 
			
		||||
		if len(s.OwaspDCXMLPath) == 0 {
 | 
			
		||||
			s.OwaspDCXMLPath = d.OwaspDCXMLPath
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.Memo = v.Memo
 | 
			
		||||
		if s.Memo == "" {
 | 
			
		||||
			s.Memo = d.Memo
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.IgnoreCves = v.IgnoreCves
 | 
			
		||||
@@ -146,19 +199,43 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.Optional = v.Optional
 | 
			
		||||
		for _, dkv := range d.Optional {
 | 
			
		||||
		s.IgnorePkgsRegexp = v.IgnorePkgsRegexp
 | 
			
		||||
		for _, pkg := range d.IgnorePkgsRegexp {
 | 
			
		||||
			found := false
 | 
			
		||||
			for _, kv := range s.Optional {
 | 
			
		||||
				if dkv[0] == kv[0] {
 | 
			
		||||
			for _, p := range s.IgnorePkgsRegexp {
 | 
			
		||||
				if pkg == p {
 | 
			
		||||
					found = true
 | 
			
		||||
					break
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if !found {
 | 
			
		||||
				s.Optional = append(s.Optional, dkv)
 | 
			
		||||
				s.IgnorePkgsRegexp = append(s.IgnorePkgsRegexp, pkg)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for _, reg := range s.IgnorePkgsRegexp {
 | 
			
		||||
			_, err := regexp.Compile(reg)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return fmt.Errorf("Faild to parse %s in %s. err: %s", reg, serverName, err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for contName, cont := range s.Containers {
 | 
			
		||||
			for _, reg := range cont.IgnorePkgsRegexp {
 | 
			
		||||
				_, err := regexp.Compile(reg)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					return fmt.Errorf("Faild to parse %s in %s@%s. err: %s",
 | 
			
		||||
						reg, contName, serverName, err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		opt := map[string]interface{}{}
 | 
			
		||||
		for k, v := range d.Optional {
 | 
			
		||||
			opt[k] = v
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range v.Optional {
 | 
			
		||||
			opt[k] = v
 | 
			
		||||
		}
 | 
			
		||||
		s.Optional = opt
 | 
			
		||||
 | 
			
		||||
		s.Enablerepo = v.Enablerepo
 | 
			
		||||
		if len(s.Enablerepo) == 0 {
 | 
			
		||||
@@ -172,18 +249,48 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error {
 | 
			
		||||
				default:
 | 
			
		||||
					return fmt.Errorf(
 | 
			
		||||
						"For now, enablerepo have to be base or updates: %s, servername: %s",
 | 
			
		||||
						s.Enablerepo, name)
 | 
			
		||||
						s.Enablerepo, serverName)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.GitHubRepos = v.GitHubRepos
 | 
			
		||||
		for ownerRepo, githubSetting := range s.GitHubRepos {
 | 
			
		||||
			if ss := strings.Split(ownerRepo, "/"); len(ss) != 2 {
 | 
			
		||||
				return fmt.Errorf("Failed to parse GitHub owner/repo: %s in %s",
 | 
			
		||||
					ownerRepo, serverName)
 | 
			
		||||
			}
 | 
			
		||||
			if githubSetting.Token == "" {
 | 
			
		||||
				return fmt.Errorf("GitHub owner/repo: %s in %s token is empty",
 | 
			
		||||
					ownerRepo, serverName)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		s.UUIDs = v.UUIDs
 | 
			
		||||
		s.Type = v.Type
 | 
			
		||||
 | 
			
		||||
		s.LogMsgAnsiColor = Colors[i%len(Colors)]
 | 
			
		||||
		i++
 | 
			
		||||
 | 
			
		||||
		servers[name] = s
 | 
			
		||||
		servers[serverName] = s
 | 
			
		||||
	}
 | 
			
		||||
	Conf.Servers = servers
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func toCpeURI(cpename string) (string, error) {
 | 
			
		||||
	if strings.HasPrefix(cpename, "cpe:2.3:") {
 | 
			
		||||
		wfn, err := naming.UnbindFS(cpename)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
		return naming.BindToURI(wfn), nil
 | 
			
		||||
	} else if strings.HasPrefix(cpename, "cpe:/") {
 | 
			
		||||
		wfn, err := naming.UnbindURI(cpename)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
		return naming.BindToURI(wfn), nil
 | 
			
		||||
	}
 | 
			
		||||
	return "", fmt.Errorf("Unknow CPE format: %s", cpename)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										44
									
								
								config/tomlloader_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								config/tomlloader_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestToCpeURI(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in       string
 | 
			
		||||
		expected string
 | 
			
		||||
		err      bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in:       "",
 | 
			
		||||
			expected: "",
 | 
			
		||||
			err:      true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in:       "cpe:/a:microsoft:internet_explorer:10",
 | 
			
		||||
			expected: "cpe:/a:microsoft:internet_explorer:10",
 | 
			
		||||
			err:      false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in:       "cpe:2.3:a:microsoft:internet_explorer:10:*:*:*:*:*:*:*",
 | 
			
		||||
			expected: "cpe:/a:microsoft:internet_explorer:10",
 | 
			
		||||
			err:      false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		actual, err := toCpeURI(tt.in)
 | 
			
		||||
		if err != nil && !tt.err {
 | 
			
		||||
			t.Errorf("[%d] unexpected error occurred, in: %s act: %s, exp: %s",
 | 
			
		||||
				i, tt.in, actual, tt.expected)
 | 
			
		||||
		} else if err == nil && tt.err {
 | 
			
		||||
			t.Errorf("[%d] expected error is not occurred, in: %s act: %s, exp: %s",
 | 
			
		||||
				i, tt.in, actual, tt.expected)
 | 
			
		||||
		}
 | 
			
		||||
		if actual != tt.expected {
 | 
			
		||||
			t.Errorf("[%d] in: %s, actual: %s, expected: %s",
 | 
			
		||||
				i, tt.in, actual, tt.expected)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -6,6 +6,8 @@ import (
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	log "github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type analysis struct {
 | 
			
		||||
@@ -30,17 +32,19 @@ func appendIfMissing(slice []string, str string) []string {
 | 
			
		||||
	return append(slice, str)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Parse parses XML and collect list of cpe
 | 
			
		||||
// Parse parses OWASP dependency check XML and collect list of cpe
 | 
			
		||||
func Parse(path string) ([]string, error) {
 | 
			
		||||
	file, err := os.Open(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Failed to open: %s", err)
 | 
			
		||||
		log.Warnf("OWASP Dependency Check XML is not found: %s", path)
 | 
			
		||||
		return []string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	defer file.Close()
 | 
			
		||||
 | 
			
		||||
	b, err := ioutil.ReadAll(file)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Failed to read: %s", err)
 | 
			
		||||
		log.Warnf("Failed to read OWASP Dependency Check XML: %s", path)
 | 
			
		||||
		return []string{}, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var anal analysis
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										65
									
								
								cwe/owasp.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								cwe/owasp.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
package cwe
 | 
			
		||||
 | 
			
		||||
// OwaspTopTen2017 has CWE-ID in OWSP Top 10
 | 
			
		||||
var OwaspTopTen2017 = map[string]string{
 | 
			
		||||
	"77":  "1",
 | 
			
		||||
	"89":  "1",
 | 
			
		||||
	"564": "1",
 | 
			
		||||
	"917": "1",
 | 
			
		||||
 | 
			
		||||
	"287": "2",
 | 
			
		||||
	"384": "2",
 | 
			
		||||
 | 
			
		||||
	"220": "3",
 | 
			
		||||
	"310": "3",
 | 
			
		||||
	"312": "3",
 | 
			
		||||
	"319": "3",
 | 
			
		||||
	"326": "3",
 | 
			
		||||
	"359": "3",
 | 
			
		||||
 | 
			
		||||
	"611": "4",
 | 
			
		||||
 | 
			
		||||
	"22":  "5",
 | 
			
		||||
	"284": "5",
 | 
			
		||||
	"285": "5",
 | 
			
		||||
	"639": "5",
 | 
			
		||||
 | 
			
		||||
	"2":   "6",
 | 
			
		||||
	"16":  "6",
 | 
			
		||||
	"388": "6",
 | 
			
		||||
 | 
			
		||||
	"79": "7",
 | 
			
		||||
 | 
			
		||||
	"502": "8",
 | 
			
		||||
 | 
			
		||||
	"223": "10",
 | 
			
		||||
	"778": "10",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// OwaspTopTen2017GitHubURLEn has GitHub links
 | 
			
		||||
var OwaspTopTen2017GitHubURLEn = map[string]string{
 | 
			
		||||
	"1":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa1-injection.md",
 | 
			
		||||
	"2":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa2-broken-authentication.md",
 | 
			
		||||
	"3":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa3-sensitive-data-disclosure.md",
 | 
			
		||||
	"4":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa4-xxe.md",
 | 
			
		||||
	"5":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa5-broken-access-control.md",
 | 
			
		||||
	"6":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa6-security-misconfiguration.md",
 | 
			
		||||
	"7":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa7-xss.md",
 | 
			
		||||
	"8":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa8-insecure-deserialization.md",
 | 
			
		||||
	"9":  "https://github.com/OWASP/Top10/blob/master/2017/en/0xa9-known-vulns.md<Paste>",
 | 
			
		||||
	"10": "https://github.com/OWASP/Top10/blob/master/2017/en/0xaa-logging-detection-response.md",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// OwaspTopTen2017GitHubURLJa has GitHub links
 | 
			
		||||
var OwaspTopTen2017GitHubURLJa = map[string]string{
 | 
			
		||||
	"1":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa1-injection.md",
 | 
			
		||||
	"2":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa2-broken-authentication.md",
 | 
			
		||||
	"3":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa3-sensitive-data-disclosure.md",
 | 
			
		||||
	"4":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa4-xxe.md",
 | 
			
		||||
	"5":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa5-broken-access-control.md",
 | 
			
		||||
	"6":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa6-security-misconfiguration.md",
 | 
			
		||||
	"7":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa7-xss.md",
 | 
			
		||||
	"8":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa8-insecure-deserialization.md",
 | 
			
		||||
	"9":  "https://github.com/OWASP/Top10/blob/master/2017/ja/0xa9-known-vulns.md<Paste>",
 | 
			
		||||
	"10": "https://github.com/OWASP/Top10/blob/master/2017/ja/0xaa-logging-detection-response.md",
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										131
									
								
								exploit/exploit.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								exploit/exploit.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,131 @@
 | 
			
		||||
/* 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 exploit
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	cnf "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/mozqnet/go-exploitdb/db"
 | 
			
		||||
	exploitmodels "github.com/mozqnet/go-exploitdb/models"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// FillWithExploit fills exploit information that has in Exploit
 | 
			
		||||
func FillWithExploit(driver db.DB, r *models.ScanResult) (nExploitCve int, err error) {
 | 
			
		||||
	if cnf.Conf.Exploit.IsFetchViaHTTP() {
 | 
			
		||||
		var cveIDs []string
 | 
			
		||||
		for cveID := range r.ScannedCves {
 | 
			
		||||
			cveIDs = append(cveIDs, cveID)
 | 
			
		||||
		}
 | 
			
		||||
		prefix, _ := util.URLPathJoin(cnf.Conf.Exploit.URL, "cves")
 | 
			
		||||
		responses, err := getCvesViaHTTP(cveIDs, prefix)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		for _, res := range responses {
 | 
			
		||||
			exps := []*exploitmodels.Exploit{}
 | 
			
		||||
			if err := json.Unmarshal([]byte(res.json), &exps); err != nil {
 | 
			
		||||
				return 0, err
 | 
			
		||||
			}
 | 
			
		||||
			exploits := ConvertToModels(exps)
 | 
			
		||||
			v, ok := r.ScannedCves[res.request.cveID]
 | 
			
		||||
			if ok {
 | 
			
		||||
				v.Exploits = exploits
 | 
			
		||||
			}
 | 
			
		||||
			r.ScannedCves[res.request.cveID] = v
 | 
			
		||||
			nExploitCve++
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if driver == nil {
 | 
			
		||||
			return 0, nil
 | 
			
		||||
		}
 | 
			
		||||
		for cveID, vuln := range r.ScannedCves {
 | 
			
		||||
			es := driver.GetExploitByCveID(cveID)
 | 
			
		||||
			if len(es) == 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			exploits := ConvertToModels(es)
 | 
			
		||||
			vuln.Exploits = exploits
 | 
			
		||||
			r.ScannedCves[cveID] = vuln
 | 
			
		||||
			nExploitCve++
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nExploitCve, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertToModels converts gost model to vuls model
 | 
			
		||||
func ConvertToModels(es []*exploitmodels.Exploit) (exploits []models.Exploit) {
 | 
			
		||||
	for _, e := range es {
 | 
			
		||||
		var documentURL, shellURL *string
 | 
			
		||||
		if e.OffensiveSecurity != nil {
 | 
			
		||||
			os := e.OffensiveSecurity
 | 
			
		||||
			if os.Document != nil {
 | 
			
		||||
				documentURL = &os.Document.DocumentURL
 | 
			
		||||
			}
 | 
			
		||||
			if os.ShellCode != nil {
 | 
			
		||||
				shellURL = &os.ShellCode.ShellCodeURL
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		exploit := models.Exploit{
 | 
			
		||||
			ExploitType:  e.ExploitType,
 | 
			
		||||
			ID:           e.ExploitUniqueID,
 | 
			
		||||
			URL:          e.URL,
 | 
			
		||||
			Description:  e.Description,
 | 
			
		||||
			DocumentURL:  documentURL,
 | 
			
		||||
			ShellCodeURL: shellURL,
 | 
			
		||||
		}
 | 
			
		||||
		exploits = append(exploits, exploit)
 | 
			
		||||
	}
 | 
			
		||||
	return exploits
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckHTTPHealth do health check
 | 
			
		||||
func CheckHTTPHealth() error {
 | 
			
		||||
	if !cnf.Conf.Exploit.IsFetchViaHTTP() {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	url := fmt.Sprintf("%s/health", cnf.Conf.Exploit.URL)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	resp, _, errs = gorequest.New().Get(url).End()
 | 
			
		||||
	//  resp, _, errs = gorequest.New().SetDebug(config.Conf.Debug).Get(url).End()
 | 
			
		||||
	//  resp, _, errs = gorequest.New().Proxy(api.httpProxy).Get(url).End()
 | 
			
		||||
	if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
		return fmt.Errorf("Failed to connect to exploit server. url: %s, errs: %v",
 | 
			
		||||
			url, errs)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfExploitFetched checks if oval entries are in DB by family, release.
 | 
			
		||||
func CheckIfExploitFetched(driver db.DB, osFamily string) (fetched bool, err error) {
 | 
			
		||||
	//TODO
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfExploitFresh checks if oval entries are fresh enough
 | 
			
		||||
func CheckIfExploitFresh(driver db.DB, osFamily string) (ok bool, err error) {
 | 
			
		||||
	//TODO
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								exploit/exploit_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								exploit/exploit_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
package exploit
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSetPackageStates(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										133
									
								
								exploit/util.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								exploit/util.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,133 @@
 | 
			
		||||
/* 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 exploit
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/cenkalti/backoff"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type response struct {
 | 
			
		||||
	request request
 | 
			
		||||
	json    string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getCvesViaHTTP(cveIDs []string, urlPrefix string) (
 | 
			
		||||
	responses []response, err error) {
 | 
			
		||||
	nReq := len(cveIDs)
 | 
			
		||||
	reqChan := make(chan request, nReq)
 | 
			
		||||
	resChan := make(chan response, nReq)
 | 
			
		||||
	errChan := make(chan error, nReq)
 | 
			
		||||
	defer close(reqChan)
 | 
			
		||||
	defer close(resChan)
 | 
			
		||||
	defer close(errChan)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		for _, cveID := range cveIDs {
 | 
			
		||||
			reqChan <- request{
 | 
			
		||||
				cveID: cveID,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	concurrency := 10
 | 
			
		||||
	tasks := util.GenWorkers(concurrency)
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		tasks <- func() {
 | 
			
		||||
			select {
 | 
			
		||||
			case req := <-reqChan:
 | 
			
		||||
				url, err := util.URLPathJoin(
 | 
			
		||||
					urlPrefix,
 | 
			
		||||
					req.cveID,
 | 
			
		||||
				)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					errChan <- err
 | 
			
		||||
				} else {
 | 
			
		||||
					util.Log.Debugf("HTTP Request to %s", url)
 | 
			
		||||
					httpGet(url, req, resChan, errChan)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	timeout := time.After(2 * 60 * time.Second)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		select {
 | 
			
		||||
		case res := <-resChan:
 | 
			
		||||
			responses = append(responses, res)
 | 
			
		||||
		case err := <-errChan:
 | 
			
		||||
			errs = append(errs, err)
 | 
			
		||||
		case <-timeout:
 | 
			
		||||
			return nil, fmt.Errorf("Timeout Fetching OVAL")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(errs) != 0 {
 | 
			
		||||
		return nil, fmt.Errorf("Failed to fetch OVAL. err: %v", errs)
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type request struct {
 | 
			
		||||
	osMajorVersion string
 | 
			
		||||
	packName       string
 | 
			
		||||
	isSrcPack      bool
 | 
			
		||||
	cveID          string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func httpGet(url string, req request, resChan chan<- response, errChan chan<- error) {
 | 
			
		||||
	var body string
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	count, retryMax := 0, 3
 | 
			
		||||
	f := func() (err error) {
 | 
			
		||||
		//  resp, body, errs = gorequest.New().SetDebug(config.Conf.Debug).Get(url).End()
 | 
			
		||||
		resp, body, errs = gorequest.New().Get(url).End()
 | 
			
		||||
		if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
			count++
 | 
			
		||||
			if count == retryMax {
 | 
			
		||||
				return nil
 | 
			
		||||
			}
 | 
			
		||||
			return fmt.Errorf("HTTP GET error: %v, url: %s, resp: %v",
 | 
			
		||||
				errs, url, resp)
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	notify := func(err error, t time.Duration) {
 | 
			
		||||
		util.Log.Warnf("Failed to HTTP GET. retrying in %s seconds. err: %s", t, err)
 | 
			
		||||
	}
 | 
			
		||||
	err := backoff.RetryNotify(f, backoff.NewExponentialBackOff(), notify)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		errChan <- fmt.Errorf("HTTP Error %s", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if count == retryMax {
 | 
			
		||||
		errChan <- fmt.Errorf("HRetry count exceeded")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resChan <- response{
 | 
			
		||||
		request: req,
 | 
			
		||||
		json:    body,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										144
									
								
								github/github.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										144
									
								
								github/github.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,144 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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 github
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/k0kubun/pp"
 | 
			
		||||
	"golang.org/x/oauth2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// FillGitHubSecurityAlerts access to owner/repo on GitHub and fetch scurity alerts of the repository via GitHub API v4 GraphQL and then set to the given ScanResult.
 | 
			
		||||
// https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/
 | 
			
		||||
func FillGitHubSecurityAlerts(r *models.ScanResult, owner, repo, token string) (nCVEs int, err error) {
 | 
			
		||||
	src := oauth2.StaticTokenSource(
 | 
			
		||||
		&oauth2.Token{AccessToken: token},
 | 
			
		||||
	)
 | 
			
		||||
	httpClient := oauth2.NewClient(context.Background(), src)
 | 
			
		||||
 | 
			
		||||
	// TODO Use `https://github.com/shurcooL/githubv4` if the tool supports vulnerabilityAlerts Endpoint
 | 
			
		||||
	const jsonfmt = `{"query":
 | 
			
		||||
	"query { repository(owner:\"%s\", name:\"%s\") { url, vulnerabilityAlerts(first: %d, %s) { pageInfo{ endCursor, hasNextPage, startCursor}, edges { node { id, externalIdentifier, externalReference, fixedIn, packageName,  dismissReason, dismissedAt } } } } }"}`
 | 
			
		||||
	after := ""
 | 
			
		||||
 | 
			
		||||
	for {
 | 
			
		||||
		jsonStr := fmt.Sprintf(jsonfmt, owner, repo, 100, after)
 | 
			
		||||
		req, err := http.NewRequest("POST",
 | 
			
		||||
			"https://api.github.com/graphql",
 | 
			
		||||
			bytes.NewBuffer([]byte(jsonStr)),
 | 
			
		||||
		)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// https://developer.github.com/v4/previews/#repository-vulnerability-alerts
 | 
			
		||||
		// To toggle this preview and access data, need to provide a custom media type in the Accept header:
 | 
			
		||||
		// MEMO: I tried to get the affected version via GitHub API. Bit it seems difficult to determin the affected version if there are multiple dependency files such as package.json.
 | 
			
		||||
		// TODO remove this header if it is no longer preview status in the future.
 | 
			
		||||
		req.Header.Set("Accept", "application/vnd.github.vixen-preview+json")
 | 
			
		||||
		req.Header.Set("Content-Type", "application/json")
 | 
			
		||||
 | 
			
		||||
		resp, err := httpClient.Do(req)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		defer resp.Body.Close()
 | 
			
		||||
		alerts := SecurityAlerts{}
 | 
			
		||||
		if json.NewDecoder(resp.Body).Decode(&alerts); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		util.Log.Debugf("%s", pp.Sprint(alerts))
 | 
			
		||||
 | 
			
		||||
		for _, v := range alerts.Data.Repository.VulnerabilityAlerts.Edges {
 | 
			
		||||
			if config.Conf.IgnoreGitHubDismissed && v.Node.DismissReason != "" {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			pkgName := fmt.Sprintf("%s %s",
 | 
			
		||||
				alerts.Data.Repository.URL, v.Node.PackageName)
 | 
			
		||||
 | 
			
		||||
			m := models.GitHubSecurityAlert{
 | 
			
		||||
				PackageName:   pkgName,
 | 
			
		||||
				FixedIn:       v.Node.FixedIn,
 | 
			
		||||
				AffectedRange: v.Node.AffectedRange,
 | 
			
		||||
				Dismissed:     len(v.Node.DismissReason) != 0,
 | 
			
		||||
				DismissedAt:   v.Node.DismissedAt,
 | 
			
		||||
				DismissReason: v.Node.DismissReason,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			cveID := v.Node.ExternalIdentifier
 | 
			
		||||
 | 
			
		||||
			if val, ok := r.ScannedCves[cveID]; ok {
 | 
			
		||||
				val.GitHubSecurityAlerts = val.GitHubSecurityAlerts.Add(m)
 | 
			
		||||
				r.ScannedCves[cveID] = val
 | 
			
		||||
				nCVEs++
 | 
			
		||||
			} else {
 | 
			
		||||
				v := models.VulnInfo{
 | 
			
		||||
					CveID:                cveID,
 | 
			
		||||
					Confidences:          models.Confidences{models.GitHubMatch},
 | 
			
		||||
					GitHubSecurityAlerts: models.GitHubSecurityAlerts{m},
 | 
			
		||||
				}
 | 
			
		||||
				r.ScannedCves[cveID] = v
 | 
			
		||||
				nCVEs++
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if !alerts.Data.Repository.VulnerabilityAlerts.PageInfo.HasNextPage {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
		after = fmt.Sprintf(`after: \"%s\"`, alerts.Data.Repository.VulnerabilityAlerts.PageInfo.EndCursor)
 | 
			
		||||
	}
 | 
			
		||||
	return nCVEs, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//SecurityAlerts has detected CVE-IDs, PackageNames, Refs
 | 
			
		||||
type SecurityAlerts struct {
 | 
			
		||||
	Data struct {
 | 
			
		||||
		Repository struct {
 | 
			
		||||
			URL                 string `json:"url,omitempty"`
 | 
			
		||||
			VulnerabilityAlerts struct {
 | 
			
		||||
				PageInfo struct {
 | 
			
		||||
					EndCursor   string `json:"endCursor,omitempty"`
 | 
			
		||||
					HasNextPage bool   `json:"hasNextPage,omitempty"`
 | 
			
		||||
					StartCursor string `json:"startCursor,omitempty"`
 | 
			
		||||
				} `json:"pageInfo,omitempty"`
 | 
			
		||||
				Edges []struct {
 | 
			
		||||
					Node struct {
 | 
			
		||||
						ID                 string    `json:"id,omitempty"`
 | 
			
		||||
						ExternalIdentifier string    `json:"externalIdentifier,omitempty"`
 | 
			
		||||
						ExternalReference  string    `json:"externalReference,omitempty"`
 | 
			
		||||
						FixedIn            string    `json:"fixedIn,omitempty"`
 | 
			
		||||
						AffectedRange      string    `json:"affectedRange,omitempty"`
 | 
			
		||||
						PackageName        string    `json:"packageName,omitempty"`
 | 
			
		||||
						DismissReason      string    `json:"dismissReason,omitempty"`
 | 
			
		||||
						DismissedAt        time.Time `json:"dismissedAt,omitempty"`
 | 
			
		||||
					} `json:"node,omitempty"`
 | 
			
		||||
				} `json:"edges,omitempty"`
 | 
			
		||||
			} `json:"vulnerabilityAlerts,omitempty"`
 | 
			
		||||
		} `json:"repository,omitempty"`
 | 
			
		||||
	} `json:"data,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										182
									
								
								gost/debian.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								gost/debian.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,182 @@
 | 
			
		||||
/* 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 gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/knqyf263/gost/db"
 | 
			
		||||
	gostmodels "github.com/knqyf263/gost/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Debian is Gost client for Debian GNU/Linux
 | 
			
		||||
type Debian struct {
 | 
			
		||||
	Base
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type packCves struct {
 | 
			
		||||
	packName  string
 | 
			
		||||
	isSrcPack bool
 | 
			
		||||
	cves      []models.CveContent
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithGost fills cve information that has in Gost
 | 
			
		||||
func (deb Debian) FillWithGost(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	linuxImage := "linux-image-" + r.RunningKernel.Release
 | 
			
		||||
	// Add linux and set the version of running kernel to search OVAL.
 | 
			
		||||
	if r.Container.ContainerID == "" {
 | 
			
		||||
		newVer := ""
 | 
			
		||||
		if p, ok := r.Packages[linuxImage]; ok {
 | 
			
		||||
			newVer = p.NewVersion
 | 
			
		||||
		}
 | 
			
		||||
		r.Packages["linux"] = models.Package{
 | 
			
		||||
			Name:       "linux",
 | 
			
		||||
			Version:    r.RunningKernel.Version,
 | 
			
		||||
			NewVersion: newVer,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	packCvesList := []packCves{}
 | 
			
		||||
	if config.Conf.Gost.IsFetchViaHTTP() {
 | 
			
		||||
		url, _ := util.URLPathJoin(config.Conf.Gost.URL, "debian", major(r.Release), "pkgs")
 | 
			
		||||
		responses, err := getAllUnfixedCvesViaHTTP(r, url)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, res := range responses {
 | 
			
		||||
			debCves := map[string]gostmodels.DebianCVE{}
 | 
			
		||||
			if err := json.Unmarshal([]byte(res.json), &debCves); err != nil {
 | 
			
		||||
				return 0, err
 | 
			
		||||
			}
 | 
			
		||||
			cves := []models.CveContent{}
 | 
			
		||||
			for _, debcve := range debCves {
 | 
			
		||||
				cves = append(cves, *deb.ConvertToModel(&debcve))
 | 
			
		||||
			}
 | 
			
		||||
			packCvesList = append(packCvesList, packCves{
 | 
			
		||||
				packName:  res.request.packName,
 | 
			
		||||
				isSrcPack: res.request.isSrcPack,
 | 
			
		||||
				cves:      cves,
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if driver == nil {
 | 
			
		||||
			return 0, nil
 | 
			
		||||
		}
 | 
			
		||||
		for _, pack := range r.Packages {
 | 
			
		||||
			cveDebs := driver.GetUnfixedCvesDebian(major(r.Release), pack.Name)
 | 
			
		||||
			cves := []models.CveContent{}
 | 
			
		||||
			for _, cveDeb := range cveDebs {
 | 
			
		||||
				cves = append(cves, *deb.ConvertToModel(&cveDeb))
 | 
			
		||||
			}
 | 
			
		||||
			packCvesList = append(packCvesList, packCves{
 | 
			
		||||
				packName:  pack.Name,
 | 
			
		||||
				isSrcPack: false,
 | 
			
		||||
				cves:      cves,
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// SrcPack
 | 
			
		||||
		for _, pack := range r.SrcPackages {
 | 
			
		||||
			cveDebs := driver.GetUnfixedCvesDebian(major(r.Release), pack.Name)
 | 
			
		||||
			cves := []models.CveContent{}
 | 
			
		||||
			for _, cveDeb := range cveDebs {
 | 
			
		||||
				cves = append(cves, *deb.ConvertToModel(&cveDeb))
 | 
			
		||||
			}
 | 
			
		||||
			packCvesList = append(packCvesList, packCves{
 | 
			
		||||
				packName:  pack.Name,
 | 
			
		||||
				isSrcPack: true,
 | 
			
		||||
				cves:      cves,
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	delete(r.Packages, "linux")
 | 
			
		||||
 | 
			
		||||
	for _, p := range packCvesList {
 | 
			
		||||
		for _, cve := range p.cves {
 | 
			
		||||
			v, ok := r.ScannedCves[cve.CveID]
 | 
			
		||||
			if ok {
 | 
			
		||||
				if v.CveContents == nil {
 | 
			
		||||
					v.CveContents = models.NewCveContents(cve)
 | 
			
		||||
				} else {
 | 
			
		||||
					v.CveContents[models.DebianSecurityTracker] = cve
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				v = models.VulnInfo{
 | 
			
		||||
					CveID:       cve.CveID,
 | 
			
		||||
					CveContents: models.NewCveContents(cve),
 | 
			
		||||
					Confidences: models.Confidences{models.DebianSecurityTrackerMatch},
 | 
			
		||||
				}
 | 
			
		||||
				nCVEs++
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			names := []string{}
 | 
			
		||||
			if p.isSrcPack {
 | 
			
		||||
				if srcPack, ok := r.SrcPackages[p.packName]; ok {
 | 
			
		||||
					for _, binName := range srcPack.BinaryNames {
 | 
			
		||||
						if _, ok := r.Packages[binName]; ok {
 | 
			
		||||
							names = append(names, binName)
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				if p.packName == "linux" {
 | 
			
		||||
					names = append(names, linuxImage)
 | 
			
		||||
				} else {
 | 
			
		||||
					names = append(names, p.packName)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, name := range names {
 | 
			
		||||
				v.AffectedPackages = v.AffectedPackages.Store(models.PackageStatus{
 | 
			
		||||
					Name:        name,
 | 
			
		||||
					FixState:    "open",
 | 
			
		||||
					NotFixedYet: true,
 | 
			
		||||
				})
 | 
			
		||||
			}
 | 
			
		||||
			r.ScannedCves[cve.CveID] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nCVEs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertToModel converts gost model to vuls model
 | 
			
		||||
func (deb Debian) ConvertToModel(cve *gostmodels.DebianCVE) *models.CveContent {
 | 
			
		||||
	severity := ""
 | 
			
		||||
	for _, p := range cve.Package {
 | 
			
		||||
		for _, r := range p.Release {
 | 
			
		||||
			severity = r.Urgency
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return &models.CveContent{
 | 
			
		||||
		Type:          models.DebianSecurityTracker,
 | 
			
		||||
		CveID:         cve.CveID,
 | 
			
		||||
		Summary:       cve.Description,
 | 
			
		||||
		Cvss2Severity: severity,
 | 
			
		||||
		Cvss3Severity: severity,
 | 
			
		||||
		SourceLink:    "https://security-tracker.debian.org/tracker/" + cve.CveID,
 | 
			
		||||
		Optional: map[string]string{
 | 
			
		||||
			"attack range": cve.Scope,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										104
									
								
								gost/gost.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								gost/gost.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
			
		||||
/* 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 gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	cnf "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/knqyf263/gost/db"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Client is the interface of OVAL client.
 | 
			
		||||
type Client interface {
 | 
			
		||||
	FillWithGost(db.DB, *models.ScanResult) (int, error)
 | 
			
		||||
 | 
			
		||||
	//TODO implement
 | 
			
		||||
	// CheckHTTPHealth() error
 | 
			
		||||
	// CheckIfGostFetched checks if Gost entries are fetched
 | 
			
		||||
	// CheckIfGostFetched(db.DB, string, string) (bool, error)
 | 
			
		||||
	// CheckIfGostFresh(db.DB, string, string) (bool, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewClient make Client by family
 | 
			
		||||
func NewClient(family string) Client {
 | 
			
		||||
	switch family {
 | 
			
		||||
	case cnf.RedHat, cnf.CentOS:
 | 
			
		||||
		return RedHat{}
 | 
			
		||||
	case cnf.Debian:
 | 
			
		||||
		return Debian{}
 | 
			
		||||
	case cnf.Windows:
 | 
			
		||||
		return Microsoft{}
 | 
			
		||||
	default:
 | 
			
		||||
		return Pseudo{}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Base is a base struct
 | 
			
		||||
type Base struct {
 | 
			
		||||
	family string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckHTTPHealth do health check
 | 
			
		||||
func (b Base) CheckHTTPHealth() error {
 | 
			
		||||
	if !cnf.Conf.Gost.IsFetchViaHTTP() {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	url := fmt.Sprintf("%s/health", cnf.Conf.Gost.URL)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	resp, _, errs = gorequest.New().Get(url).End()
 | 
			
		||||
	//  resp, _, errs = gorequest.New().SetDebug(config.Conf.Debug).Get(url).End()
 | 
			
		||||
	//  resp, _, errs = gorequest.New().Proxy(api.httpProxy).Get(url).End()
 | 
			
		||||
	if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
		return fmt.Errorf("Failed to connect to gost server. url: %s, errs: %v",
 | 
			
		||||
			url, errs)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfGostFetched checks if oval entries are in DB by family, release.
 | 
			
		||||
func (b Base) CheckIfGostFetched(driver db.DB, osFamily string) (fetched bool, err error) {
 | 
			
		||||
	//TODO
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfGostFresh checks if oval entries are fresh enough
 | 
			
		||||
func (b Base) CheckIfGostFresh(driver db.DB, osFamily string) (ok bool, err error) {
 | 
			
		||||
	//TODO
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Pseudo is Gost client except for RedHat family and Debian
 | 
			
		||||
type Pseudo struct {
 | 
			
		||||
	Base
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithGost fills cve information that has in Gost
 | 
			
		||||
func (pse Pseudo) FillWithGost(driver db.DB, r *models.ScanResult) (int, error) {
 | 
			
		||||
	return 0, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func major(osVer string) (majorVersion string) {
 | 
			
		||||
	return strings.Split(osVer, ".")[0]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										129
									
								
								gost/gost_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								gost/gost_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,129 @@
 | 
			
		||||
package gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	gostmodels "github.com/knqyf263/gost/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSetPackageStates(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		pkgstats  []gostmodels.RedhatPackageState
 | 
			
		||||
		installed models.Packages
 | 
			
		||||
		release   string
 | 
			
		||||
		in        models.VulnInfo
 | 
			
		||||
		out       models.PackageStatuses
 | 
			
		||||
	}{
 | 
			
		||||
 | 
			
		||||
		//0 one
 | 
			
		||||
		{
 | 
			
		||||
			pkgstats: []gostmodels.RedhatPackageState{
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "Will not fix",
 | 
			
		||||
					PackageName: "bouncycastle",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:7",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			installed: models.Packages{
 | 
			
		||||
				"bouncycastle": models.Package{},
 | 
			
		||||
			},
 | 
			
		||||
			release: "7",
 | 
			
		||||
			in:      models.VulnInfo{},
 | 
			
		||||
			out: []models.PackageStatus{
 | 
			
		||||
				{
 | 
			
		||||
					Name:        "bouncycastle",
 | 
			
		||||
					FixState:    "Will not fix",
 | 
			
		||||
					NotFixedYet: true,
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		//1 two
 | 
			
		||||
		{
 | 
			
		||||
			pkgstats: []gostmodels.RedhatPackageState{
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "Will not fix",
 | 
			
		||||
					PackageName: "bouncycastle",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:7",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "Fix deferred",
 | 
			
		||||
					PackageName: "pack_a",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:7",
 | 
			
		||||
				},
 | 
			
		||||
				// ignore not-installed-package
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "Fix deferred",
 | 
			
		||||
					PackageName: "pack_b",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:7",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			installed: models.Packages{
 | 
			
		||||
				"bouncycastle": models.Package{},
 | 
			
		||||
				"pack_a":       models.Package{},
 | 
			
		||||
			},
 | 
			
		||||
			release: "7",
 | 
			
		||||
			in:      models.VulnInfo{},
 | 
			
		||||
			out: []models.PackageStatus{
 | 
			
		||||
				{
 | 
			
		||||
					Name:        "bouncycastle",
 | 
			
		||||
					FixState:    "Will not fix",
 | 
			
		||||
					NotFixedYet: true,
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					Name:        "pack_a",
 | 
			
		||||
					FixState:    "Fix deferred",
 | 
			
		||||
					NotFixedYet: true,
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		//2 ignore affected
 | 
			
		||||
		{
 | 
			
		||||
			pkgstats: []gostmodels.RedhatPackageState{
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "affected",
 | 
			
		||||
					PackageName: "bouncycastle",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:7",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			installed: models.Packages{
 | 
			
		||||
				"bouncycastle": models.Package{},
 | 
			
		||||
			},
 | 
			
		||||
			release: "7",
 | 
			
		||||
			in: models.VulnInfo{
 | 
			
		||||
				AffectedPackages: models.PackageStatuses{},
 | 
			
		||||
			},
 | 
			
		||||
			out: models.PackageStatuses{},
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		//3 look only the same os release.
 | 
			
		||||
		{
 | 
			
		||||
			pkgstats: []gostmodels.RedhatPackageState{
 | 
			
		||||
				{
 | 
			
		||||
					FixState:    "Will not fix",
 | 
			
		||||
					PackageName: "bouncycastle",
 | 
			
		||||
					Cpe:         "cpe:/o:redhat:enterprise_linux:6",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			installed: models.Packages{
 | 
			
		||||
				"bouncycastle": models.Package{},
 | 
			
		||||
			},
 | 
			
		||||
			release: "7",
 | 
			
		||||
			in: models.VulnInfo{
 | 
			
		||||
				AffectedPackages: models.PackageStatuses{},
 | 
			
		||||
			},
 | 
			
		||||
			out: models.PackageStatuses{},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	r := RedHat{}
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		out := r.mergePackageStates(tt.in, tt.pkgstats, tt.installed, tt.release)
 | 
			
		||||
		if ok := reflect.DeepEqual(tt.out, out); !ok {
 | 
			
		||||
			t.Errorf("[%d]\nexpected: %v:%T\n  actual: %v:%T\n", i, tt.out, tt.out, out, out)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										116
									
								
								gost/microsoft.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								gost/microsoft.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,116 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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 gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/knqyf263/gost/db"
 | 
			
		||||
	gostmodels "github.com/knqyf263/gost/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Microsoft is Gost client for windows
 | 
			
		||||
type Microsoft struct {
 | 
			
		||||
	Base
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithGost fills cve information that has in Gost
 | 
			
		||||
func (ms Microsoft) FillWithGost(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	if driver == nil {
 | 
			
		||||
		return 0, nil
 | 
			
		||||
	}
 | 
			
		||||
	var cveIDs []string
 | 
			
		||||
	for cveID := range r.ScannedCves {
 | 
			
		||||
		cveIDs = append(cveIDs, cveID)
 | 
			
		||||
	}
 | 
			
		||||
	for cveID, msCve := range driver.GetMicrosoftMulti(cveIDs) {
 | 
			
		||||
		if _, ok := r.ScannedCves[cveID]; !ok {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		cveCont := ms.ConvertToModel(&msCve)
 | 
			
		||||
		v, _ := r.ScannedCves[cveID]
 | 
			
		||||
		if v.CveContents == nil {
 | 
			
		||||
			v.CveContents = models.CveContents{}
 | 
			
		||||
		}
 | 
			
		||||
		v.CveContents[models.Microsoft] = *cveCont
 | 
			
		||||
		r.ScannedCves[cveID] = v
 | 
			
		||||
	}
 | 
			
		||||
	return len(cveIDs), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertToModel converts gost model to vuls model
 | 
			
		||||
func (ms Microsoft) ConvertToModel(cve *gostmodels.MicrosoftCVE) *models.CveContent {
 | 
			
		||||
	v3score := 0.0
 | 
			
		||||
	var v3Vector string
 | 
			
		||||
	for _, scoreSet := range cve.ScoreSets {
 | 
			
		||||
		if v3score < scoreSet.BaseScore {
 | 
			
		||||
			v3score = scoreSet.BaseScore
 | 
			
		||||
			v3Vector = scoreSet.Vector
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var v3Severity string
 | 
			
		||||
	for _, s := range cve.Severity {
 | 
			
		||||
		v3Severity = s.Description
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var refs []models.Reference
 | 
			
		||||
	for _, r := range cve.References {
 | 
			
		||||
		if r.AttrType == "External" {
 | 
			
		||||
			refs = append(refs, models.Reference{Link: r.URL})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var cwe []string
 | 
			
		||||
	if 0 < len(cve.CWE) {
 | 
			
		||||
		cwe = []string{cve.CWE}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	option := map[string]string{}
 | 
			
		||||
	if 0 < len(cve.ExploitStatus) {
 | 
			
		||||
		option["exploit"] = cve.ExploitStatus
 | 
			
		||||
	}
 | 
			
		||||
	if 0 < len(cve.Workaround) {
 | 
			
		||||
		option["workaround"] = cve.Workaround
 | 
			
		||||
	}
 | 
			
		||||
	var kbids []string
 | 
			
		||||
	for _, kbid := range cve.KBIDs {
 | 
			
		||||
		kbids = append(kbids, kbid.KBID)
 | 
			
		||||
	}
 | 
			
		||||
	if 0 < len(kbids) {
 | 
			
		||||
		option["kbids"] = strings.Join(kbids, ",")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &models.CveContent{
 | 
			
		||||
		Type:          models.Microsoft,
 | 
			
		||||
		CveID:         cve.CveID,
 | 
			
		||||
		Title:         cve.Title,
 | 
			
		||||
		Summary:       cve.Description,
 | 
			
		||||
		Cvss3Score:    v3score,
 | 
			
		||||
		Cvss3Vector:   v3Vector,
 | 
			
		||||
		Cvss3Severity: v3Severity,
 | 
			
		||||
		References:    refs,
 | 
			
		||||
		CweIDs:        cwe,
 | 
			
		||||
		Mitigation:    cve.Mitigation,
 | 
			
		||||
		Published:     cve.PublishDate,
 | 
			
		||||
		LastModified:  cve.LastUpdateDate,
 | 
			
		||||
		SourceLink:    "https://portal.msrc.microsoft.com/ja-jp/security-guidance/advisory/" + cve.CveID,
 | 
			
		||||
		Optional:      option,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										289
									
								
								gost/redhat.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										289
									
								
								gost/redhat.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,289 @@
 | 
			
		||||
/* 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 gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/knqyf263/gost/db"
 | 
			
		||||
	gostmodels "github.com/knqyf263/gost/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// RedHat is Gost client for RedHat family linux
 | 
			
		||||
type RedHat struct {
 | 
			
		||||
	Base
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithGost fills cve information that has in Gost
 | 
			
		||||
func (red RedHat) FillWithGost(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	if nCVEs, err = red.fillUnfixed(driver, r); err != nil {
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	return nCVEs, red.fillFixed(driver, r)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (red RedHat) fillFixed(driver db.DB, r *models.ScanResult) error {
 | 
			
		||||
	var cveIDs []string
 | 
			
		||||
	for cveID, vuln := range r.ScannedCves {
 | 
			
		||||
		if _, ok := vuln.CveContents[models.RedHatAPI]; ok {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		cveIDs = append(cveIDs, cveID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if config.Conf.Gost.IsFetchViaHTTP() {
 | 
			
		||||
		prefix, _ := util.URLPathJoin(config.Conf.Gost.URL,
 | 
			
		||||
			"redhat", "cves")
 | 
			
		||||
		responses, err := getCvesViaHTTP(cveIDs, prefix)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		for _, res := range responses {
 | 
			
		||||
			redCve := gostmodels.RedhatCVE{}
 | 
			
		||||
			if err := json.Unmarshal([]byte(res.json), &redCve); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			if redCve.ID == 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			cveCont := red.ConvertToModel(&redCve)
 | 
			
		||||
			v, ok := r.ScannedCves[res.request.cveID]
 | 
			
		||||
			if ok {
 | 
			
		||||
				if v.CveContents == nil {
 | 
			
		||||
					v.CveContents = models.NewCveContents(*cveCont)
 | 
			
		||||
				} else {
 | 
			
		||||
					v.CveContents[models.RedHatAPI] = *cveCont
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				v = models.VulnInfo{
 | 
			
		||||
					CveID:       cveCont.CveID,
 | 
			
		||||
					CveContents: models.NewCveContents(*cveCont),
 | 
			
		||||
					Confidences: models.Confidences{models.RedHatAPIMatch},
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			r.ScannedCves[res.request.cveID] = v
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if driver == nil {
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
		for cveID, redCve := range driver.GetRedhatMulti(cveIDs) {
 | 
			
		||||
			if redCve.ID == 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			cveCont := red.ConvertToModel(&redCve)
 | 
			
		||||
			v, ok := r.ScannedCves[cveID]
 | 
			
		||||
			if ok {
 | 
			
		||||
				if v.CveContents == nil {
 | 
			
		||||
					v.CveContents = models.NewCveContents(*cveCont)
 | 
			
		||||
				} else {
 | 
			
		||||
					v.CveContents[models.RedHatAPI] = *cveCont
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				v = models.VulnInfo{
 | 
			
		||||
					CveID:       cveCont.CveID,
 | 
			
		||||
					CveContents: models.NewCveContents(*cveCont),
 | 
			
		||||
					Confidences: models.Confidences{models.RedHatAPIMatch},
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			r.ScannedCves[cveID] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (red RedHat) fillUnfixed(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	if config.Conf.Gost.IsFetchViaHTTP() {
 | 
			
		||||
		prefix, _ := util.URLPathJoin(config.Conf.Gost.URL,
 | 
			
		||||
			"redhat", major(r.Release), "pkgs")
 | 
			
		||||
		responses, err := getAllUnfixedCvesViaHTTP(r, prefix)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		for _, res := range responses {
 | 
			
		||||
			// CVE-ID: RedhatCVE
 | 
			
		||||
			cves := map[string]gostmodels.RedhatCVE{}
 | 
			
		||||
			if err := json.Unmarshal([]byte(res.json), &cves); err != nil {
 | 
			
		||||
				return 0, err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, cve := range cves {
 | 
			
		||||
				cveCont := red.ConvertToModel(&cve)
 | 
			
		||||
				v, ok := r.ScannedCves[cve.Name]
 | 
			
		||||
				if ok {
 | 
			
		||||
					if v.CveContents == nil {
 | 
			
		||||
						v.CveContents = models.NewCveContents(*cveCont)
 | 
			
		||||
					} else {
 | 
			
		||||
						v.CveContents[models.RedHatAPI] = *cveCont
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					v = models.VulnInfo{
 | 
			
		||||
						CveID:       cveCont.CveID,
 | 
			
		||||
						CveContents: models.NewCveContents(*cveCont),
 | 
			
		||||
						Confidences: models.Confidences{models.RedHatAPIMatch},
 | 
			
		||||
					}
 | 
			
		||||
					nCVEs++
 | 
			
		||||
				}
 | 
			
		||||
				pkgStats := red.mergePackageStates(v,
 | 
			
		||||
					cve.PackageState, r.Packages, r.Release)
 | 
			
		||||
				if 0 < len(pkgStats) {
 | 
			
		||||
					v.AffectedPackages = pkgStats
 | 
			
		||||
					r.ScannedCves[cve.Name] = v
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if driver == nil {
 | 
			
		||||
			return 0, nil
 | 
			
		||||
		}
 | 
			
		||||
		for _, pack := range r.Packages {
 | 
			
		||||
			// CVE-ID: RedhatCVE
 | 
			
		||||
			cves := map[string]gostmodels.RedhatCVE{}
 | 
			
		||||
			cves = driver.GetUnfixedCvesRedhat(major(r.Release), pack.Name)
 | 
			
		||||
			for _, cve := range cves {
 | 
			
		||||
				cveCont := red.ConvertToModel(&cve)
 | 
			
		||||
				v, ok := r.ScannedCves[cve.Name]
 | 
			
		||||
				if ok {
 | 
			
		||||
					if v.CveContents == nil {
 | 
			
		||||
						v.CveContents = models.NewCveContents(*cveCont)
 | 
			
		||||
					} else {
 | 
			
		||||
						v.CveContents[models.RedHatAPI] = *cveCont
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					v = models.VulnInfo{
 | 
			
		||||
						CveID:       cveCont.CveID,
 | 
			
		||||
						CveContents: models.NewCveContents(*cveCont),
 | 
			
		||||
						Confidences: models.Confidences{models.RedHatAPIMatch},
 | 
			
		||||
					}
 | 
			
		||||
					nCVEs++
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				pkgStats := red.mergePackageStates(v,
 | 
			
		||||
					cve.PackageState, r.Packages, r.Release)
 | 
			
		||||
				if 0 < len(pkgStats) {
 | 
			
		||||
					v.AffectedPackages = pkgStats
 | 
			
		||||
					r.ScannedCves[cve.Name] = v
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nCVEs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (red RedHat) mergePackageStates(v models.VulnInfo, ps []gostmodels.RedhatPackageState, installed models.Packages, release string) (pkgStats models.PackageStatuses) {
 | 
			
		||||
	pkgStats = v.AffectedPackages
 | 
			
		||||
	for _, pstate := range ps {
 | 
			
		||||
		if pstate.Cpe !=
 | 
			
		||||
			"cpe:/o:redhat:enterprise_linux:"+major(release) {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !(pstate.FixState == "Will not fix" ||
 | 
			
		||||
			pstate.FixState == "Fix deferred") {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if _, ok := installed[pstate.PackageName]; !ok {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		notFixedYet := false
 | 
			
		||||
		switch pstate.FixState {
 | 
			
		||||
		case "Will not fix", "Fix deferred":
 | 
			
		||||
			notFixedYet = true
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		pkgStats = pkgStats.Store(models.PackageStatus{
 | 
			
		||||
			Name:        pstate.PackageName,
 | 
			
		||||
			FixState:    pstate.FixState,
 | 
			
		||||
			NotFixedYet: notFixedYet,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (red RedHat) parseCwe(str string) (cwes []string) {
 | 
			
		||||
	if str != "" {
 | 
			
		||||
		s := strings.Replace(str, "(", "|", -1)
 | 
			
		||||
		s = strings.Replace(s, ")", "|", -1)
 | 
			
		||||
		s = strings.Replace(s, "->", "|", -1)
 | 
			
		||||
		for _, s := range strings.Split(s, "|") {
 | 
			
		||||
			if s != "" {
 | 
			
		||||
				cwes = append(cwes, s)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertToModel converts gost model to vuls model
 | 
			
		||||
func (red RedHat) ConvertToModel(cve *gostmodels.RedhatCVE) *models.CveContent {
 | 
			
		||||
	cwes := red.parseCwe(cve.Cwe)
 | 
			
		||||
 | 
			
		||||
	details := []string{}
 | 
			
		||||
	for _, detail := range cve.Details {
 | 
			
		||||
		details = append(details, detail.Detail)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v2score := 0.0
 | 
			
		||||
	if cve.Cvss.CvssBaseScore != "" {
 | 
			
		||||
		v2score, _ = strconv.ParseFloat(cve.Cvss.CvssBaseScore, 64)
 | 
			
		||||
	}
 | 
			
		||||
	v2severity := ""
 | 
			
		||||
	if v2score != 0 {
 | 
			
		||||
		v2severity = cve.ThreatSeverity
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	v3score := 0.0
 | 
			
		||||
	if cve.Cvss3.Cvss3BaseScore != "" {
 | 
			
		||||
		v3score, _ = strconv.ParseFloat(cve.Cvss3.Cvss3BaseScore, 64)
 | 
			
		||||
	}
 | 
			
		||||
	v3severity := ""
 | 
			
		||||
	if v3score != 0 {
 | 
			
		||||
		v3severity = cve.ThreatSeverity
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var refs []models.Reference
 | 
			
		||||
	for _, r := range cve.References {
 | 
			
		||||
		refs = append(refs, models.Reference{Link: r.Reference})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &models.CveContent{
 | 
			
		||||
		Type:          models.RedHatAPI,
 | 
			
		||||
		CveID:         cve.Name,
 | 
			
		||||
		Title:         cve.Bugzilla.Description,
 | 
			
		||||
		Summary:       strings.Join(details, "\n"),
 | 
			
		||||
		Cvss2Score:    v2score,
 | 
			
		||||
		Cvss2Vector:   cve.Cvss.CvssScoringVector,
 | 
			
		||||
		Cvss2Severity: v2severity,
 | 
			
		||||
		Cvss3Score:    v3score,
 | 
			
		||||
		Cvss3Vector:   cve.Cvss3.Cvss3ScoringVector,
 | 
			
		||||
		Cvss3Severity: v3severity,
 | 
			
		||||
		References:    refs,
 | 
			
		||||
		CweIDs:        cwes,
 | 
			
		||||
		Mitigation:    cve.Mitigation,
 | 
			
		||||
		Published:     cve.PublicDate,
 | 
			
		||||
		SourceLink:    "https://access.redhat.com/security/cve/" + cve.Name,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										37
									
								
								gost/redhat_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								gost/redhat_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
package gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"testing"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestParseCwe(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  string
 | 
			
		||||
		out []string
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in:  "CWE-665->(CWE-200|CWE-89)",
 | 
			
		||||
			out: []string{"CWE-665", "CWE-200", "CWE-89"},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in:  "CWE-841->CWE-770->CWE-454",
 | 
			
		||||
			out: []string{"CWE-841", "CWE-770", "CWE-454"},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in:  "(CWE-122|CWE-125)",
 | 
			
		||||
			out: []string{"CWE-122", "CWE-125"},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	r := RedHat{}
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		out := r.parseCwe(tt.in)
 | 
			
		||||
		sort.Strings(out)
 | 
			
		||||
		sort.Strings(tt.out)
 | 
			
		||||
		if !reflect.DeepEqual(tt.out, out) {
 | 
			
		||||
			t.Errorf("[%d]expected: %s, actual: %s", i, tt.out, out)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										201
									
								
								gost/util.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										201
									
								
								gost/util.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,201 @@
 | 
			
		||||
/* 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 gost
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/cenkalti/backoff"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type response struct {
 | 
			
		||||
	request request
 | 
			
		||||
	json    string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getCvesViaHTTP(cveIDs []string, urlPrefix string) (
 | 
			
		||||
	responses []response, err error) {
 | 
			
		||||
	nReq := len(cveIDs)
 | 
			
		||||
	reqChan := make(chan request, nReq)
 | 
			
		||||
	resChan := make(chan response, nReq)
 | 
			
		||||
	errChan := make(chan error, nReq)
 | 
			
		||||
	defer close(reqChan)
 | 
			
		||||
	defer close(resChan)
 | 
			
		||||
	defer close(errChan)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		for _, cveID := range cveIDs {
 | 
			
		||||
			reqChan <- request{
 | 
			
		||||
				cveID: cveID,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	concurrency := 10
 | 
			
		||||
	tasks := util.GenWorkers(concurrency)
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		tasks <- func() {
 | 
			
		||||
			select {
 | 
			
		||||
			case req := <-reqChan:
 | 
			
		||||
				url, err := util.URLPathJoin(
 | 
			
		||||
					urlPrefix,
 | 
			
		||||
					req.cveID,
 | 
			
		||||
				)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					errChan <- err
 | 
			
		||||
				} else {
 | 
			
		||||
					util.Log.Debugf("HTTP Request to %s", url)
 | 
			
		||||
					httpGet(url, req, resChan, errChan)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	timeout := time.After(2 * 60 * time.Second)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		select {
 | 
			
		||||
		case res := <-resChan:
 | 
			
		||||
			responses = append(responses, res)
 | 
			
		||||
		case err := <-errChan:
 | 
			
		||||
			errs = append(errs, err)
 | 
			
		||||
		case <-timeout:
 | 
			
		||||
			return nil, fmt.Errorf("Timeout Fetching OVAL")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(errs) != 0 {
 | 
			
		||||
		return nil, fmt.Errorf("Failed to fetch OVAL. err: %v", errs)
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type request struct {
 | 
			
		||||
	osMajorVersion string
 | 
			
		||||
	packName       string
 | 
			
		||||
	isSrcPack      bool
 | 
			
		||||
	cveID          string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getAllUnfixedCvesViaHTTP(r *models.ScanResult, urlPrefix string) (
 | 
			
		||||
	responses []response, err error) {
 | 
			
		||||
 | 
			
		||||
	nReq := len(r.Packages) + len(r.SrcPackages)
 | 
			
		||||
	reqChan := make(chan request, nReq)
 | 
			
		||||
	resChan := make(chan response, nReq)
 | 
			
		||||
	errChan := make(chan error, nReq)
 | 
			
		||||
	defer close(reqChan)
 | 
			
		||||
	defer close(resChan)
 | 
			
		||||
	defer close(errChan)
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		for _, pack := range r.Packages {
 | 
			
		||||
			reqChan <- request{
 | 
			
		||||
				osMajorVersion: major(r.Release),
 | 
			
		||||
				packName:       pack.Name,
 | 
			
		||||
				isSrcPack:      false,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for _, pack := range r.SrcPackages {
 | 
			
		||||
			reqChan <- request{
 | 
			
		||||
				osMajorVersion: major(r.Release),
 | 
			
		||||
				packName:       pack.Name,
 | 
			
		||||
				isSrcPack:      true,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	concurrency := 10
 | 
			
		||||
	tasks := util.GenWorkers(concurrency)
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		tasks <- func() {
 | 
			
		||||
			select {
 | 
			
		||||
			case req := <-reqChan:
 | 
			
		||||
				url, err := util.URLPathJoin(
 | 
			
		||||
					urlPrefix,
 | 
			
		||||
					req.packName,
 | 
			
		||||
					"unfixed-cves",
 | 
			
		||||
				)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					errChan <- err
 | 
			
		||||
				} else {
 | 
			
		||||
					util.Log.Debugf("HTTP Request to %s", url)
 | 
			
		||||
					httpGet(url, req, resChan, errChan)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	timeout := time.After(2 * 60 * time.Second)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	for i := 0; i < nReq; i++ {
 | 
			
		||||
		select {
 | 
			
		||||
		case res := <-resChan:
 | 
			
		||||
			responses = append(responses, res)
 | 
			
		||||
		case err := <-errChan:
 | 
			
		||||
			errs = append(errs, err)
 | 
			
		||||
		case <-timeout:
 | 
			
		||||
			return nil, fmt.Errorf("Timeout Fetching OVAL")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(errs) != 0 {
 | 
			
		||||
		return nil, fmt.Errorf("Failed to fetch OVAL. err: %v", errs)
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func httpGet(url string, req request, resChan chan<- response, errChan chan<- error) {
 | 
			
		||||
	var body string
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	count, retryMax := 0, 3
 | 
			
		||||
	f := func() (err error) {
 | 
			
		||||
		//  resp, body, errs = gorequest.New().SetDebug(config.Conf.Debug).Get(url).End()
 | 
			
		||||
		resp, body, errs = gorequest.New().Get(url).End()
 | 
			
		||||
		if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
			count++
 | 
			
		||||
			if count == retryMax {
 | 
			
		||||
				return nil
 | 
			
		||||
			}
 | 
			
		||||
			return fmt.Errorf("HTTP GET error: %v, url: %s, resp: %v",
 | 
			
		||||
				errs, url, resp)
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	notify := func(err error, t time.Duration) {
 | 
			
		||||
		util.Log.Warnf("Failed to HTTP GET. retrying in %s seconds. err: %s", t, err)
 | 
			
		||||
	}
 | 
			
		||||
	err := backoff.RetryNotify(f, backoff.NewExponentialBackOff(), notify)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		errChan <- fmt.Errorf("HTTP Error %s", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if count == retryMax {
 | 
			
		||||
		errChan <- fmt.Errorf("HRetry count exceeded")
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resChan <- response{
 | 
			
		||||
		request: req,
 | 
			
		||||
		json:    body,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								main.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -25,15 +25,10 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/commands"
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Version of Vuls
 | 
			
		||||
var version = "0.4.2"
 | 
			
		||||
 | 
			
		||||
// Revision of Git
 | 
			
		||||
var revision string
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	subcommands.Register(subcommands.HelpCommand(), "")
 | 
			
		||||
	subcommands.Register(subcommands.FlagsCommand(), "")
 | 
			
		||||
@@ -44,13 +39,14 @@ func main() {
 | 
			
		||||
	subcommands.Register(&commands.HistoryCmd{}, "history")
 | 
			
		||||
	subcommands.Register(&commands.ReportCmd{}, "report")
 | 
			
		||||
	subcommands.Register(&commands.ConfigtestCmd{}, "configtest")
 | 
			
		||||
	subcommands.Register(&commands.ServerCmd{}, "server")
 | 
			
		||||
 | 
			
		||||
	var v = flag.Bool("v", false, "Show version")
 | 
			
		||||
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	if *v {
 | 
			
		||||
		fmt.Printf("vuls %s %s\n", version, revision)
 | 
			
		||||
		fmt.Printf("vuls %s %s\n", config.Version, config.Revision)
 | 
			
		||||
		os.Exit(int(subcommands.ExitSuccess))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -61,12 +60,12 @@ func (v CveContents) Except(exceptCtypes ...CveContentType) (values CveContents)
 | 
			
		||||
// SourceLinks returns link of source
 | 
			
		||||
func (v CveContents) SourceLinks(lang, myFamily, cveID string) (values []CveContentStr) {
 | 
			
		||||
	if lang == "ja" {
 | 
			
		||||
		if cont, found := v[JVN]; found && 0 < len(cont.SourceLink) {
 | 
			
		||||
			values = append(values, CveContentStr{JVN, cont.SourceLink})
 | 
			
		||||
		if cont, found := v[Jvn]; found && 0 < len(cont.SourceLink) {
 | 
			
		||||
			values = append(values, CveContentStr{Jvn, cont.SourceLink})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	order := CveContentTypes{NVD, NewCveContentType(myFamily)}
 | 
			
		||||
	order := CveContentTypes{Nvd, NvdXML, NewCveContentType(myFamily)}
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v[ctype]; found {
 | 
			
		||||
			values = append(values, CveContentStr{ctype, cont.SourceLink})
 | 
			
		||||
@@ -75,7 +74,7 @@ func (v CveContents) SourceLinks(lang, myFamily, cveID string) (values []CveCont
 | 
			
		||||
 | 
			
		||||
	if len(values) == 0 {
 | 
			
		||||
		return []CveContentStr{{
 | 
			
		||||
			Type:  NVD,
 | 
			
		||||
			Type:  Nvd,
 | 
			
		||||
			Value: "https://nvd.nist.gov/vuln/detail/" + cveID,
 | 
			
		||||
		}}
 | 
			
		||||
	}
 | 
			
		||||
@@ -148,11 +147,14 @@ func (v CveContents) References(myFamily string) (values []CveContentRefs) {
 | 
			
		||||
func (v CveContents) CweIDs(myFamily string) (values []CveContentStr) {
 | 
			
		||||
	order := CveContentTypes{NewCveContentType(myFamily)}
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(append(order)...)...)
 | 
			
		||||
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v[ctype]; found && 0 < len(cont.CweID) {
 | 
			
		||||
			// RedHat's OVAL sometimes contains multiple CWE-IDs separated by spaces
 | 
			
		||||
			for _, cweID := range strings.Fields(cont.CweID) {
 | 
			
		||||
		if cont, found := v[ctype]; found && 0 < len(cont.CweIDs) {
 | 
			
		||||
			for _, cweID := range cont.CweIDs {
 | 
			
		||||
				for _, val := range values {
 | 
			
		||||
					if val.Value == cweID {
 | 
			
		||||
						continue
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				values = append(values, CveContentStr{
 | 
			
		||||
					Type:  ctype,
 | 
			
		||||
					Value: cweID,
 | 
			
		||||
@@ -163,23 +165,38 @@ func (v CveContents) CweIDs(myFamily string) (values []CveContentStr) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UniqCweIDs returns Uniq CweIDs
 | 
			
		||||
func (v CveContents) UniqCweIDs(myFamily string) (values []CveContentStr) {
 | 
			
		||||
	uniq := map[string]CveContentStr{}
 | 
			
		||||
	for _, cwes := range v.CweIDs(myFamily) {
 | 
			
		||||
		uniq[cwes.Value] = cwes
 | 
			
		||||
	}
 | 
			
		||||
	for _, cwe := range uniq {
 | 
			
		||||
		values = append(values, cwe)
 | 
			
		||||
	}
 | 
			
		||||
	return values
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CveContent has abstraction of various vulnerability information
 | 
			
		||||
type CveContent struct {
 | 
			
		||||
	Type         CveContentType
 | 
			
		||||
	CveID        string
 | 
			
		||||
	Title        string
 | 
			
		||||
	Summary      string
 | 
			
		||||
	Severity     string
 | 
			
		||||
	Cvss2Score   float64
 | 
			
		||||
	Cvss2Vector  string
 | 
			
		||||
	Cvss3Score   float64
 | 
			
		||||
	Cvss3Vector  string
 | 
			
		||||
	SourceLink   string
 | 
			
		||||
	Cpes         []Cpe
 | 
			
		||||
	References   References
 | 
			
		||||
	CweID        string
 | 
			
		||||
	Published    time.Time
 | 
			
		||||
	LastModified time.Time
 | 
			
		||||
	Type          CveContentType    `json:"type"`
 | 
			
		||||
	CveID         string            `json:"cveID"`
 | 
			
		||||
	Title         string            `json:"title"`
 | 
			
		||||
	Summary       string            `json:"summary"`
 | 
			
		||||
	Cvss2Score    float64           `json:"cvss2Score"`
 | 
			
		||||
	Cvss2Vector   string            `json:"cvss2Vector"`
 | 
			
		||||
	Cvss2Severity string            `json:"cvss2Severity"`
 | 
			
		||||
	Cvss3Score    float64           `json:"cvss3Score"`
 | 
			
		||||
	Cvss3Vector   string            `json:"cvss3Vector"`
 | 
			
		||||
	Cvss3Severity string            `json:"cvss3Severity"`
 | 
			
		||||
	SourceLink    string            `json:"sourceLink"`
 | 
			
		||||
	Cpes          []Cpe             `json:"cpes,omitempty"`
 | 
			
		||||
	References    References        `json:"references,omitempty"`
 | 
			
		||||
	CweIDs        []string          `json:"cweIDs,omitempty"`
 | 
			
		||||
	Published     time.Time         `json:"published"`
 | 
			
		||||
	LastModified  time.Time         `json:"lastModified"`
 | 
			
		||||
	Mitigation    string            `json:"mitigation"` // RedHat API
 | 
			
		||||
	Optional      map[string]string `json:"optional,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Empty checks the content is empty
 | 
			
		||||
@@ -193,10 +210,12 @@ type CveContentType string
 | 
			
		||||
// NewCveContentType create CveContentType
 | 
			
		||||
func NewCveContentType(name string) CveContentType {
 | 
			
		||||
	switch name {
 | 
			
		||||
	case "nvdxml":
 | 
			
		||||
		return NvdXML
 | 
			
		||||
	case "nvd":
 | 
			
		||||
		return NVD
 | 
			
		||||
		return Nvd
 | 
			
		||||
	case "jvn":
 | 
			
		||||
		return JVN
 | 
			
		||||
		return Jvn
 | 
			
		||||
	case "redhat", "centos":
 | 
			
		||||
		return RedHat
 | 
			
		||||
	case "oracle":
 | 
			
		||||
@@ -205,21 +224,36 @@ func NewCveContentType(name string) CveContentType {
 | 
			
		||||
		return Ubuntu
 | 
			
		||||
	case "debian":
 | 
			
		||||
		return Debian
 | 
			
		||||
	case "redhat_api":
 | 
			
		||||
		return RedHatAPI
 | 
			
		||||
	case "debian_security_tracker":
 | 
			
		||||
		return DebianSecurityTracker
 | 
			
		||||
	case "microsoft":
 | 
			
		||||
		return Microsoft
 | 
			
		||||
	default:
 | 
			
		||||
		return Unknown
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// NVD is NVD
 | 
			
		||||
	NVD CveContentType = "nvd"
 | 
			
		||||
	// NvdXML is NvdXML
 | 
			
		||||
	NvdXML CveContentType = "nvdxml"
 | 
			
		||||
 | 
			
		||||
	// JVN is JVN
 | 
			
		||||
	JVN CveContentType = "jvn"
 | 
			
		||||
	// Nvd is Nvd
 | 
			
		||||
	Nvd CveContentType = "nvd"
 | 
			
		||||
 | 
			
		||||
	// Jvn is Jvn
 | 
			
		||||
	Jvn CveContentType = "jvn"
 | 
			
		||||
 | 
			
		||||
	// RedHat is RedHat
 | 
			
		||||
	RedHat CveContentType = "redhat"
 | 
			
		||||
 | 
			
		||||
	// RedHatAPI is RedHat
 | 
			
		||||
	RedHatAPI CveContentType = "redhat_api"
 | 
			
		||||
 | 
			
		||||
	// DebianSecurityTracker is Debian Secury tracker
 | 
			
		||||
	DebianSecurityTracker CveContentType = "debian_security_tracker"
 | 
			
		||||
 | 
			
		||||
	// Debian is Debian
 | 
			
		||||
	Debian CveContentType = "debian"
 | 
			
		||||
 | 
			
		||||
@@ -232,6 +266,9 @@ const (
 | 
			
		||||
	// SUSE is SUSE Linux
 | 
			
		||||
	SUSE CveContentType = "suse"
 | 
			
		||||
 | 
			
		||||
	// Microsoft is Microsoft
 | 
			
		||||
	Microsoft CveContentType = "microsoft"
 | 
			
		||||
 | 
			
		||||
	// Unknown is Unknown
 | 
			
		||||
	Unknown CveContentType = "unknown"
 | 
			
		||||
)
 | 
			
		||||
@@ -240,7 +277,16 @@ const (
 | 
			
		||||
type CveContentTypes []CveContentType
 | 
			
		||||
 | 
			
		||||
// AllCveContetTypes has all of CveContentTypes
 | 
			
		||||
var AllCveContetTypes = CveContentTypes{NVD, JVN, RedHat, Debian, Ubuntu}
 | 
			
		||||
var AllCveContetTypes = CveContentTypes{
 | 
			
		||||
	Nvd,
 | 
			
		||||
	NvdXML,
 | 
			
		||||
	Jvn,
 | 
			
		||||
	RedHat,
 | 
			
		||||
	Debian,
 | 
			
		||||
	Ubuntu,
 | 
			
		||||
	RedHatAPI,
 | 
			
		||||
	DebianSecurityTracker,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Except returns CveContentTypes except for given args
 | 
			
		||||
func (c CveContentTypes) Except(excepts ...CveContentType) (excepted CveContentTypes) {
 | 
			
		||||
@@ -261,7 +307,8 @@ func (c CveContentTypes) Except(excepts ...CveContentType) (excepted CveContentT
 | 
			
		||||
 | 
			
		||||
// Cpe is Common Platform Enumeration
 | 
			
		||||
type Cpe struct {
 | 
			
		||||
	CpeName string
 | 
			
		||||
	URI             string `json:"uri"`
 | 
			
		||||
	FormattedString string `json:"formattedString"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// References is a slice of Reference
 | 
			
		||||
@@ -269,7 +316,7 @@ type References []Reference
 | 
			
		||||
 | 
			
		||||
// Reference has a related link of the CVE
 | 
			
		||||
type Reference struct {
 | 
			
		||||
	Source string
 | 
			
		||||
	Link   string
 | 
			
		||||
	RefID  string
 | 
			
		||||
	Source string `json:"source"`
 | 
			
		||||
	Link   string `json:"link"`
 | 
			
		||||
	RefID  string `json:"refID"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -60,27 +60,27 @@ func TestSourceLinks(t *testing.T) {
 | 
			
		||||
				lang:  "ja",
 | 
			
		||||
				cveID: "CVE-2017-6074",
 | 
			
		||||
				cont: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:       JVN,
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:       Jvn,
 | 
			
		||||
						SourceLink: "https://jvn.jp/vu/JVNVU93610402/",
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:       RedHat,
 | 
			
		||||
						SourceLink: "https://access.redhat.com/security/cve/CVE-2017-6074",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:       NvdXML,
 | 
			
		||||
						SourceLink: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  JVN,
 | 
			
		||||
					Type:  Jvn,
 | 
			
		||||
					Value: "https://jvn.jp/vu/JVNVU93610402/",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -95,23 +95,23 @@ func TestSourceLinks(t *testing.T) {
 | 
			
		||||
				lang:  "en",
 | 
			
		||||
				cveID: "CVE-2017-6074",
 | 
			
		||||
				cont: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:       JVN,
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:       Jvn,
 | 
			
		||||
						SourceLink: "https://jvn.jp/vu/JVNVU93610402/",
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:       RedHat,
 | 
			
		||||
						SourceLink: "https://access.redhat.com/security/cve/CVE-2017-6074",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:       NvdXML,
 | 
			
		||||
						SourceLink: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -129,16 +129,16 @@ func TestSourceLinks(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  Nvd,
 | 
			
		||||
					Value: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		actual := tt.in.cont.SourceLinks(tt.in.lang, "redhat", tt.in.cveID)
 | 
			
		||||
		if !reflect.DeepEqual(tt.out, actual) {
 | 
			
		||||
			t.Errorf("\nexpected: %v\n  actual: %v\n", tt.out, actual)
 | 
			
		||||
			t.Errorf("\n[%d] expected: %v\n  actual: %v\n", i, tt.out, actual)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -158,16 +158,16 @@ func TestVendorLink(t *testing.T) {
 | 
			
		||||
				vinfo: VulnInfo{
 | 
			
		||||
					CveID: "CVE-2017-6074",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						JVN: {
 | 
			
		||||
							Type:       JVN,
 | 
			
		||||
						Jvn: {
 | 
			
		||||
							Type:       Jvn,
 | 
			
		||||
							SourceLink: "https://jvn.jp/vu/JVNVU93610402/",
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
							Type:       RedHat,
 | 
			
		||||
							SourceLink: "https://access.redhat.com/security/cve/CVE-2017-6074",
 | 
			
		||||
						},
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							SourceLink: "https://nvd.nist.gov/vuln/detail/CVE-2017-6074",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -18,4 +18,4 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
// JSONVersion is JSON Version
 | 
			
		||||
const JSONVersion = 3
 | 
			
		||||
const JSONVersion = 4
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -38,6 +38,12 @@ func NewPackages(packs ...Package) Packages {
 | 
			
		||||
 | 
			
		||||
// MergeNewVersion merges candidate version information to the receiver struct
 | 
			
		||||
func (ps Packages) MergeNewVersion(as Packages) {
 | 
			
		||||
	for name, pack := range ps {
 | 
			
		||||
		pack.NewVersion = pack.Version
 | 
			
		||||
		pack.NewRelease = pack.Release
 | 
			
		||||
		ps[name] = pack
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, a := range as {
 | 
			
		||||
		if pack, ok := ps[a.Name]; ok {
 | 
			
		||||
			pack.NewVersion = a.NewVersion
 | 
			
		||||
@@ -60,18 +66,7 @@ func (ps Packages) Merge(other Packages) Packages {
 | 
			
		||||
	return merged
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatUpdatablePacksSummary returns a summary of updatable packages
 | 
			
		||||
func (ps Packages) FormatUpdatablePacksSummary() string {
 | 
			
		||||
	nUpdatable := 0
 | 
			
		||||
	for _, p := range ps {
 | 
			
		||||
		if p.NewVersion != "" {
 | 
			
		||||
			nUpdatable++
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%d updatable packages", nUpdatable)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindOne search a element by name-newver-newrel-arch
 | 
			
		||||
// FindOne search a element
 | 
			
		||||
func (ps Packages) FindOne(f func(Package) bool) (string, Package, bool) {
 | 
			
		||||
	for key, p := range ps {
 | 
			
		||||
		if f(p) {
 | 
			
		||||
@@ -81,16 +76,44 @@ func (ps Packages) FindOne(f func(Package) bool) (string, Package, bool) {
 | 
			
		||||
	return "", Package{}, false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindByFQPN search a package by Fully-Qualified-Package-Name
 | 
			
		||||
func (ps Packages) FindByFQPN(nameVerRelArc string) (*Package, error) {
 | 
			
		||||
	for _, p := range ps {
 | 
			
		||||
		if nameVerRelArc == p.FQPN() {
 | 
			
		||||
			return &p, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, fmt.Errorf("Failed to find the package: %s", nameVerRelArc)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Package has installed binary packages.
 | 
			
		||||
type Package struct {
 | 
			
		||||
	Name       string
 | 
			
		||||
	Version    string
 | 
			
		||||
	Release    string
 | 
			
		||||
	NewVersion string
 | 
			
		||||
	NewRelease string
 | 
			
		||||
	Arch       string
 | 
			
		||||
	Repository string
 | 
			
		||||
	Changelog  Changelog
 | 
			
		||||
	Name             string               `json:"name"`
 | 
			
		||||
	Version          string               `json:"version"`
 | 
			
		||||
	Release          string               `json:"release"`
 | 
			
		||||
	NewVersion       string               `json:"newVersion"`
 | 
			
		||||
	NewRelease       string               `json:"newRelease"`
 | 
			
		||||
	Arch             string               `json:"arch"`
 | 
			
		||||
	Repository       string               `json:"repository"`
 | 
			
		||||
	Changelog        Changelog            `json:"changelog"`
 | 
			
		||||
	AffectedProcs    []AffectedProcess    `json:",omitempty"`
 | 
			
		||||
	NeedRestartProcs []NeedRestartProcess `json:",omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FQPN returns Fully-Qualified-Package-Name
 | 
			
		||||
// name-version-release.arch
 | 
			
		||||
func (p Package) FQPN() string {
 | 
			
		||||
	fqpn := p.Name
 | 
			
		||||
	if p.Version != "" {
 | 
			
		||||
		fqpn += fmt.Sprintf("-%s", p.Version)
 | 
			
		||||
	}
 | 
			
		||||
	if p.Release != "" {
 | 
			
		||||
		fqpn += fmt.Sprintf("-%s", p.Release)
 | 
			
		||||
	}
 | 
			
		||||
	if p.Arch != "" {
 | 
			
		||||
		fqpn += fmt.Sprintf(".%s", p.Arch)
 | 
			
		||||
	}
 | 
			
		||||
	return fqpn
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatVer returns package version-release
 | 
			
		||||
@@ -112,10 +135,14 @@ func (p Package) FormatNewVer() string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatVersionFromTo formats installed and new package version
 | 
			
		||||
func (p Package) FormatVersionFromTo(notFixedYet bool) string {
 | 
			
		||||
func (p Package) FormatVersionFromTo(notFixedYet bool, status string) string {
 | 
			
		||||
	to := p.FormatNewVer()
 | 
			
		||||
	if notFixedYet {
 | 
			
		||||
		to = "Not Fixed Yet"
 | 
			
		||||
		if status != "" {
 | 
			
		||||
			to = status
 | 
			
		||||
		} else {
 | 
			
		||||
			to = "Not Fixed Yet"
 | 
			
		||||
		}
 | 
			
		||||
	} else if p.NewVersion == "" {
 | 
			
		||||
		to = "Unknown"
 | 
			
		||||
	}
 | 
			
		||||
@@ -141,7 +168,7 @@ func (p Package) FormatChangelog() string {
 | 
			
		||||
	case FailedToGetChangelog:
 | 
			
		||||
		clog = "No changelogs"
 | 
			
		||||
	case FailedToFindVersionInChangelog:
 | 
			
		||||
		clog = "Failed to parse changelogs. For detials, check yourself"
 | 
			
		||||
		clog = "Failed to parse changelogs. For details, check yourself"
 | 
			
		||||
	}
 | 
			
		||||
	buf = append(buf, packVer, delim.String(), clog)
 | 
			
		||||
	return strings.Join(buf, "\n")
 | 
			
		||||
@@ -150,8 +177,23 @@ func (p Package) FormatChangelog() string {
 | 
			
		||||
// Changelog has contents of changelog and how to get it.
 | 
			
		||||
// Method: models.detectionMethodStr
 | 
			
		||||
type Changelog struct {
 | 
			
		||||
	Contents string
 | 
			
		||||
	Method   DetectionMethod
 | 
			
		||||
	Contents string          `json:"contents"`
 | 
			
		||||
	Method   DetectionMethod `json:"method"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AffectedProcess keep a processes information affected by software update
 | 
			
		||||
type AffectedProcess struct {
 | 
			
		||||
	PID  string `json:"pid"`
 | 
			
		||||
	Name string `json:"name"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NeedRestartProcess keep a processes information affected by software update
 | 
			
		||||
type NeedRestartProcess struct {
 | 
			
		||||
	PID         string `json:"pid"`
 | 
			
		||||
	Path        string `json:"path"`
 | 
			
		||||
	ServiceName string `json:"serviceName"`
 | 
			
		||||
	InitSystem  string `json:"initSystem"`
 | 
			
		||||
	HasInit     bool   `json:"-"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SrcPackage has installed source package information.
 | 
			
		||||
@@ -160,9 +202,9 @@ type Changelog struct {
 | 
			
		||||
// so it is also needed to capture source version for OVAL version comparison.
 | 
			
		||||
// https://github.com/future-architect/vuls/issues/504
 | 
			
		||||
type SrcPackage struct {
 | 
			
		||||
	Name        string
 | 
			
		||||
	Version     string
 | 
			
		||||
	BinaryNames []string
 | 
			
		||||
	Name        string   `json:"name"`
 | 
			
		||||
	Version     string   `json:"version"`
 | 
			
		||||
	BinaryNames []string `json:"binaryNames"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddBinaryName add the name if not exists
 | 
			
		||||
@@ -181,3 +223,15 @@ func (s *SrcPackage) AddBinaryName(name string) {
 | 
			
		||||
// SrcPackages is Map of SrcPackage
 | 
			
		||||
// { "package-name": SrcPackage }
 | 
			
		||||
type SrcPackages map[string]SrcPackage
 | 
			
		||||
 | 
			
		||||
// FindByBinName finds by bin-package-name
 | 
			
		||||
func (s SrcPackages) FindByBinName(name string) (*SrcPackage, bool) {
 | 
			
		||||
	for _, p := range s {
 | 
			
		||||
		for _, binName := range p.BinaryNames {
 | 
			
		||||
			if binName == name {
 | 
			
		||||
				return &p, true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil, false
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -133,3 +133,61 @@ func TestAddBinaryName(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFindByBinName(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in       SrcPackages
 | 
			
		||||
		name     string
 | 
			
		||||
		expected *SrcPackage
 | 
			
		||||
		ok       bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: map[string]SrcPackage{
 | 
			
		||||
				"packA": {
 | 
			
		||||
					Name:        "srcA",
 | 
			
		||||
					BinaryNames: []string{"binA"},
 | 
			
		||||
					Version:     "1.0.0",
 | 
			
		||||
				},
 | 
			
		||||
				"packB": {
 | 
			
		||||
					Name:        "srcB",
 | 
			
		||||
					BinaryNames: []string{"binB"},
 | 
			
		||||
					Version:     "2.0.0",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			name: "binA",
 | 
			
		||||
			expected: &SrcPackage{
 | 
			
		||||
				Name:        "srcA",
 | 
			
		||||
				BinaryNames: []string{"binA"},
 | 
			
		||||
				Version:     "1.0.0",
 | 
			
		||||
			},
 | 
			
		||||
			ok: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: map[string]SrcPackage{
 | 
			
		||||
				"packA": {
 | 
			
		||||
					Name:        "srcA",
 | 
			
		||||
					BinaryNames: []string{"binA"},
 | 
			
		||||
					Version:     "1.0.0",
 | 
			
		||||
				},
 | 
			
		||||
				"packB": {
 | 
			
		||||
					Name:        "srcB",
 | 
			
		||||
					BinaryNames: []string{"binB"},
 | 
			
		||||
					Version:     "2.0.0",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			name:     "nobin",
 | 
			
		||||
			expected: nil,
 | 
			
		||||
			ok:       false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		act, ok := tt.in.FindByBinName(tt.name)
 | 
			
		||||
		if ok != tt.ok {
 | 
			
		||||
			t.Errorf("[%d] expected %#v, actual %#v", i, tt.in, tt.expected)
 | 
			
		||||
		}
 | 
			
		||||
		if act != nil && !reflect.DeepEqual(*tt.expected, *act) {
 | 
			
		||||
			t.Errorf("[%d] expected %#v, actual %#v", i, tt.in, tt.expected)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -20,9 +20,15 @@ package models
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/alert"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/cwe"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ScanResults is a slide of ScanResult
 | 
			
		||||
@@ -30,38 +36,92 @@ type ScanResults []ScanResult
 | 
			
		||||
 | 
			
		||||
// ScanResult has the result of scanned CVE information.
 | 
			
		||||
type ScanResult struct {
 | 
			
		||||
	ScannedAt   time.Time
 | 
			
		||||
	ReportedAt  time.Time
 | 
			
		||||
	JSONVersion int
 | 
			
		||||
	Lang        string
 | 
			
		||||
	ServerUUID  string
 | 
			
		||||
	ServerName  string // TOML Section key
 | 
			
		||||
	Family      string
 | 
			
		||||
	Release     string
 | 
			
		||||
	Container   Container
 | 
			
		||||
	Platform    Platform
 | 
			
		||||
	JSONVersion      int                    `json:"jsonVersion"`
 | 
			
		||||
	Lang             string                 `json:"lang"`
 | 
			
		||||
	ServerUUID       string                 `json:"serverUUID"`
 | 
			
		||||
	ServerName       string                 `json:"serverName"` // TOML Section key
 | 
			
		||||
	Family           string                 `json:"family"`
 | 
			
		||||
	Release          string                 `json:"release"`
 | 
			
		||||
	Container        Container              `json:"container"`
 | 
			
		||||
	Platform         Platform               `json:"platform"`
 | 
			
		||||
	IPv4Addrs        []string               `json:"ipv4Addrs,omitempty"` // only global unicast address (https://golang.org/pkg/net/#IP.IsGlobalUnicast)
 | 
			
		||||
	IPv6Addrs        []string               `json:"ipv6Addrs,omitempty"` // only global unicast address (https://golang.org/pkg/net/#IP.IsGlobalUnicast)
 | 
			
		||||
	ScannedAt        time.Time              `json:"scannedAt"`
 | 
			
		||||
	ScanMode         string                 `json:"scanMode"`
 | 
			
		||||
	ScannedVersion   string                 `json:"scannedVersion"`
 | 
			
		||||
	ScannedRevision  string                 `json:"scannedRevision"`
 | 
			
		||||
	ScannedBy        string                 `json:"scannedBy"`
 | 
			
		||||
	ScannedIPv4Addrs []string               `json:"scannedIpv4Addrs"`
 | 
			
		||||
	ScannedIPv6Addrs []string               `json:"scannedIpv6Addrs"`
 | 
			
		||||
	ReportedAt       time.Time              `json:"reportedAt"`
 | 
			
		||||
	ReportedVersion  string                 `json:"reportedVersion"`
 | 
			
		||||
	ReportedRevision string                 `json:"reportedRevision"`
 | 
			
		||||
	ReportedBy       string                 `json:"reportedBy"`
 | 
			
		||||
	ScannedCves      VulnInfos              `json:"scannedCves"`
 | 
			
		||||
	RunningKernel    Kernel                 `json:"runningKernel"`
 | 
			
		||||
	Packages         Packages               `json:"packages"`
 | 
			
		||||
	CweDict          CweDict                `json:"cweDict"`
 | 
			
		||||
	Optional         map[string]interface{} `json:",omitempty"`
 | 
			
		||||
	SrcPackages      SrcPackages            `json:",omitempty"`
 | 
			
		||||
	Errors           []string               `json:"errors"`
 | 
			
		||||
	Config           struct {
 | 
			
		||||
		Scan   config.Config `json:"scan"`
 | 
			
		||||
		Report config.Config `json:"report"`
 | 
			
		||||
	} `json:"config"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	// Scanned Vulns by SSH scan + CPE + OVAL
 | 
			
		||||
	ScannedCves VulnInfos
 | 
			
		||||
// CweDict is a dictionary for CWE
 | 
			
		||||
type CweDict map[string]CweDictEntry
 | 
			
		||||
 | 
			
		||||
	RunningKernel Kernel
 | 
			
		||||
	Packages      Packages
 | 
			
		||||
	SrcPackages   SrcPackages
 | 
			
		||||
 | 
			
		||||
	Errors   []string
 | 
			
		||||
	Optional [][]interface{}
 | 
			
		||||
 | 
			
		||||
	Config struct {
 | 
			
		||||
		Scan   config.Config
 | 
			
		||||
		Report config.Config
 | 
			
		||||
// Get the name, url, top10URL for the specified cweID, lang
 | 
			
		||||
func (c CweDict) Get(cweID, lang string) (name, url, top10Rank, top10URL string) {
 | 
			
		||||
	cweNum := strings.TrimPrefix(cweID, "CWE-")
 | 
			
		||||
	switch config.Conf.Lang {
 | 
			
		||||
	case "ja":
 | 
			
		||||
		if dict, ok := c[cweNum]; ok && dict.OwaspTopTen2017 != "" {
 | 
			
		||||
			top10Rank = dict.OwaspTopTen2017
 | 
			
		||||
			top10URL = cwe.OwaspTopTen2017GitHubURLJa[dict.OwaspTopTen2017]
 | 
			
		||||
		}
 | 
			
		||||
		if dict, ok := cwe.CweDictJa[cweNum]; ok {
 | 
			
		||||
			name = dict.Name
 | 
			
		||||
			url = fmt.Sprintf("http://jvndb.jvn.jp/ja/cwe/%s.html", cweID)
 | 
			
		||||
		} else {
 | 
			
		||||
			if dict, ok := cwe.CweDictEn[cweNum]; ok {
 | 
			
		||||
				name = dict.Name
 | 
			
		||||
			}
 | 
			
		||||
			url = fmt.Sprintf("https://cwe.mitre.org/data/definitions/%s.html", cweID)
 | 
			
		||||
		}
 | 
			
		||||
	default:
 | 
			
		||||
		if dict, ok := c[cweNum]; ok && dict.OwaspTopTen2017 != "" {
 | 
			
		||||
			top10Rank = dict.OwaspTopTen2017
 | 
			
		||||
			top10URL = cwe.OwaspTopTen2017GitHubURLEn[dict.OwaspTopTen2017]
 | 
			
		||||
		}
 | 
			
		||||
		url = fmt.Sprintf("https://cwe.mitre.org/data/definitions/%s.html", cweID)
 | 
			
		||||
		if dict, ok := cwe.CweDictEn[cweNum]; ok {
 | 
			
		||||
			name = dict.Name
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CweDictEntry is a entry of CWE
 | 
			
		||||
type CweDictEntry struct {
 | 
			
		||||
	En              *cwe.Cwe `json:"en,omitempty"`
 | 
			
		||||
	Ja              *cwe.Cwe `json:"ja,omitempty"`
 | 
			
		||||
	OwaspTopTen2017 string   `json:"owaspTopTen2017"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetAlertsByCveID return alerts fetched by cveID
 | 
			
		||||
func GetAlertsByCveID(cveID string, lang string) (alerts []alert.Alert) {
 | 
			
		||||
	alerts = alert.GenerateAlertDict(cveID, lang)
 | 
			
		||||
	return alerts
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Kernel has the Release, version and whether need restart
 | 
			
		||||
type Kernel struct {
 | 
			
		||||
	Release        string
 | 
			
		||||
	Version        string
 | 
			
		||||
	RebootRequired bool
 | 
			
		||||
	Release        string `json:"release"`
 | 
			
		||||
	Version        string `json:"version"`
 | 
			
		||||
	RebootRequired bool   `json:"rebootRequired"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FilterByCvssOver is filter function.
 | 
			
		||||
@@ -83,9 +143,29 @@ func (r ScanResult) FilterByCvssOver(over float64) ScanResult {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FilterIgnoreCves is filter function.
 | 
			
		||||
func (r ScanResult) FilterIgnoreCves(cveIDs []string) ScanResult {
 | 
			
		||||
func (r ScanResult) FilterIgnoreCves() ScanResult {
 | 
			
		||||
 | 
			
		||||
	ignoreCves := []string{}
 | 
			
		||||
	if len(r.Container.Name) == 0 {
 | 
			
		||||
		ignoreCves = config.Conf.Servers[r.ServerName].IgnoreCves
 | 
			
		||||
	} else {
 | 
			
		||||
		if s, ok := config.Conf.Servers[r.ServerName]; ok {
 | 
			
		||||
			if con, ok := s.Containers[r.Container.Name]; ok {
 | 
			
		||||
				ignoreCves = con.IgnoreCves
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Errorf("%s is not found in config.toml",
 | 
			
		||||
					r.Container.Name)
 | 
			
		||||
				return r
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Errorf("%s is not found in config.toml",
 | 
			
		||||
				r.ServerName)
 | 
			
		||||
			return r
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	filtered := r.ScannedCves.Find(func(v VulnInfo) bool {
 | 
			
		||||
		for _, c := range cveIDs {
 | 
			
		||||
		for _, c := range ignoreCves {
 | 
			
		||||
			if v.CveID == c {
 | 
			
		||||
				return false
 | 
			
		||||
			}
 | 
			
		||||
@@ -102,6 +182,9 @@ func (r ScanResult) FilterUnfixed() ScanResult {
 | 
			
		||||
		return r
 | 
			
		||||
	}
 | 
			
		||||
	filtered := r.ScannedCves.Find(func(v VulnInfo) bool {
 | 
			
		||||
		if len(v.CpeURIs) != 0 {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
		NotFixedAll := true
 | 
			
		||||
		for _, p := range v.AffectedPackages {
 | 
			
		||||
			NotFixedAll = NotFixedAll && p.NotFixedYet
 | 
			
		||||
@@ -112,6 +195,63 @@ func (r ScanResult) FilterUnfixed() ScanResult {
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FilterIgnorePkgs is filter function.
 | 
			
		||||
func (r ScanResult) FilterIgnorePkgs() ScanResult {
 | 
			
		||||
	ignorePkgsRegexps := []string{}
 | 
			
		||||
	if len(r.Container.Name) == 0 {
 | 
			
		||||
		ignorePkgsRegexps = config.Conf.Servers[r.ServerName].IgnorePkgsRegexp
 | 
			
		||||
	} else {
 | 
			
		||||
		if s, ok := config.Conf.Servers[r.ServerName]; ok {
 | 
			
		||||
			if con, ok := s.Containers[r.Container.Name]; ok {
 | 
			
		||||
				ignorePkgsRegexps = con.IgnorePkgsRegexp
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Errorf("%s is not found in config.toml",
 | 
			
		||||
					r.Container.Name)
 | 
			
		||||
				return r
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Errorf("%s is not found in config.toml",
 | 
			
		||||
				r.ServerName)
 | 
			
		||||
			return r
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	regexps := []*regexp.Regexp{}
 | 
			
		||||
	for _, pkgRegexp := range ignorePkgsRegexps {
 | 
			
		||||
		re, err := regexp.Compile(pkgRegexp)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			util.Log.Errorf("Faild to parse %s, %s", pkgRegexp, err)
 | 
			
		||||
			continue
 | 
			
		||||
		} else {
 | 
			
		||||
			regexps = append(regexps, re)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(regexps) == 0 {
 | 
			
		||||
		return r
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	filtered := r.ScannedCves.Find(func(v VulnInfo) bool {
 | 
			
		||||
		if len(v.AffectedPackages) == 0 {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
		for _, p := range v.AffectedPackages {
 | 
			
		||||
			match := false
 | 
			
		||||
			for _, re := range regexps {
 | 
			
		||||
				if re.MatchString(p.Name) {
 | 
			
		||||
					match = true
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if !match {
 | 
			
		||||
				return true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return false
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	r.ScannedCves = filtered
 | 
			
		||||
	return r
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ReportFileName returns the filename on localhost without extention
 | 
			
		||||
func (r ScanResult) ReportFileName() (name string) {
 | 
			
		||||
	if len(r.Container.ContainerID) == 0 {
 | 
			
		||||
@@ -144,7 +284,7 @@ func (r ScanResult) ServerInfo() string {
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ServerInfoTui returns server infromation for TUI sidebar
 | 
			
		||||
// ServerInfoTui returns server information for TUI sidebar
 | 
			
		||||
func (r ScanResult) ServerInfoTui() string {
 | 
			
		||||
	if len(r.Container.ContainerID) == 0 {
 | 
			
		||||
		line := fmt.Sprintf("%s (%s%s)",
 | 
			
		||||
@@ -178,29 +318,122 @@ func (r ScanResult) FormatServerName() (name string) {
 | 
			
		||||
 | 
			
		||||
// FormatTextReportHeadedr returns header of text report
 | 
			
		||||
func (r ScanResult) FormatTextReportHeadedr() string {
 | 
			
		||||
	serverInfo := r.ServerInfo()
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	for i := 0; i < len(serverInfo); i++ {
 | 
			
		||||
	for i := 0; i < len(r.ServerInfo()); i++ {
 | 
			
		||||
		buf.WriteString("=")
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%s\n%s\n%s\t%s\n",
 | 
			
		||||
 | 
			
		||||
	return fmt.Sprintf("%s\n%s\n%s, %s, %s, %s, %s\n",
 | 
			
		||||
		r.ServerInfo(),
 | 
			
		||||
		buf.String(),
 | 
			
		||||
		r.ScannedCves.FormatCveSummary(),
 | 
			
		||||
		r.Packages.FormatUpdatablePacksSummary(),
 | 
			
		||||
		r.ScannedCves.FormatFixedStatus(r.Packages),
 | 
			
		||||
		r.FormatUpdatablePacksSummary(),
 | 
			
		||||
		r.FormatExploitCveSummary(),
 | 
			
		||||
		r.FormatAlertSummary(),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatUpdatablePacksSummary returns a summary of updatable packages
 | 
			
		||||
func (r ScanResult) FormatUpdatablePacksSummary() string {
 | 
			
		||||
	if !r.isDisplayUpdatableNum() {
 | 
			
		||||
		return fmt.Sprintf("%d installed", len(r.Packages))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nUpdatable := 0
 | 
			
		||||
	for _, p := range r.Packages {
 | 
			
		||||
		if p.NewVersion == "" {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		if p.Version != p.NewVersion || p.Release != p.NewRelease {
 | 
			
		||||
			nUpdatable++
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%d installed, %d updatable",
 | 
			
		||||
		len(r.Packages),
 | 
			
		||||
		nUpdatable)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatExploitCveSummary returns a summary of exploit cve
 | 
			
		||||
func (r ScanResult) FormatExploitCveSummary() string {
 | 
			
		||||
	nExploitCve := 0
 | 
			
		||||
	for _, vuln := range r.ScannedCves {
 | 
			
		||||
		if 0 < len(vuln.Exploits) {
 | 
			
		||||
			nExploitCve++
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%d exploits", nExploitCve)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatAlertSummary returns a summary of XCERT alerts
 | 
			
		||||
func (r ScanResult) FormatAlertSummary() string {
 | 
			
		||||
	jaCnt := 0
 | 
			
		||||
	enCnt := 0
 | 
			
		||||
	for _, vuln := range r.ScannedCves {
 | 
			
		||||
		if len(vuln.AlertDict.En) > 0 {
 | 
			
		||||
			enCnt += len(vuln.AlertDict.En)
 | 
			
		||||
		}
 | 
			
		||||
		if len(vuln.AlertDict.Ja) > 0 {
 | 
			
		||||
			jaCnt += len(vuln.AlertDict.Ja)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("en: %d, ja: %d alerts", enCnt, jaCnt)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r ScanResult) isDisplayUpdatableNum() bool {
 | 
			
		||||
	var mode config.ScanMode
 | 
			
		||||
	s, _ := config.Conf.Servers[r.ServerName]
 | 
			
		||||
	mode = s.Mode
 | 
			
		||||
 | 
			
		||||
	if mode.IsOffline() {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if mode.IsFastRoot() || mode.IsDeep() {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if mode.IsFast() {
 | 
			
		||||
		switch r.Family {
 | 
			
		||||
		case config.RedHat,
 | 
			
		||||
			config.Oracle,
 | 
			
		||||
			config.Debian,
 | 
			
		||||
			config.Ubuntu,
 | 
			
		||||
			config.Raspbian:
 | 
			
		||||
			return false
 | 
			
		||||
		default:
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsContainer returns whether this ServerInfo is about container
 | 
			
		||||
func (r ScanResult) IsContainer() bool {
 | 
			
		||||
	return 0 < len(r.Container.ContainerID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsDeepScanMode checks if the scan mode is deep scan mode.
 | 
			
		||||
func (r ScanResult) IsDeepScanMode() bool {
 | 
			
		||||
	for _, s := range r.Config.Scan.Servers {
 | 
			
		||||
		for _, m := range s.ScanMode {
 | 
			
		||||
			if m == "deep" {
 | 
			
		||||
				return true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Container has Container information
 | 
			
		||||
type Container struct {
 | 
			
		||||
	ContainerID string
 | 
			
		||||
	Name        string
 | 
			
		||||
	Image       string
 | 
			
		||||
	Type        string
 | 
			
		||||
	ContainerID string `json:"containerID"`
 | 
			
		||||
	Name        string `json:"name"`
 | 
			
		||||
	Image       string `json:"image"`
 | 
			
		||||
	Type        string `json:"type"`
 | 
			
		||||
	UUID        string `json:"uuid"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Platform has platform information
 | 
			
		||||
type Platform struct {
 | 
			
		||||
	Name       string // aws or azure or gcp or other...
 | 
			
		||||
	InstanceID string
 | 
			
		||||
	Name       string `json:"name"` // aws or azure or gcp or other...
 | 
			
		||||
	InstanceID string `json:"instanceID"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -43,7 +43,7 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         NVD,
 | 
			
		||||
									Type:         NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0001",
 | 
			
		||||
									Cvss2Score:   7.1,
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
@@ -54,7 +54,7 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         NVD,
 | 
			
		||||
									Type:         NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									Cvss2Score:   6.9,
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
@@ -65,13 +65,13 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0003",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         NVD,
 | 
			
		||||
									Type:         NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0003",
 | 
			
		||||
									Cvss2Score:   6.9,
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         JVN,
 | 
			
		||||
									Type:         Jvn,
 | 
			
		||||
									CveID:        "CVE-2017-0003",
 | 
			
		||||
									Cvss2Score:   7.2,
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
@@ -87,7 +87,7 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
						CveContents: NewCveContents(
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         NVD,
 | 
			
		||||
								Type:         NvdXML,
 | 
			
		||||
								CveID:        "CVE-2017-0001",
 | 
			
		||||
								Cvss2Score:   7.1,
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
@@ -98,13 +98,13 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
						CveID: "CVE-2017-0003",
 | 
			
		||||
						CveContents: NewCveContents(
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         NVD,
 | 
			
		||||
								Type:         NvdXML,
 | 
			
		||||
								CveID:        "CVE-2017-0003",
 | 
			
		||||
								Cvss2Score:   6.9,
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
							},
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         JVN,
 | 
			
		||||
								Type:         Jvn,
 | 
			
		||||
								CveID:        "CVE-2017-0003",
 | 
			
		||||
								Cvss2Score:   7.2,
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
@@ -124,10 +124,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         Ubuntu,
 | 
			
		||||
									CveID:        "CVE-2017-0001",
 | 
			
		||||
									Severity:     "HIGH",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
									Type:          Ubuntu,
 | 
			
		||||
									CveID:         "CVE-2017-0001",
 | 
			
		||||
									Cvss2Severity: "HIGH",
 | 
			
		||||
									LastModified:  time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
							),
 | 
			
		||||
						},
 | 
			
		||||
@@ -135,10 +135,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         RedHat,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									Severity:     "CRITICAL",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
									Type:          RedHat,
 | 
			
		||||
									CveID:         "CVE-2017-0002",
 | 
			
		||||
									Cvss2Severity: "CRITICAL",
 | 
			
		||||
									LastModified:  time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
							),
 | 
			
		||||
						},
 | 
			
		||||
@@ -146,10 +146,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0003",
 | 
			
		||||
							CveContents: NewCveContents(
 | 
			
		||||
								CveContent{
 | 
			
		||||
									Type:         Oracle,
 | 
			
		||||
									CveID:        "CVE-2017-0003",
 | 
			
		||||
									Severity:     "IMPORTANT",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
									Type:          Oracle,
 | 
			
		||||
									CveID:         "CVE-2017-0003",
 | 
			
		||||
									Cvss2Severity: "IMPORTANT",
 | 
			
		||||
									LastModified:  time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
							),
 | 
			
		||||
						},
 | 
			
		||||
@@ -162,10 +162,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
						CveContents: NewCveContents(
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         Ubuntu,
 | 
			
		||||
								CveID:        "CVE-2017-0001",
 | 
			
		||||
								Severity:     "HIGH",
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
								Type:          Ubuntu,
 | 
			
		||||
								CveID:         "CVE-2017-0001",
 | 
			
		||||
								Cvss2Severity: "HIGH",
 | 
			
		||||
								LastModified:  time.Time{},
 | 
			
		||||
							},
 | 
			
		||||
						),
 | 
			
		||||
					},
 | 
			
		||||
@@ -173,10 +173,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
						CveID: "CVE-2017-0002",
 | 
			
		||||
						CveContents: NewCveContents(
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         RedHat,
 | 
			
		||||
								CveID:        "CVE-2017-0002",
 | 
			
		||||
								Severity:     "CRITICAL",
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
								Type:          RedHat,
 | 
			
		||||
								CveID:         "CVE-2017-0002",
 | 
			
		||||
								Cvss2Severity: "CRITICAL",
 | 
			
		||||
								LastModified:  time.Time{},
 | 
			
		||||
							},
 | 
			
		||||
						),
 | 
			
		||||
					},
 | 
			
		||||
@@ -184,10 +184,10 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
						CveID: "CVE-2017-0003",
 | 
			
		||||
						CveContents: NewCveContents(
 | 
			
		||||
							CveContent{
 | 
			
		||||
								Type:         Oracle,
 | 
			
		||||
								CveID:        "CVE-2017-0003",
 | 
			
		||||
								Severity:     "IMPORTANT",
 | 
			
		||||
								LastModified: time.Time{},
 | 
			
		||||
								Type:          Oracle,
 | 
			
		||||
								CveID:         "CVE-2017-0003",
 | 
			
		||||
								Cvss2Severity: "IMPORTANT",
 | 
			
		||||
								LastModified:  time.Time{},
 | 
			
		||||
							},
 | 
			
		||||
						),
 | 
			
		||||
					},
 | 
			
		||||
@@ -206,7 +206,6 @@ func TestFilterByCvssOver(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFilterIgnoreCveIDs(t *testing.T) {
 | 
			
		||||
	type in struct {
 | 
			
		||||
		cves []string
 | 
			
		||||
@@ -220,6 +219,7 @@ func TestFilterIgnoreCveIDs(t *testing.T) {
 | 
			
		||||
			in: in{
 | 
			
		||||
				cves: []string{"CVE-2017-0002"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
@@ -234,6 +234,7 @@ func TestFilterIgnoreCveIDs(t *testing.T) {
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0001": {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
@@ -246,7 +247,10 @@ func TestFilterIgnoreCveIDs(t *testing.T) {
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		actual := tt.in.rs.FilterIgnoreCves(tt.in.cves)
 | 
			
		||||
		config.Conf.Servers = map[string]config.ServerInfo{
 | 
			
		||||
			"name": {IgnoreCves: tt.in.cves},
 | 
			
		||||
		}
 | 
			
		||||
		actual := tt.in.rs.FilterIgnoreCves()
 | 
			
		||||
		for k := range tt.out.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
@@ -254,6 +258,83 @@ func TestFilterIgnoreCveIDs(t *testing.T) {
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for k := range actual.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFilterIgnoreCveIDsContainer(t *testing.T) {
 | 
			
		||||
	type in struct {
 | 
			
		||||
		cves []string
 | 
			
		||||
		rs   ScanResult
 | 
			
		||||
	}
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  in
 | 
			
		||||
		out ScanResult
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				cves: []string{"CVE-2017-0002"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					Container:  Container{Name: "dockerA"},
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2017-0002": {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2017-0003": {
 | 
			
		||||
							CveID: "CVE-2017-0003",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				Container:  Container{Name: "dockerA"},
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0001": {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
					},
 | 
			
		||||
					"CVE-2017-0003": {
 | 
			
		||||
						CveID: "CVE-2017-0003",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		config.Conf.Servers = map[string]config.ServerInfo{
 | 
			
		||||
			"name": {
 | 
			
		||||
				Containers: map[string]config.ContainerSetting{
 | 
			
		||||
					"dockerA": {
 | 
			
		||||
						IgnoreCves: tt.in.cves,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
		actual := tt.in.rs.FilterIgnoreCves()
 | 
			
		||||
		for k := range tt.out.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for k := range actual.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -336,3 +417,322 @@ func TestFilterUnfixed(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFilterIgnorePkgs(t *testing.T) {
 | 
			
		||||
	type in struct {
 | 
			
		||||
		ignorePkgsRegexp []string
 | 
			
		||||
		rs               ScanResult
 | 
			
		||||
	}
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  in
 | 
			
		||||
		out ScanResult
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2017-0002": {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0002": {
 | 
			
		||||
						CveID: "CVE-2017-0002",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
								{Name: "vim"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0001": {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
						AffectedPackages: PackageStatuses{
 | 
			
		||||
							{Name: "kernel"},
 | 
			
		||||
							{Name: "vim"},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel", "^vim", "^bind"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
								{Name: "vim"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName:  "name",
 | 
			
		||||
				ScannedCves: VulnInfos{},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		config.Conf.Servers = map[string]config.ServerInfo{
 | 
			
		||||
			"name": {IgnorePkgsRegexp: tt.in.ignorePkgsRegexp},
 | 
			
		||||
		}
 | 
			
		||||
		actual := tt.in.rs.FilterIgnorePkgs()
 | 
			
		||||
		for k := range tt.out.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for k := range actual.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFilterIgnorePkgsContainer(t *testing.T) {
 | 
			
		||||
	type in struct {
 | 
			
		||||
		ignorePkgsRegexp []string
 | 
			
		||||
		rs               ScanResult
 | 
			
		||||
	}
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  in
 | 
			
		||||
		out ScanResult
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					Container:  Container{Name: "dockerA"},
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2017-0002": {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				Container:  Container{Name: "dockerA"},
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0002": {
 | 
			
		||||
						CveID: "CVE-2017-0002",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					Container:  Container{Name: "dockerA"},
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
								{Name: "vim"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName: "name",
 | 
			
		||||
				Container:  Container{Name: "dockerA"},
 | 
			
		||||
				ScannedCves: VulnInfos{
 | 
			
		||||
					"CVE-2017-0001": {
 | 
			
		||||
						CveID: "CVE-2017-0001",
 | 
			
		||||
						AffectedPackages: PackageStatuses{
 | 
			
		||||
							{Name: "kernel"},
 | 
			
		||||
							{Name: "vim"},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				ignorePkgsRegexp: []string{"^kernel", "^vim", "^bind"},
 | 
			
		||||
				rs: ScanResult{
 | 
			
		||||
					ServerName: "name",
 | 
			
		||||
					Container:  Container{Name: "dockerA"},
 | 
			
		||||
					ScannedCves: VulnInfos{
 | 
			
		||||
						"CVE-2017-0001": {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							AffectedPackages: PackageStatuses{
 | 
			
		||||
								{Name: "kernel"},
 | 
			
		||||
								{Name: "vim"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: ScanResult{
 | 
			
		||||
				ServerName:  "name",
 | 
			
		||||
				Container:   Container{Name: "dockerA"},
 | 
			
		||||
				ScannedCves: VulnInfos{},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		config.Conf.Servers = map[string]config.ServerInfo{
 | 
			
		||||
			"name": {
 | 
			
		||||
				Containers: map[string]config.ContainerSetting{
 | 
			
		||||
					"dockerA": {
 | 
			
		||||
						IgnorePkgsRegexp: tt.in.ignorePkgsRegexp,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
		actual := tt.in.rs.FilterIgnorePkgs()
 | 
			
		||||
		for k := range tt.out.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for k := range actual.ScannedCves {
 | 
			
		||||
			if !reflect.DeepEqual(tt.out.ScannedCves[k], actual.ScannedCves[k]) {
 | 
			
		||||
				o := pp.Sprintf("%v", tt.out.ScannedCves[k])
 | 
			
		||||
				a := pp.Sprintf("%v", actual.ScannedCves[k])
 | 
			
		||||
				t.Errorf("[%s] expected: %v\n  actual: %v\n", k, o, a)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIsDisplayUpdatableNum(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		mode     []byte
 | 
			
		||||
		family   string
 | 
			
		||||
		expected bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Offline},
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.FastRoot},
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Deep},
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.RedHat,
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Oracle,
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Debian,
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Ubuntu,
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Raspbian,
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.CentOS,
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Amazon,
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.FreeBSD,
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.OpenSUSE,
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			mode:     []byte{config.Fast},
 | 
			
		||||
			family:   config.Alpine,
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		mode := config.ScanMode{}
 | 
			
		||||
		for _, m := range tt.mode {
 | 
			
		||||
			mode.Set(m)
 | 
			
		||||
		}
 | 
			
		||||
		config.Conf.Servers = map[string]config.ServerInfo{
 | 
			
		||||
			"name": {Mode: mode},
 | 
			
		||||
		}
 | 
			
		||||
		r := ScanResult{
 | 
			
		||||
			ServerName: "name",
 | 
			
		||||
			Family:     tt.family,
 | 
			
		||||
		}
 | 
			
		||||
		act := r.isDisplayUpdatableNum()
 | 
			
		||||
		if tt.expected != act {
 | 
			
		||||
			t.Errorf("[%d] expected %#v, actual %#v", i, tt.expected, act)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										142
									
								
								models/utils.go
									
									
									
									
									
								
							
							
						
						
									
										142
									
								
								models/utils.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -18,17 +18,22 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	cvedict "github.com/kotakanbe/go-cve-dictionary/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ConvertNvdToModel convert NVD to CveContent
 | 
			
		||||
func ConvertNvdToModel(cveID string, nvd cvedict.Nvd) *CveContent {
 | 
			
		||||
// ConvertNvdXMLToModel convert NVD to CveContent
 | 
			
		||||
func ConvertNvdXMLToModel(cveID string, nvd *cvedict.NvdXML) *CveContent {
 | 
			
		||||
	if nvd == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	var cpes []Cpe
 | 
			
		||||
	for _, c := range nvd.Cpes {
 | 
			
		||||
		cpes = append(cpes, Cpe{CpeName: c.CpeName})
 | 
			
		||||
		cpes = append(cpes, Cpe{
 | 
			
		||||
			FormattedString: c.FormattedString,
 | 
			
		||||
			URI:             c.URI,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var refs []Reference
 | 
			
		||||
@@ -39,42 +44,21 @@ func ConvertNvdToModel(cveID string, nvd cvedict.Nvd) *CveContent {
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	validVec := true
 | 
			
		||||
	for _, v := range []string{
 | 
			
		||||
		nvd.AccessVector,
 | 
			
		||||
		nvd.AccessComplexity,
 | 
			
		||||
		nvd.Authentication,
 | 
			
		||||
		nvd.ConfidentialityImpact,
 | 
			
		||||
		nvd.IntegrityImpact,
 | 
			
		||||
		nvd.AvailabilityImpact,
 | 
			
		||||
	} {
 | 
			
		||||
		if len(v) == 0 {
 | 
			
		||||
			validVec = false
 | 
			
		||||
		}
 | 
			
		||||
	cweIDs := []string{}
 | 
			
		||||
	for _, cid := range nvd.Cwes {
 | 
			
		||||
		cweIDs = append(cweIDs, cid.CweID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vector := ""
 | 
			
		||||
	if validVec {
 | 
			
		||||
		vector = fmt.Sprintf("AV:%s/AC:%s/Au:%s/C:%s/I:%s/A:%s",
 | 
			
		||||
			string(nvd.AccessVector[0]),
 | 
			
		||||
			string(nvd.AccessComplexity[0]),
 | 
			
		||||
			string(nvd.Authentication[0]),
 | 
			
		||||
			string(nvd.ConfidentialityImpact[0]),
 | 
			
		||||
			string(nvd.IntegrityImpact[0]),
 | 
			
		||||
			string(nvd.AvailabilityImpact[0]))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	//TODO CVSSv3
 | 
			
		||||
	return &CveContent{
 | 
			
		||||
		Type:         NVD,
 | 
			
		||||
		CveID:        cveID,
 | 
			
		||||
		Summary:      nvd.Summary,
 | 
			
		||||
		Cvss2Score:   nvd.Score,
 | 
			
		||||
		Cvss2Vector:  vector,
 | 
			
		||||
		Severity:     "", // severity is not contained in NVD
 | 
			
		||||
		SourceLink:   "https://nvd.nist.gov/vuln/detail/" + cveID,
 | 
			
		||||
		Cpes:         cpes,
 | 
			
		||||
		CweID:        nvd.CweID,
 | 
			
		||||
		Type:          Nvd,
 | 
			
		||||
		CveID:         cveID,
 | 
			
		||||
		Summary:       nvd.Summary,
 | 
			
		||||
		Cvss2Score:    nvd.Cvss2.BaseScore,
 | 
			
		||||
		Cvss2Vector:   nvd.Cvss2.VectorString,
 | 
			
		||||
		Cvss2Severity: nvd.Cvss2.Severity,
 | 
			
		||||
		SourceLink:    "https://nvd.nist.gov/vuln/detail/" + cveID,
 | 
			
		||||
		// Cpes:          cpes,
 | 
			
		||||
		CweIDs:       cweIDs,
 | 
			
		||||
		References:   refs,
 | 
			
		||||
		Published:    nvd.PublishedDate,
 | 
			
		||||
		LastModified: nvd.LastModifiedDate,
 | 
			
		||||
@@ -82,10 +66,16 @@ func ConvertNvdToModel(cveID string, nvd cvedict.Nvd) *CveContent {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertJvnToModel convert JVN to CveContent
 | 
			
		||||
func ConvertJvnToModel(cveID string, jvn cvedict.Jvn) *CveContent {
 | 
			
		||||
func ConvertJvnToModel(cveID string, jvn *cvedict.Jvn) *CveContent {
 | 
			
		||||
	if jvn == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	var cpes []Cpe
 | 
			
		||||
	for _, c := range jvn.Cpes {
 | 
			
		||||
		cpes = append(cpes, Cpe{CpeName: c.CpeName})
 | 
			
		||||
		cpes = append(cpes, Cpe{
 | 
			
		||||
			FormattedString: c.FormattedString,
 | 
			
		||||
			URI:             c.URI,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	refs := []Reference{}
 | 
			
		||||
@@ -96,19 +86,71 @@ func ConvertJvnToModel(cveID string, jvn cvedict.Jvn) *CveContent {
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vector := strings.TrimSuffix(strings.TrimPrefix(jvn.Vector, "("), ")")
 | 
			
		||||
	return &CveContent{
 | 
			
		||||
		Type:         JVN,
 | 
			
		||||
		CveID:        cveID,
 | 
			
		||||
		Title:        jvn.Title,
 | 
			
		||||
		Summary:      jvn.Summary,
 | 
			
		||||
		Severity:     jvn.Severity,
 | 
			
		||||
		Cvss2Score:   jvn.Score,
 | 
			
		||||
		Cvss2Vector:  vector,
 | 
			
		||||
		SourceLink:   jvn.JvnLink,
 | 
			
		||||
		Cpes:         cpes,
 | 
			
		||||
		Type:          Jvn,
 | 
			
		||||
		CveID:         cveID,
 | 
			
		||||
		Title:         jvn.Title,
 | 
			
		||||
		Summary:       jvn.Summary,
 | 
			
		||||
		Cvss2Score:    jvn.Cvss2.BaseScore,
 | 
			
		||||
		Cvss2Vector:   jvn.Cvss2.VectorString,
 | 
			
		||||
		Cvss2Severity: jvn.Cvss2.Severity,
 | 
			
		||||
		Cvss3Score:    jvn.Cvss3.BaseScore,
 | 
			
		||||
		Cvss3Vector:   jvn.Cvss3.VectorString,
 | 
			
		||||
		Cvss3Severity: jvn.Cvss3.BaseSeverity,
 | 
			
		||||
		SourceLink:    jvn.JvnLink,
 | 
			
		||||
		// Cpes:          cpes,
 | 
			
		||||
		References:   refs,
 | 
			
		||||
		Published:    jvn.PublishedDate,
 | 
			
		||||
		LastModified: jvn.LastModifiedDate,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertNvdJSONToModel convert NVD to CveContent
 | 
			
		||||
func ConvertNvdJSONToModel(cveID string, nvd *cvedict.NvdJSON) *CveContent {
 | 
			
		||||
	if nvd == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	var cpes []Cpe
 | 
			
		||||
	for _, c := range nvd.Cpes {
 | 
			
		||||
		cpes = append(cpes, Cpe{
 | 
			
		||||
			FormattedString: c.FormattedString,
 | 
			
		||||
			URI:             c.URI,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var refs []Reference
 | 
			
		||||
	for _, r := range nvd.References {
 | 
			
		||||
		refs = append(refs, Reference{
 | 
			
		||||
			Link:   r.Link,
 | 
			
		||||
			Source: r.Source,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cweIDs := []string{}
 | 
			
		||||
	for _, cid := range nvd.Cwes {
 | 
			
		||||
		cweIDs = append(cweIDs, cid.CweID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	desc := []string{}
 | 
			
		||||
	for _, d := range nvd.Descriptions {
 | 
			
		||||
		desc = append(desc, d.Value)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &CveContent{
 | 
			
		||||
		Type:          Nvd,
 | 
			
		||||
		CveID:         cveID,
 | 
			
		||||
		Summary:       strings.Join(desc, "\n"),
 | 
			
		||||
		Cvss2Score:    nvd.Cvss2.BaseScore,
 | 
			
		||||
		Cvss2Vector:   nvd.Cvss2.VectorString,
 | 
			
		||||
		Cvss2Severity: nvd.Cvss2.Severity,
 | 
			
		||||
		Cvss3Score:    nvd.Cvss3.BaseScore,
 | 
			
		||||
		Cvss3Vector:   nvd.Cvss3.VectorString,
 | 
			
		||||
		Cvss3Severity: nvd.Cvss3.BaseSeverity,
 | 
			
		||||
		SourceLink:    "https://nvd.nist.gov/vuln/detail/" + cveID,
 | 
			
		||||
		// Cpes:          cpes,
 | 
			
		||||
		CweIDs:       cweIDs,
 | 
			
		||||
		References:   refs,
 | 
			
		||||
		Published:    nvd.PublishedDate,
 | 
			
		||||
		LastModified: nvd.LastModifiedDate,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -24,7 +24,10 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/alert"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	exploitmodels "github.com/mozqnet/go-exploitdb/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// VulnInfos has a map of VulnInfo
 | 
			
		||||
@@ -104,43 +107,120 @@ func (v VulnInfos) FormatCveSummary() string {
 | 
			
		||||
		m["High"], m["Medium"], m["Low"], m["Unknown"])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatFixedStatus summarize the number of cves are fixed.
 | 
			
		||||
func (v VulnInfos) FormatFixedStatus(packs Packages) string {
 | 
			
		||||
	total, fixed := 0, 0
 | 
			
		||||
	for _, vInfo := range v {
 | 
			
		||||
		if len(vInfo.CpeURIs) != 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		total++
 | 
			
		||||
		if vInfo.PatchStatus(packs) == "Fixed" {
 | 
			
		||||
			fixed++
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%d/%d Fixed", fixed, total)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PackageStatuses is a list of PackageStatus
 | 
			
		||||
type PackageStatuses []PackageStatus
 | 
			
		||||
 | 
			
		||||
// FormatTuiSummary format packname to show TUI summary
 | 
			
		||||
func (ps PackageStatuses) FormatTuiSummary() string {
 | 
			
		||||
	names := []string{}
 | 
			
		||||
	for _, p := range ps {
 | 
			
		||||
		names = append(names, p.Name)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(names, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Store insert given pkg if missing, update pkg if exists
 | 
			
		||||
func (ps PackageStatuses) Store(pkg PackageStatus) PackageStatuses {
 | 
			
		||||
	for i, p := range ps {
 | 
			
		||||
		if p.Name == pkg.Name {
 | 
			
		||||
			ps[i] = pkg
 | 
			
		||||
			return ps
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	ps = append(ps, pkg)
 | 
			
		||||
	return ps
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Sort by Name
 | 
			
		||||
func (p PackageStatuses) Sort() {
 | 
			
		||||
	sort.Slice(p, func(i, j int) bool {
 | 
			
		||||
		return p[i].Name < p[j].Name
 | 
			
		||||
func (ps PackageStatuses) Sort() {
 | 
			
		||||
	sort.Slice(ps, func(i, j int) bool {
 | 
			
		||||
		return ps[i].Name < ps[j].Name
 | 
			
		||||
	})
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PackageStatus has name and other status abount the package
 | 
			
		||||
type PackageStatus struct {
 | 
			
		||||
	Name        string
 | 
			
		||||
	NotFixedYet bool
 | 
			
		||||
	Name        string `json:"name"`
 | 
			
		||||
	NotFixedYet bool   `json:"notFixedYet"`
 | 
			
		||||
	FixState    string `json:"fixState"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// VulnInfo has a vulnerability information and unsecure packages
 | 
			
		||||
type VulnInfo struct {
 | 
			
		||||
	CveID            string
 | 
			
		||||
	Confidence       Confidence
 | 
			
		||||
	AffectedPackages PackageStatuses
 | 
			
		||||
	DistroAdvisories []DistroAdvisory // for Aamazon, RHEL, FreeBSD
 | 
			
		||||
	CpeNames         []string
 | 
			
		||||
	CveContents      CveContents
 | 
			
		||||
	CveID            string           `json:"cveID,omitempty"`
 | 
			
		||||
	Confidences      Confidences      `json:"confidences,omitempty"`
 | 
			
		||||
	AffectedPackages PackageStatuses  `json:"affectedPackages,omitempty"`
 | 
			
		||||
	DistroAdvisories []DistroAdvisory `json:"distroAdvisories,omitempty"` // for Aamazon, RHEL, FreeBSD
 | 
			
		||||
	CveContents      CveContents      `json:"cveContents,omitempty"`
 | 
			
		||||
	Exploits         []Exploit        `json:"exploits,omitempty"`
 | 
			
		||||
	AlertDict        AlertDict        `json:"alertDict,omitempty"`
 | 
			
		||||
 | 
			
		||||
	CpeURIs              []string             `json:"cpeURIs,omitempty"` // CpeURIs related to this CVE defined in config.toml
 | 
			
		||||
	GitHubSecurityAlerts GitHubSecurityAlerts `json:"gitHubSecurityAlerts,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GitHubSecurityAlerts is a list of GitHubSecurityAlert
 | 
			
		||||
type GitHubSecurityAlerts []GitHubSecurityAlert
 | 
			
		||||
 | 
			
		||||
// Add adds given arg to the slice and return the slice (imutable)
 | 
			
		||||
func (g GitHubSecurityAlerts) Add(alert GitHubSecurityAlert) GitHubSecurityAlerts {
 | 
			
		||||
	for _, a := range g {
 | 
			
		||||
		if a.PackageName == alert.PackageName {
 | 
			
		||||
			return g
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return append(g, alert)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g GitHubSecurityAlerts) String() string {
 | 
			
		||||
	ss := []string{}
 | 
			
		||||
	for _, a := range g {
 | 
			
		||||
		ss = append(ss, a.PackageName)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(ss, ", ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GitHubSecurityAlert has detected CVE-ID, PackageName, Status fetched via GitHub API
 | 
			
		||||
type GitHubSecurityAlert struct {
 | 
			
		||||
	PackageName   string    `json:"packageName"`
 | 
			
		||||
	FixedIn       string    `json:"fixedIn"`
 | 
			
		||||
	AffectedRange string    `json:"affectedRange"`
 | 
			
		||||
	Dismissed     bool      `json:"dismissed"`
 | 
			
		||||
	DismissedAt   time.Time `json:"dismissedAt"`
 | 
			
		||||
	DismissReason string    `json:"dismissReason"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Titles returns tilte (TUI)
 | 
			
		||||
func (v VulnInfo) Titles(lang, myFamily string) (values []CveContentStr) {
 | 
			
		||||
	if lang == "ja" {
 | 
			
		||||
		if cont, found := v.CveContents[JVN]; found && 0 < len(cont.Title) {
 | 
			
		||||
			values = append(values, CveContentStr{JVN, cont.Title})
 | 
			
		||||
		if cont, found := v.CveContents[Jvn]; found && 0 < len(cont.Title) {
 | 
			
		||||
			values = append(values, CveContentStr{Jvn, cont.Title})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	order := CveContentTypes{NVD, NewCveContentType(myFamily)}
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(append(order, JVN)...)...)
 | 
			
		||||
	// RedHat API has one line title.
 | 
			
		||||
	if cont, found := v.CveContents[RedHatAPI]; found && 0 < len(cont.Title) {
 | 
			
		||||
		values = append(values, CveContentStr{RedHatAPI, cont.Title})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	order := CveContentTypes{Nvd, NvdXML, NewCveContentType(myFamily)}
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(append(order, Jvn)...)...)
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		// Only JVN has meaningful title. so return first 100 char of summary
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < len(cont.Summary) {
 | 
			
		||||
@@ -171,16 +251,16 @@ func (v VulnInfo) Titles(lang, myFamily string) (values []CveContentStr) {
 | 
			
		||||
// Summaries returns summaries
 | 
			
		||||
func (v VulnInfo) Summaries(lang, myFamily string) (values []CveContentStr) {
 | 
			
		||||
	if lang == "ja" {
 | 
			
		||||
		if cont, found := v.CveContents[JVN]; found && 0 < len(cont.Summary) {
 | 
			
		||||
		if cont, found := v.CveContents[Jvn]; found && 0 < len(cont.Summary) {
 | 
			
		||||
			summary := cont.Title
 | 
			
		||||
			summary += "\n" + strings.Replace(
 | 
			
		||||
				strings.Replace(cont.Summary, "\n", " ", -1), "\r", " ", -1)
 | 
			
		||||
			values = append(values, CveContentStr{JVN, summary})
 | 
			
		||||
			values = append(values, CveContentStr{Jvn, summary})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	order := CveContentTypes{NVD, NewCveContentType(myFamily)}
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(append(order, JVN)...)...)
 | 
			
		||||
	order := CveContentTypes{Nvd, NvdXML, NewCveContentType(myFamily)}
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(append(order, Jvn)...)...)
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < len(cont.Summary) {
 | 
			
		||||
			summary := strings.Replace(cont.Summary, "\n", " ", -1)
 | 
			
		||||
@@ -208,23 +288,46 @@ func (v VulnInfo) Summaries(lang, myFamily string) (values []CveContentStr) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Cvss2Scores returns CVSS V2 Scores
 | 
			
		||||
func (v VulnInfo) Cvss2Scores() (values []CveContentCvss) {
 | 
			
		||||
	order := []CveContentType{NVD, RedHat, JVN}
 | 
			
		||||
// Mitigations returns mitigations
 | 
			
		||||
func (v VulnInfo) Mitigations(myFamily string) (values []CveContentStr) {
 | 
			
		||||
	order := CveContentTypes{RedHatAPI}
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < cont.Cvss2Score {
 | 
			
		||||
			// https://nvd.nist.gov/vuln-metrics/cvss
 | 
			
		||||
			sev := cont.Severity
 | 
			
		||||
			if ctype == NVD {
 | 
			
		||||
				sev = cvss2ScoreToSeverity(cont.Cvss2Score)
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < len(cont.Mitigation) {
 | 
			
		||||
			values = append(values, CveContentStr{
 | 
			
		||||
				Type:  ctype,
 | 
			
		||||
				Value: cont.Mitigation,
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(values) == 0 {
 | 
			
		||||
		return []CveContentStr{{
 | 
			
		||||
			Type:  Unknown,
 | 
			
		||||
			Value: "-",
 | 
			
		||||
		}}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Cvss2Scores returns CVSS V2 Scores
 | 
			
		||||
func (v VulnInfo) Cvss2Scores(myFamily string) (values []CveContentCvss) {
 | 
			
		||||
	order := []CveContentType{Nvd, NvdXML, RedHatAPI, RedHat, Jvn}
 | 
			
		||||
	if myFamily != config.RedHat && myFamily != config.CentOS {
 | 
			
		||||
		order = append(order, NewCveContentType(myFamily))
 | 
			
		||||
	}
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found {
 | 
			
		||||
			if cont.Cvss2Score == 0 && cont.Cvss2Severity == "" {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			// https://nvd.nist.gov/vuln-metrics/cvss
 | 
			
		||||
			values = append(values, CveContentCvss{
 | 
			
		||||
				Type: ctype,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS2,
 | 
			
		||||
					Score:    cont.Cvss2Score,
 | 
			
		||||
					Vector:   cont.Cvss2Vector,
 | 
			
		||||
					Severity: strings.ToUpper(sev),
 | 
			
		||||
					Severity: strings.ToUpper(cont.Cvss2Severity),
 | 
			
		||||
				},
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
@@ -233,7 +336,7 @@ func (v VulnInfo) Cvss2Scores() (values []CveContentCvss) {
 | 
			
		||||
	for _, adv := range v.DistroAdvisories {
 | 
			
		||||
		if adv.Severity != "" {
 | 
			
		||||
			values = append(values, CveContentCvss{
 | 
			
		||||
				Type: "Vendor",
 | 
			
		||||
				Type: "Advisory",
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:                 CVSS2,
 | 
			
		||||
					Score:                severityToV2ScoreRoughly(adv.Severity),
 | 
			
		||||
@@ -245,24 +348,44 @@ func (v VulnInfo) Cvss2Scores() (values []CveContentCvss) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// An OVAL entry in Ubuntu and Debian has only severity (CVSS score isn't included).
 | 
			
		||||
	// Show severity and dummy score calculated roughly.
 | 
			
		||||
	order = append(order, AllCveContetTypes.Except(order...)...)
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found &&
 | 
			
		||||
			cont.Cvss2Score == 0 &&
 | 
			
		||||
			cont.Cvss3Score == 0 &&
 | 
			
		||||
			cont.Cvss2Severity != "" {
 | 
			
		||||
 | 
			
		||||
			values = append(values, CveContentCvss{
 | 
			
		||||
				Type: cont.Type,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:                 CVSS2,
 | 
			
		||||
					Score:                severityToV2ScoreRoughly(cont.Cvss2Severity),
 | 
			
		||||
					CalculatedBySeverity: true,
 | 
			
		||||
					Vector:               "-",
 | 
			
		||||
					Severity:             strings.ToUpper(cont.Cvss2Severity),
 | 
			
		||||
				},
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Cvss3Scores returns CVSS V3 Score
 | 
			
		||||
func (v VulnInfo) Cvss3Scores() (values []CveContentCvss) {
 | 
			
		||||
	// TODO implement NVD
 | 
			
		||||
	order := []CveContentType{RedHat}
 | 
			
		||||
	order := []CveContentType{Nvd, RedHatAPI, RedHat, Jvn}
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < cont.Cvss3Score {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found {
 | 
			
		||||
			// https://nvd.nist.gov/vuln-metrics/cvss
 | 
			
		||||
			sev := cont.Severity
 | 
			
		||||
			values = append(values, CveContentCvss{
 | 
			
		||||
				Type: ctype,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS3,
 | 
			
		||||
					Score:    cont.Cvss3Score,
 | 
			
		||||
					Vector:   cont.Cvss3Vector,
 | 
			
		||||
					Severity: strings.ToUpper(sev),
 | 
			
		||||
					Severity: strings.ToUpper(cont.Cvss3Severity),
 | 
			
		||||
				},
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
@@ -272,8 +395,7 @@ func (v VulnInfo) Cvss3Scores() (values []CveContentCvss) {
 | 
			
		||||
 | 
			
		||||
// MaxCvss3Score returns Max CVSS V3 Score
 | 
			
		||||
func (v VulnInfo) MaxCvss3Score() CveContentCvss {
 | 
			
		||||
	// TODO implement NVD
 | 
			
		||||
	order := []CveContentType{RedHat}
 | 
			
		||||
	order := []CveContentType{Nvd, RedHat, RedHatAPI, Jvn}
 | 
			
		||||
	max := 0.0
 | 
			
		||||
	value := CveContentCvss{
 | 
			
		||||
		Type:  Unknown,
 | 
			
		||||
@@ -282,14 +404,13 @@ func (v VulnInfo) MaxCvss3Score() CveContentCvss {
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && max < cont.Cvss3Score {
 | 
			
		||||
			// https://nvd.nist.gov/vuln-metrics/cvss
 | 
			
		||||
			sev := cont.Severity
 | 
			
		||||
			value = CveContentCvss{
 | 
			
		||||
				Type: ctype,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS3,
 | 
			
		||||
					Score:    cont.Cvss3Score,
 | 
			
		||||
					Vector:   cont.Cvss3Vector,
 | 
			
		||||
					Severity: sev,
 | 
			
		||||
					Severity: strings.ToUpper(cont.Cvss3Severity),
 | 
			
		||||
				},
 | 
			
		||||
			}
 | 
			
		||||
			max = cont.Cvss3Score
 | 
			
		||||
@@ -316,7 +437,7 @@ func (v VulnInfo) MaxCvssScore() CveContentCvss {
 | 
			
		||||
 | 
			
		||||
// MaxCvss2Score returns Max CVSS V2 Score
 | 
			
		||||
func (v VulnInfo) MaxCvss2Score() CveContentCvss {
 | 
			
		||||
	order := []CveContentType{NVD, RedHat, JVN}
 | 
			
		||||
	order := []CveContentType{Nvd, NvdXML, RedHat, RedHatAPI, Jvn}
 | 
			
		||||
	max := 0.0
 | 
			
		||||
	value := CveContentCvss{
 | 
			
		||||
		Type:  Unknown,
 | 
			
		||||
@@ -325,17 +446,13 @@ func (v VulnInfo) MaxCvss2Score() CveContentCvss {
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && max < cont.Cvss2Score {
 | 
			
		||||
			// https://nvd.nist.gov/vuln-metrics/cvss
 | 
			
		||||
			sev := cont.Severity
 | 
			
		||||
			if ctype == NVD {
 | 
			
		||||
				sev = cvss2ScoreToSeverity(cont.Cvss2Score)
 | 
			
		||||
			}
 | 
			
		||||
			value = CveContentCvss{
 | 
			
		||||
				Type: ctype,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS2,
 | 
			
		||||
					Score:    cont.Cvss2Score,
 | 
			
		||||
					Vector:   cont.Cvss2Vector,
 | 
			
		||||
					Severity: sev,
 | 
			
		||||
					Severity: strings.ToUpper(cont.Cvss2Severity),
 | 
			
		||||
				},
 | 
			
		||||
			}
 | 
			
		||||
			max = cont.Cvss2Score
 | 
			
		||||
@@ -350,8 +467,8 @@ func (v VulnInfo) MaxCvss2Score() CveContentCvss {
 | 
			
		||||
	// Only Ubuntu, RedHat and Oracle have severity data in OVAL.
 | 
			
		||||
	order = []CveContentType{Ubuntu, RedHat, Oracle}
 | 
			
		||||
	for _, ctype := range order {
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < len(cont.Severity) {
 | 
			
		||||
			score := severityToV2ScoreRoughly(cont.Severity)
 | 
			
		||||
		if cont, found := v.CveContents[ctype]; found && 0 < len(cont.Cvss2Severity) {
 | 
			
		||||
			score := severityToV2ScoreRoughly(cont.Cvss2Severity)
 | 
			
		||||
			if max < score {
 | 
			
		||||
				value = CveContentCvss{
 | 
			
		||||
					Type: ctype,
 | 
			
		||||
@@ -360,7 +477,7 @@ func (v VulnInfo) MaxCvss2Score() CveContentCvss {
 | 
			
		||||
						Score:                score,
 | 
			
		||||
						CalculatedBySeverity: true,
 | 
			
		||||
						Vector:               cont.Cvss2Vector,
 | 
			
		||||
						Severity:             cont.Severity,
 | 
			
		||||
						Severity:             strings.ToUpper(cont.Cvss2Severity),
 | 
			
		||||
					},
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@@ -389,10 +506,55 @@ func (v VulnInfo) MaxCvss2Score() CveContentCvss {
 | 
			
		||||
	return value
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CveContentCvss has CveContentType and Cvss2
 | 
			
		||||
// AttackVector returns attack vector string
 | 
			
		||||
func (v VulnInfo) AttackVector() string {
 | 
			
		||||
	for _, cnt := range v.CveContents {
 | 
			
		||||
		if strings.HasPrefix(cnt.Cvss2Vector, "AV:N") ||
 | 
			
		||||
			strings.HasPrefix(cnt.Cvss3Vector, "CVSS:3.0/AV:N") {
 | 
			
		||||
			return "Network"
 | 
			
		||||
		} else if strings.HasPrefix(cnt.Cvss2Vector, "AV:A") ||
 | 
			
		||||
			strings.HasPrefix(cnt.Cvss3Vector, "CVSS:3.0/AV:A") {
 | 
			
		||||
			return "Adjacent"
 | 
			
		||||
		} else if strings.HasPrefix(cnt.Cvss2Vector, "AV:L") ||
 | 
			
		||||
			strings.HasPrefix(cnt.Cvss3Vector, "CVSS:3.0/AV:L") {
 | 
			
		||||
			return "Local"
 | 
			
		||||
		} else if strings.HasPrefix(cnt.Cvss3Vector, "CVSS:3.0/AV:P") {
 | 
			
		||||
			return "Physical"
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if cont, found := v.CveContents[DebianSecurityTracker]; found {
 | 
			
		||||
		if attackRange, found := cont.Optional["attack range"]; found {
 | 
			
		||||
			return attackRange
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PatchStatus returns attack vector string
 | 
			
		||||
func (v VulnInfo) PatchStatus(packs Packages) string {
 | 
			
		||||
	// Vuls don't know patch status of the CPE
 | 
			
		||||
	if len(v.CpeURIs) != 0 {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	for _, p := range v.AffectedPackages {
 | 
			
		||||
		if p.NotFixedYet {
 | 
			
		||||
			return "Unfixed"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// fast, offline mode doesn't have new version
 | 
			
		||||
		if pack, ok := packs[p.Name]; ok {
 | 
			
		||||
			if pack.NewVersion == "" {
 | 
			
		||||
				return "Unknown"
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return "Fixed"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CveContentCvss has CVSS information
 | 
			
		||||
type CveContentCvss struct {
 | 
			
		||||
	Type  CveContentType
 | 
			
		||||
	Value Cvss
 | 
			
		||||
	Type  CveContentType `json:"type"`
 | 
			
		||||
	Value Cvss           `json:"value"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CvssType Represent the type of CVSS
 | 
			
		||||
@@ -408,20 +570,23 @@ const (
 | 
			
		||||
 | 
			
		||||
// Cvss has CVSS Score
 | 
			
		||||
type Cvss struct {
 | 
			
		||||
	Type                 CvssType
 | 
			
		||||
	Score                float64
 | 
			
		||||
	CalculatedBySeverity bool
 | 
			
		||||
	Vector               string
 | 
			
		||||
	Severity             string
 | 
			
		||||
	Type                 CvssType `json:"type"`
 | 
			
		||||
	Score                float64  `json:"score"`
 | 
			
		||||
	CalculatedBySeverity bool     `json:"calculatedBySeverity"`
 | 
			
		||||
	Vector               string   `json:"vector"`
 | 
			
		||||
	Severity             string   `json:"severity"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format CVSS Score and Vector
 | 
			
		||||
func (c Cvss) Format() string {
 | 
			
		||||
	if c.Score == 0 || c.Vector == "" {
 | 
			
		||||
		return c.Severity
 | 
			
		||||
	}
 | 
			
		||||
	switch c.Type {
 | 
			
		||||
	case CVSS2:
 | 
			
		||||
		return fmt.Sprintf("%3.1f/%s", c.Score, c.Vector)
 | 
			
		||||
		return fmt.Sprintf("%3.1f/%s %s", c.Score, c.Vector, c.Severity)
 | 
			
		||||
	case CVSS3:
 | 
			
		||||
		return fmt.Sprintf("%3.1f/CVSS:3.0/%s", c.Score, c.Vector)
 | 
			
		||||
		return fmt.Sprintf("%3.1f/%s %s", c.Score, c.Vector, c.Severity)
 | 
			
		||||
	}
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
@@ -461,49 +626,13 @@ func severityToV2ScoreRoughly(severity string) float64 {
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CveContentCvss3 has CveContentType and Cvss3
 | 
			
		||||
//  type CveContentCvss3 struct {
 | 
			
		||||
//      Type  CveContentType
 | 
			
		||||
//      Value Cvss3
 | 
			
		||||
//  }
 | 
			
		||||
 | 
			
		||||
// Cvss3 has CVSS v3 Score, Vector and  Severity
 | 
			
		||||
//  type Cvss3 struct {
 | 
			
		||||
//      Score    float64
 | 
			
		||||
//      Vector   string
 | 
			
		||||
//      Severity string
 | 
			
		||||
//  }
 | 
			
		||||
 | 
			
		||||
// Format CVSS Score and Vector
 | 
			
		||||
//  func (c Cvss3) Format() string {
 | 
			
		||||
//      return fmt.Sprintf("%3.1f/CVSS:3.0/%s", c.Score, c.Vector)
 | 
			
		||||
//  }
 | 
			
		||||
 | 
			
		||||
//  func cvss3ScoreToSeverity(score float64) string {
 | 
			
		||||
//      if 9.0 <= score {
 | 
			
		||||
//          return "CRITICAL"
 | 
			
		||||
//      } else if 7.0 <= score {
 | 
			
		||||
//          return "HIGH"
 | 
			
		||||
//      } else if 4.0 <= score {
 | 
			
		||||
//          return "MEDIUM"
 | 
			
		||||
//      }
 | 
			
		||||
//      return "LOW"
 | 
			
		||||
//  }
 | 
			
		||||
 | 
			
		||||
// FormatMaxCvssScore returns Max CVSS Score
 | 
			
		||||
func (v VulnInfo) FormatMaxCvssScore() string {
 | 
			
		||||
	v2Max := v.MaxCvss2Score()
 | 
			
		||||
	v3Max := v.MaxCvss3Score()
 | 
			
		||||
	if v2Max.Value.Score <= v3Max.Value.Score {
 | 
			
		||||
		return fmt.Sprintf("%3.1f %s (%s)",
 | 
			
		||||
			v3Max.Value.Score,
 | 
			
		||||
			strings.ToUpper(v3Max.Value.Severity),
 | 
			
		||||
			v3Max.Type)
 | 
			
		||||
	}
 | 
			
		||||
	max := v.MaxCvssScore()
 | 
			
		||||
	return fmt.Sprintf("%3.1f %s (%s)",
 | 
			
		||||
		v2Max.Value.Score,
 | 
			
		||||
		strings.ToUpper(v2Max.Value.Severity),
 | 
			
		||||
		v2Max.Type)
 | 
			
		||||
		max.Value.Score,
 | 
			
		||||
		strings.ToUpper(max.Value.Severity),
 | 
			
		||||
		max.Type)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Cvss2CalcURL returns CVSS v2 caluclator's URL
 | 
			
		||||
@@ -558,37 +687,13 @@ func (v VulnInfo) VendorLinks(family string) map[string]string {
 | 
			
		||||
	return links
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NilToEmpty set nil slice or map fields to empty to avoid null in JSON
 | 
			
		||||
func (v *VulnInfo) NilToEmpty() *VulnInfo {
 | 
			
		||||
	if v.CpeNames == nil {
 | 
			
		||||
		v.CpeNames = []string{}
 | 
			
		||||
	}
 | 
			
		||||
	if v.DistroAdvisories == nil {
 | 
			
		||||
		v.DistroAdvisories = []DistroAdvisory{}
 | 
			
		||||
	}
 | 
			
		||||
	if v.AffectedPackages == nil {
 | 
			
		||||
		v.AffectedPackages = PackageStatuses{}
 | 
			
		||||
	}
 | 
			
		||||
	if v.CveContents == nil {
 | 
			
		||||
		v.CveContents = NewCveContents()
 | 
			
		||||
	}
 | 
			
		||||
	for key := range v.CveContents {
 | 
			
		||||
		if v.CveContents[key].Cpes == nil {
 | 
			
		||||
			cont := v.CveContents[key]
 | 
			
		||||
			cont.Cpes = []Cpe{}
 | 
			
		||||
			v.CveContents[key] = cont
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return v
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DistroAdvisory has Amazon Linux, RHEL, FreeBSD Security Advisory information.
 | 
			
		||||
type DistroAdvisory struct {
 | 
			
		||||
	AdvisoryID  string
 | 
			
		||||
	Severity    string
 | 
			
		||||
	Issued      time.Time
 | 
			
		||||
	Updated     time.Time
 | 
			
		||||
	Description string
 | 
			
		||||
	AdvisoryID  string    `json:"advisoryID"`
 | 
			
		||||
	Severity    string    `json:"severity"`
 | 
			
		||||
	Issued      time.Time `json:"issued"`
 | 
			
		||||
	Updated     time.Time `json:"updated"`
 | 
			
		||||
	Description string    `json:"description"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format the distro advisory information
 | 
			
		||||
@@ -605,11 +710,67 @@ func (p DistroAdvisory) Format() string {
 | 
			
		||||
	return strings.Join(buf, "\n")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Exploit :
 | 
			
		||||
type Exploit struct {
 | 
			
		||||
	ExploitType  exploitmodels.ExploitType `json:"exploitType"`
 | 
			
		||||
	ID           string                    `json:"id"`
 | 
			
		||||
	URL          string                    `json:"url"`
 | 
			
		||||
	Description  string                    `json:"description"`
 | 
			
		||||
	DocumentURL  *string                   `json:"documentURL,omitempty"`
 | 
			
		||||
	ShellCodeURL *string                   `json:"shellCodeURL,omitempty"`
 | 
			
		||||
	BinaryURL    *string                   `json:"binaryURL,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AlertDict has target cve's JPCERT and USCERT alert data
 | 
			
		||||
type AlertDict struct {
 | 
			
		||||
	Ja []alert.Alert `json:"ja"`
 | 
			
		||||
	En []alert.Alert `json:"en"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HasAlert returns whether or not it has En or Ja entries.
 | 
			
		||||
func (a AlertDict) HasAlert() bool {
 | 
			
		||||
	return len(a.En) != 0 || len(a.Ja) != 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FormatSource returns which source has this alert
 | 
			
		||||
func (a AlertDict) FormatSource() string {
 | 
			
		||||
	s := []string{}
 | 
			
		||||
	if len(a.En) != 0 {
 | 
			
		||||
		s = append(s, "USCERT")
 | 
			
		||||
	}
 | 
			
		||||
	if len(a.Ja) != 0 {
 | 
			
		||||
		s = append(s, "JPCERT")
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(s, "/")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Confidences is a list of Confidence
 | 
			
		||||
type Confidences []Confidence
 | 
			
		||||
 | 
			
		||||
// AppendIfMissing appends confidence to the list if missiong
 | 
			
		||||
func (cs *Confidences) AppendIfMissing(confidence Confidence) {
 | 
			
		||||
	for _, c := range *cs {
 | 
			
		||||
		if c.DetectionMethod == confidence.DetectionMethod {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	*cs = append(*cs, confidence)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SortByConfident sorts Confidences
 | 
			
		||||
func (cs Confidences) SortByConfident() Confidences {
 | 
			
		||||
	sort.Slice(cs, func(i, j int) bool {
 | 
			
		||||
		return cs[i].SortOrder < cs[j].SortOrder
 | 
			
		||||
	})
 | 
			
		||||
	return cs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Confidence is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
// Score: 0 - 100
 | 
			
		||||
type Confidence struct {
 | 
			
		||||
	Score           int
 | 
			
		||||
	DetectionMethod DetectionMethod
 | 
			
		||||
	Score           int             `json:"score"`
 | 
			
		||||
	DetectionMethod DetectionMethod `json:"detectionMethod"`
 | 
			
		||||
	SortOrder       int             `json:"-"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c Confidence) String() string {
 | 
			
		||||
@@ -634,12 +795,21 @@ const (
 | 
			
		||||
	// OvalMatchStr is a String representation of OvalMatch
 | 
			
		||||
	OvalMatchStr = "OvalMatch"
 | 
			
		||||
 | 
			
		||||
	// RedHatAPIStr is a String representation of RedHatAPIMatch
 | 
			
		||||
	RedHatAPIStr = "RedHatAPIMatch"
 | 
			
		||||
 | 
			
		||||
	// DebianSecurityTrackerMatchStr is a String representation of DebianSecurityTrackerMatch
 | 
			
		||||
	DebianSecurityTrackerMatchStr = "DebianSecurityTrackerMatch"
 | 
			
		||||
 | 
			
		||||
	// ChangelogExactMatchStr is a String representation of ChangelogExactMatch
 | 
			
		||||
	ChangelogExactMatchStr = "ChangelogExactMatch"
 | 
			
		||||
 | 
			
		||||
	// ChangelogLenientMatchStr is a String representation of ChangelogLenientMatch
 | 
			
		||||
	ChangelogLenientMatchStr = "ChangelogLenientMatch"
 | 
			
		||||
 | 
			
		||||
	// GitHubMatchStr is a String representation of GitHubMatch
 | 
			
		||||
	GitHubMatchStr = "GitHubMatch"
 | 
			
		||||
 | 
			
		||||
	// FailedToGetChangelog is a String representation of FailedToGetChangelog
 | 
			
		||||
	FailedToGetChangelog = "FailedToGetChangelog"
 | 
			
		||||
 | 
			
		||||
@@ -649,20 +819,29 @@ const (
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// CpeNameMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	CpeNameMatch = Confidence{100, CpeNameMatchStr}
 | 
			
		||||
	CpeNameMatch = Confidence{100, CpeNameMatchStr, 1}
 | 
			
		||||
 | 
			
		||||
	// YumUpdateSecurityMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	YumUpdateSecurityMatch = Confidence{100, YumUpdateSecurityMatchStr}
 | 
			
		||||
	YumUpdateSecurityMatch = Confidence{100, YumUpdateSecurityMatchStr, 2}
 | 
			
		||||
 | 
			
		||||
	// PkgAuditMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	PkgAuditMatch = Confidence{100, PkgAuditMatchStr}
 | 
			
		||||
	PkgAuditMatch = Confidence{100, PkgAuditMatchStr, 2}
 | 
			
		||||
 | 
			
		||||
	// OvalMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	OvalMatch = Confidence{100, OvalMatchStr}
 | 
			
		||||
	OvalMatch = Confidence{100, OvalMatchStr, 0}
 | 
			
		||||
 | 
			
		||||
	// RedHatAPIMatch ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	RedHatAPIMatch = Confidence{100, RedHatAPIStr, 0}
 | 
			
		||||
 | 
			
		||||
	// DebianSecurityTrackerMatch ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	DebianSecurityTrackerMatch = Confidence{100, DebianSecurityTrackerMatchStr, 0}
 | 
			
		||||
 | 
			
		||||
	// ChangelogExactMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	ChangelogExactMatch = Confidence{95, ChangelogExactMatchStr}
 | 
			
		||||
	ChangelogExactMatch = Confidence{95, ChangelogExactMatchStr, 3}
 | 
			
		||||
 | 
			
		||||
	// ChangelogLenientMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	ChangelogLenientMatch = Confidence{50, ChangelogLenientMatchStr}
 | 
			
		||||
	ChangelogLenientMatch = Confidence{50, ChangelogLenientMatchStr, 4}
 | 
			
		||||
 | 
			
		||||
	// GitHubMatch is a ranking how confident the CVE-ID was deteted correctly
 | 
			
		||||
	GitHubMatch = Confidence{97, GitHubMatchStr, 2}
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -36,16 +36,16 @@ func TestTitles(t *testing.T) {
 | 
			
		||||
				lang: "ja",
 | 
			
		||||
				cont: VulnInfo{
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						JVN: {
 | 
			
		||||
							Type:  JVN,
 | 
			
		||||
						Jvn: {
 | 
			
		||||
							Type:  Jvn,
 | 
			
		||||
							Title: "Title1",
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
							Type:    RedHat,
 | 
			
		||||
							Summary: "Summary RedHat",
 | 
			
		||||
						},
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:    NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:    NvdXML,
 | 
			
		||||
							Summary: "Summary NVD",
 | 
			
		||||
							// Severity is NIOT included in NVD
 | 
			
		||||
						},
 | 
			
		||||
@@ -54,11 +54,11 @@ func TestTitles(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  JVN,
 | 
			
		||||
					Type:  Jvn,
 | 
			
		||||
					Value: "Title1",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "Summary NVD",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -73,16 +73,16 @@ func TestTitles(t *testing.T) {
 | 
			
		||||
				lang: "en",
 | 
			
		||||
				cont: VulnInfo{
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						JVN: {
 | 
			
		||||
							Type:  JVN,
 | 
			
		||||
						Jvn: {
 | 
			
		||||
							Type:  Jvn,
 | 
			
		||||
							Title: "Title1",
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
							Type:    RedHat,
 | 
			
		||||
							Summary: "Summary RedHat",
 | 
			
		||||
						},
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:    NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:    NvdXML,
 | 
			
		||||
							Summary: "Summary NVD",
 | 
			
		||||
							// Severity is NIOT included in NVD
 | 
			
		||||
						},
 | 
			
		||||
@@ -91,7 +91,7 @@ func TestTitles(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "Summary NVD",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -137,8 +137,8 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
				lang: "ja",
 | 
			
		||||
				cont: VulnInfo{
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						JVN: {
 | 
			
		||||
							Type:    JVN,
 | 
			
		||||
						Jvn: {
 | 
			
		||||
							Type:    Jvn,
 | 
			
		||||
							Title:   "Title JVN",
 | 
			
		||||
							Summary: "Summary JVN",
 | 
			
		||||
						},
 | 
			
		||||
@@ -146,8 +146,8 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
							Type:    RedHat,
 | 
			
		||||
							Summary: "Summary RedHat",
 | 
			
		||||
						},
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:    NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:    NvdXML,
 | 
			
		||||
							Summary: "Summary NVD",
 | 
			
		||||
							// Severity is NIOT included in NVD
 | 
			
		||||
						},
 | 
			
		||||
@@ -156,11 +156,11 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  JVN,
 | 
			
		||||
					Type:  Jvn,
 | 
			
		||||
					Value: "Title JVN\nSummary JVN",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "Summary NVD",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -175,8 +175,8 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
				lang: "en",
 | 
			
		||||
				cont: VulnInfo{
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						JVN: {
 | 
			
		||||
							Type:    JVN,
 | 
			
		||||
						Jvn: {
 | 
			
		||||
							Type:    Jvn,
 | 
			
		||||
							Title:   "Title JVN",
 | 
			
		||||
							Summary: "Summary JVN",
 | 
			
		||||
						},
 | 
			
		||||
@@ -184,8 +184,8 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
							Type:    RedHat,
 | 
			
		||||
							Summary: "Summary RedHat",
 | 
			
		||||
						},
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:    NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:    NvdXML,
 | 
			
		||||
							Summary: "Summary NVD",
 | 
			
		||||
							// Severity is NIOT included in NVD
 | 
			
		||||
						},
 | 
			
		||||
@@ -194,7 +194,7 @@ func TestSummaries(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentStr{
 | 
			
		||||
				{
 | 
			
		||||
					Type:  NVD,
 | 
			
		||||
					Type:  NvdXML,
 | 
			
		||||
					Value: "Summary NVD",
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
@@ -235,8 +235,8 @@ func TestCountGroupBySeverity(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0002": {
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 6.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -248,8 +248,8 @@ func TestCountGroupBySeverity(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0003": {
 | 
			
		||||
					CveID: "CVE-2017-0003",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 2.0,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
@@ -257,8 +257,8 @@ func TestCountGroupBySeverity(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0004": {
 | 
			
		||||
					CveID: "CVE-2017-0004",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 5.0,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
@@ -296,8 +296,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0002": {
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 6.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -309,8 +309,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0001": {
 | 
			
		||||
					CveID: "CVE-2017-0001",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 7.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -324,8 +324,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				{
 | 
			
		||||
					CveID: "CVE-2017-0001",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 7.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -337,8 +337,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				{
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 6.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -355,8 +355,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				"CVE-2017-0002": {
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 6.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -388,8 +388,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
				{
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						NVD: {
 | 
			
		||||
							Type:       NVD,
 | 
			
		||||
						NvdXML: {
 | 
			
		||||
							Type:       NvdXML,
 | 
			
		||||
							Cvss2Score: 6.0,
 | 
			
		||||
						},
 | 
			
		||||
						RedHat: {
 | 
			
		||||
@@ -407,8 +407,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						Ubuntu: {
 | 
			
		||||
							Type:     Ubuntu,
 | 
			
		||||
							Severity: "High",
 | 
			
		||||
							Type:          Ubuntu,
 | 
			
		||||
							Cvss2Severity: "High",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -416,8 +416,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
					CveID: "CVE-2017-0001",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						Ubuntu: {
 | 
			
		||||
							Type:     Ubuntu,
 | 
			
		||||
							Severity: "Low",
 | 
			
		||||
							Type:          Ubuntu,
 | 
			
		||||
							Cvss2Severity: "Low",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -427,8 +427,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
					CveID: "CVE-2017-0002",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						Ubuntu: {
 | 
			
		||||
							Type:     Ubuntu,
 | 
			
		||||
							Severity: "High",
 | 
			
		||||
							Type:          Ubuntu,
 | 
			
		||||
							Cvss2Severity: "High",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -436,8 +436,8 @@ func TestToSortedSlice(t *testing.T) {
 | 
			
		||||
					CveID: "CVE-2017-0001",
 | 
			
		||||
					CveContents: CveContents{
 | 
			
		||||
						Ubuntu: {
 | 
			
		||||
							Type:     Ubuntu,
 | 
			
		||||
							Severity: "Low",
 | 
			
		||||
							Type:          Ubuntu,
 | 
			
		||||
							Cvss2Severity: "Low",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -460,29 +460,29 @@ func TestCvss2Scores(t *testing.T) {
 | 
			
		||||
		{
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:        JVN,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss2Score:  8.2,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:          Jvn,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.2,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:        RedHat,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss2Score:  8.0,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.0,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:        NVD,
 | 
			
		||||
						Cvss2Score:  8.1,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
						// Severity is NIOT included in NVD
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:          NvdXML,
 | 
			
		||||
						Cvss2Score:    8.1,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: []CveContentCvss{
 | 
			
		||||
				{
 | 
			
		||||
					Type: NVD,
 | 
			
		||||
					Type: NvdXML,
 | 
			
		||||
					Value: Cvss{
 | 
			
		||||
						Type:     CVSS2,
 | 
			
		||||
						Score:    8.1,
 | 
			
		||||
@@ -500,7 +500,7 @@ func TestCvss2Scores(t *testing.T) {
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					Type: JVN,
 | 
			
		||||
					Type: Jvn,
 | 
			
		||||
					Value: Cvss{
 | 
			
		||||
						Type:     CVSS2,
 | 
			
		||||
						Score:    8.2,
 | 
			
		||||
@@ -517,9 +517,9 @@ func TestCvss2Scores(t *testing.T) {
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		actual := tt.in.Cvss2Scores()
 | 
			
		||||
		actual := tt.in.Cvss2Scores("redhat")
 | 
			
		||||
		if !reflect.DeepEqual(tt.out, actual) {
 | 
			
		||||
			t.Errorf("[%d] expected: %v\n  actual: %v\n", i, tt.out, actual)
 | 
			
		||||
			t.Errorf("[%d]\nexpected: %v\n  actual: %v\n", i, tt.out, actual)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -532,20 +532,20 @@ func TestMaxCvss2Scores(t *testing.T) {
 | 
			
		||||
		{
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:        JVN,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss2Score:  8.2,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:          Jvn,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.2,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:        RedHat,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss2Score:  8.0,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.0,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:        NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:        NvdXML,
 | 
			
		||||
						Cvss2Score:  8.1,
 | 
			
		||||
						Cvss2Vector: "AV:N/AC:L/Au:N/C:N/I:N/A:P",
 | 
			
		||||
						// Severity is NIOT included in NVD
 | 
			
		||||
@@ -553,7 +553,7 @@ func TestMaxCvss2Scores(t *testing.T) {
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: CveContentCvss{
 | 
			
		||||
				Type: JVN,
 | 
			
		||||
				Type: Jvn,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS2,
 | 
			
		||||
					Score:    8.2,
 | 
			
		||||
@@ -567,8 +567,8 @@ func TestMaxCvss2Scores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					Ubuntu: {
 | 
			
		||||
						Type:     Ubuntu,
 | 
			
		||||
						Severity: "HIGH",
 | 
			
		||||
						Type:          Ubuntu,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -613,16 +613,16 @@ func TestCvss3Scores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:        RedHat,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss3Score:  8.0,
 | 
			
		||||
						Cvss3Vector: "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss3Severity: "HIGH",
 | 
			
		||||
						Cvss3Score:    8.0,
 | 
			
		||||
						Cvss3Vector:   "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:        NVD,
 | 
			
		||||
						Cvss3Score:  8.1,
 | 
			
		||||
						Cvss3Vector: "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
						// Severity is NIOT included in NVD
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:          NvdXML,
 | 
			
		||||
						Cvss2Score:    8.1,
 | 
			
		||||
						Cvss2Vector:   "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -661,10 +661,10 @@ func TestMaxCvss3Scores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:        RedHat,
 | 
			
		||||
						Severity:    "HIGH",
 | 
			
		||||
						Cvss3Score:  8.0,
 | 
			
		||||
						Cvss3Vector: "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss3Severity: "HIGH",
 | 
			
		||||
						Cvss3Score:    8.0,
 | 
			
		||||
						Cvss3Vector:   "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -708,8 +708,8 @@ func TestMaxCvssScores(t *testing.T) {
 | 
			
		||||
		{
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:       NvdXML,
 | 
			
		||||
						Cvss3Score: 7.0,
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
@@ -748,8 +748,8 @@ func TestMaxCvssScores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					Ubuntu: {
 | 
			
		||||
						Type:     Ubuntu,
 | 
			
		||||
						Severity: "HIGH",
 | 
			
		||||
						Type:          Ubuntu,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -768,17 +768,18 @@ func TestMaxCvssScores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					Ubuntu: {
 | 
			
		||||
						Type:     Ubuntu,
 | 
			
		||||
						Severity: "MEDIUM",
 | 
			
		||||
						Type:          Ubuntu,
 | 
			
		||||
						Cvss2Severity: "MEDIUM",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
						Cvss2Score: 7.0,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:          NvdXML,
 | 
			
		||||
						Cvss2Score:    7.0,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: CveContentCvss{
 | 
			
		||||
				Type: NVD,
 | 
			
		||||
				Type: NvdXML,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS2,
 | 
			
		||||
					Score:    7.0,
 | 
			
		||||
@@ -810,12 +811,13 @@ func TestMaxCvssScores(t *testing.T) {
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					Ubuntu: {
 | 
			
		||||
						Type:     Ubuntu,
 | 
			
		||||
						Severity: "MEDIUM",
 | 
			
		||||
						Type:          Ubuntu,
 | 
			
		||||
						Cvss2Severity: "MEDIUM",
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
						Cvss2Score: 4.0,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:          NvdXML,
 | 
			
		||||
						Cvss2Score:    4.0,
 | 
			
		||||
						Cvss2Severity: "MEDIUM",
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				DistroAdvisories: []DistroAdvisory{
 | 
			
		||||
@@ -825,7 +827,7 @@ func TestMaxCvssScores(t *testing.T) {
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: CveContentCvss{
 | 
			
		||||
				Type: NVD,
 | 
			
		||||
				Type: NvdXML,
 | 
			
		||||
				Value: Cvss{
 | 
			
		||||
					Type:     CVSS2,
 | 
			
		||||
					Score:    4,
 | 
			
		||||
@@ -861,18 +863,18 @@ func TestFormatMaxCvssScore(t *testing.T) {
 | 
			
		||||
		{
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:       JVN,
 | 
			
		||||
						Severity:   "HIGH",
 | 
			
		||||
						Cvss2Score: 8.3,
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:          Jvn,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.3,
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:       RedHat,
 | 
			
		||||
						Severity:   "HIGH",
 | 
			
		||||
						Cvss3Score: 8.0,
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss3Score:    8.0,
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:       NvdXML,
 | 
			
		||||
						Cvss2Score: 8.1,
 | 
			
		||||
						// Severity is NIOT included in NVD
 | 
			
		||||
					},
 | 
			
		||||
@@ -883,19 +885,20 @@ func TestFormatMaxCvssScore(t *testing.T) {
 | 
			
		||||
		{
 | 
			
		||||
			in: VulnInfo{
 | 
			
		||||
				CveContents: CveContents{
 | 
			
		||||
					JVN: {
 | 
			
		||||
						Type:       JVN,
 | 
			
		||||
						Severity:   "HIGH",
 | 
			
		||||
						Cvss2Score: 8.3,
 | 
			
		||||
					Jvn: {
 | 
			
		||||
						Type:          Jvn,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.3,
 | 
			
		||||
					},
 | 
			
		||||
					RedHat: {
 | 
			
		||||
						Type:       RedHat,
 | 
			
		||||
						Severity:   "HIGH",
 | 
			
		||||
						Cvss2Score: 8.0,
 | 
			
		||||
						Cvss3Score: 9.9,
 | 
			
		||||
						Type:          RedHat,
 | 
			
		||||
						Cvss2Severity: "HIGH",
 | 
			
		||||
						Cvss2Score:    8.0,
 | 
			
		||||
						Cvss3Severity: "HIGH",
 | 
			
		||||
						Cvss3Score:    9.9,
 | 
			
		||||
					},
 | 
			
		||||
					NVD: {
 | 
			
		||||
						Type:       NVD,
 | 
			
		||||
					NvdXML: {
 | 
			
		||||
						Type:       NvdXML,
 | 
			
		||||
						Cvss2Score: 8.1,
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -934,3 +937,100 @@ func TestSortPackageStatues(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestStorePackageStatueses(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		pkgstats PackageStatuses
 | 
			
		||||
		in       PackageStatus
 | 
			
		||||
		out      PackageStatuses
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			pkgstats: PackageStatuses{
 | 
			
		||||
				{Name: "a"},
 | 
			
		||||
				{Name: "b"},
 | 
			
		||||
			},
 | 
			
		||||
			in: PackageStatus{
 | 
			
		||||
				Name: "c",
 | 
			
		||||
			},
 | 
			
		||||
			out: PackageStatuses{
 | 
			
		||||
				{Name: "a"},
 | 
			
		||||
				{Name: "b"},
 | 
			
		||||
				{Name: "c"},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		out := tt.pkgstats.Store(tt.in)
 | 
			
		||||
		if ok := reflect.DeepEqual(tt.out, out); !ok {
 | 
			
		||||
			t.Errorf("\nexpected: %v\n  actual: %v\n", tt.out, out)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAppendIfMissing(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  Confidences
 | 
			
		||||
		arg Confidence
 | 
			
		||||
		out Confidences
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: Confidences{
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
			arg: CpeNameMatch,
 | 
			
		||||
			out: Confidences{
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: Confidences{
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
			arg: ChangelogExactMatch,
 | 
			
		||||
			out: Confidences{
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
				ChangelogExactMatch,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		tt.in.AppendIfMissing(tt.arg)
 | 
			
		||||
		if !reflect.DeepEqual(tt.in, tt.out) {
 | 
			
		||||
			t.Errorf("\nexpected: %v\n  actual: %v\n", tt.out, tt.in)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSortByConfiden(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  Confidences
 | 
			
		||||
		out Confidences
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: Confidences{
 | 
			
		||||
				OvalMatch,
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
			out: Confidences{
 | 
			
		||||
				OvalMatch,
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: Confidences{
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
				OvalMatch,
 | 
			
		||||
			},
 | 
			
		||||
			out: Confidences{
 | 
			
		||||
				OvalMatch,
 | 
			
		||||
				CpeNameMatch,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		act := tt.in.SortByConfident()
 | 
			
		||||
		if !reflect.DeepEqual(tt.out, act) {
 | 
			
		||||
			t.Errorf("\nexpected: %v\n  actual: %v\n", tt.out, act)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -21,7 +21,7 @@ import (
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	ovalmodels "github.com/kotakanbe/goval-dictionary/models"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Alpine is the struct of Alpine Linux
 | 
			
		||||
@@ -39,44 +39,36 @@ func NewAlpine() Alpine {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval returns scan result after updating CVE info by OVAL
 | 
			
		||||
func (o Alpine) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
func (o Alpine) FillWithOval(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	var relatedDefs ovalResult
 | 
			
		||||
	if o.isFetchViaHTTP() {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameViaHTTP(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(driver, r); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, defPacks := range relatedDefs.entries {
 | 
			
		||||
		o.update(r, defPacks)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
	return len(relatedDefs.entries), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o Alpine) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
	ovalContent := *o.convertToModel(&defPacks.def)
 | 
			
		||||
	cveID := defPacks.def.Advisory.Cves[0].CveID
 | 
			
		||||
	vinfo, ok := r.ScannedCves[cveID]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		util.Log.Debugf("%s is newly detected by OVAL", cveID)
 | 
			
		||||
		vinfo = models.VulnInfo{
 | 
			
		||||
			CveID:       cveID,
 | 
			
		||||
			Confidence:  models.OvalMatch,
 | 
			
		||||
			CveContents: models.NewCveContents(ovalContent),
 | 
			
		||||
			Confidences: []models.Confidence{models.OvalMatch},
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses(r.Family)
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses()
 | 
			
		||||
	vinfo.AffectedPackages.Sort()
 | 
			
		||||
	r.ScannedCves[cveID] = vinfo
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o Alpine) convertToModel(def *ovalmodels.Definition) *models.CveContent {
 | 
			
		||||
	return &models.CveContent{
 | 
			
		||||
		CveID: def.Advisory.Cves[0].CveID,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -21,6 +21,7 @@ import (
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	ovalmodels "github.com/kotakanbe/goval-dictionary/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -37,7 +38,7 @@ func (o DebianBase) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
		util.Log.Debugf("%s is newly detected by OVAL", defPacks.def.Debian.CveID)
 | 
			
		||||
		vinfo = models.VulnInfo{
 | 
			
		||||
			CveID:       defPacks.def.Debian.CveID,
 | 
			
		||||
			Confidence:  models.OvalMatch,
 | 
			
		||||
			Confidences: []models.Confidence{models.OvalMatch},
 | 
			
		||||
			CveContents: models.NewCveContents(ovalContent),
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
@@ -51,20 +52,28 @@ func (o DebianBase) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
				defPacks.def.Debian.CveID)
 | 
			
		||||
			cveContents = models.CveContents{}
 | 
			
		||||
		}
 | 
			
		||||
		if vinfo.Confidence.Score < models.OvalMatch.Score {
 | 
			
		||||
			vinfo.Confidence = models.OvalMatch
 | 
			
		||||
		}
 | 
			
		||||
		vinfo.Confidences.AppendIfMissing(models.OvalMatch)
 | 
			
		||||
		cveContents[ctype] = ovalContent
 | 
			
		||||
		vinfo.CveContents = cveContents
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// uniq(vinfo.PackNames + defPacks.actuallyAffectedPackNames)
 | 
			
		||||
	for _, pack := range vinfo.AffectedPackages {
 | 
			
		||||
		notFixedYet, _ := defPacks.actuallyAffectedPackNames[pack.Name]
 | 
			
		||||
		defPacks.actuallyAffectedPackNames[pack.Name] = notFixedYet
 | 
			
		||||
		defPacks.actuallyAffectedPackNames[pack.Name] = pack.NotFixedYet
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses(r.Family)
 | 
			
		||||
	// update notFixedYet of SrcPackage
 | 
			
		||||
	for binName := range defPacks.actuallyAffectedPackNames {
 | 
			
		||||
		if srcPack, ok := r.SrcPackages.FindByBinName(binName); ok {
 | 
			
		||||
			for _, p := range defPacks.def.AffectedPacks {
 | 
			
		||||
				if p.Name == srcPack.Name {
 | 
			
		||||
					defPacks.actuallyAffectedPackNames[binName] = p.NotFixedYet
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses()
 | 
			
		||||
	vinfo.AffectedPackages.Sort()
 | 
			
		||||
	r.ScannedCves[defPacks.def.Debian.CveID] = vinfo
 | 
			
		||||
}
 | 
			
		||||
@@ -80,11 +89,11 @@ func (o DebianBase) convertToModel(def *ovalmodels.Definition) *models.CveConten
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &models.CveContent{
 | 
			
		||||
		CveID:      def.Debian.CveID,
 | 
			
		||||
		Title:      def.Title,
 | 
			
		||||
		Summary:    def.Description,
 | 
			
		||||
		Severity:   def.Advisory.Severity,
 | 
			
		||||
		References: refs,
 | 
			
		||||
		CveID:         def.Debian.CveID,
 | 
			
		||||
		Title:         def.Title,
 | 
			
		||||
		Summary:       def.Description,
 | 
			
		||||
		Cvss2Severity: def.Advisory.Severity,
 | 
			
		||||
		References:    refs,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -105,17 +114,17 @@ func NewDebian() Debian {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval returns scan result after updating CVE info by OVAL
 | 
			
		||||
func (o Debian) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
func (o Debian) FillWithOval(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
 | 
			
		||||
	//Debian's uname gives both of kernel release(uname -r), version(kernel-image version)
 | 
			
		||||
	linuxImage := "linux-image-" + r.RunningKernel.Release
 | 
			
		||||
 | 
			
		||||
	// Add linux and set the version of running kernel to search OVAL.
 | 
			
		||||
	newVer := ""
 | 
			
		||||
	if p, ok := r.Packages[linuxImage]; ok {
 | 
			
		||||
		newVer = p.NewVersion
 | 
			
		||||
	}
 | 
			
		||||
	if r.Container.ContainerID == "" {
 | 
			
		||||
		newVer := ""
 | 
			
		||||
		if p, ok := r.Packages[linuxImage]; ok {
 | 
			
		||||
			newVer = p.NewVersion
 | 
			
		||||
		}
 | 
			
		||||
		r.Packages["linux"] = models.Package{
 | 
			
		||||
			Name:       "linux",
 | 
			
		||||
			Version:    r.RunningKernel.Version,
 | 
			
		||||
@@ -124,13 +133,13 @@ func (o Debian) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var relatedDefs ovalResult
 | 
			
		||||
	if o.isFetchViaHTTP() {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameViaHTTP(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(driver, r); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -159,7 +168,7 @@ func (o Debian) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
			vuln.CveContents[models.Debian] = cont
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return len(relatedDefs.entries), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Ubuntu is the interface for Debian OVAL
 | 
			
		||||
@@ -179,7 +188,7 @@ func NewUbuntu() Ubuntu {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval returns scan result after updating CVE info by OVAL
 | 
			
		||||
func (o Ubuntu) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
func (o Ubuntu) FillWithOval(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	ovalKernelImageNames := []string{
 | 
			
		||||
		"linux-aws",
 | 
			
		||||
		"linux-azure",
 | 
			
		||||
@@ -234,13 +243,13 @@ func (o Ubuntu) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var relatedDefs ovalResult
 | 
			
		||||
	if o.isFetchViaHTTP() {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameViaHTTP(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(driver, r); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -271,5 +280,5 @@ func (o Ubuntu) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
			vuln.CveContents[models.Ubuntu] = cont
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return len(relatedDefs.entries), nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										58
									
								
								oval/oval.go
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								oval/oval.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -23,22 +23,21 @@ import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	cnf "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	ovallog "github.com/kotakanbe/goval-dictionary/log"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Client is the interface of OVAL client.
 | 
			
		||||
type Client interface {
 | 
			
		||||
	CheckHTTPHealth() error
 | 
			
		||||
	FillWithOval(r *models.ScanResult) error
 | 
			
		||||
	FillWithOval(db.DB, *models.ScanResult) (int, error)
 | 
			
		||||
 | 
			
		||||
	// CheckIfOvalFetched checks if oval entries are in DB by family, release.
 | 
			
		||||
	CheckIfOvalFetched(string, string) (bool, error)
 | 
			
		||||
	CheckIfOvalFresh(string, string) (bool, error)
 | 
			
		||||
	CheckIfOvalFetched(db.DB, string, string) (bool, error)
 | 
			
		||||
	CheckIfOvalFresh(db.DB, string, string) (bool, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Base is a base struct
 | 
			
		||||
@@ -48,11 +47,11 @@ type Base struct {
 | 
			
		||||
 | 
			
		||||
// CheckHTTPHealth do health check
 | 
			
		||||
func (b Base) CheckHTTPHealth() error {
 | 
			
		||||
	if !b.isFetchViaHTTP() {
 | 
			
		||||
	if !cnf.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	url := fmt.Sprintf("%s/health", config.Conf.OvalDBURL)
 | 
			
		||||
	url := fmt.Sprintf("%s/health", cnf.Conf.OvalDict.URL)
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	resp, _, errs = gorequest.New().Get(url).End()
 | 
			
		||||
@@ -66,20 +65,9 @@ func (b Base) CheckHTTPHealth() error {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfOvalFetched checks if oval entries are in DB by family, release.
 | 
			
		||||
func (b Base) CheckIfOvalFetched(osFamily, release string) (fetched bool, err error) {
 | 
			
		||||
	ovallog.Initialize(config.Conf.LogDir)
 | 
			
		||||
	if !b.isFetchViaHTTP() {
 | 
			
		||||
		var ovaldb db.DB
 | 
			
		||||
		if ovaldb, err = db.NewDB(
 | 
			
		||||
			osFamily,
 | 
			
		||||
			config.Conf.OvalDBType,
 | 
			
		||||
			config.Conf.OvalDBPath,
 | 
			
		||||
			config.Conf.DebugSQL,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		defer ovaldb.CloseDB()
 | 
			
		||||
		count, err := ovaldb.CountDefs(osFamily, release)
 | 
			
		||||
func (b Base) CheckIfOvalFetched(driver db.DB, osFamily, release string) (fetched bool, err error) {
 | 
			
		||||
	if !cnf.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		count, err := driver.CountDefs(osFamily, release)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return false, fmt.Errorf("Failed to count OVAL defs: %s, %s, %v",
 | 
			
		||||
				osFamily, release, err)
 | 
			
		||||
@@ -87,7 +75,7 @@ func (b Base) CheckIfOvalFetched(osFamily, release string) (fetched bool, err er
 | 
			
		||||
		return 0 < count, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	url, _ := util.URLPathJoin(config.Conf.OvalDBURL, "count", osFamily, release)
 | 
			
		||||
	url, _ := util.URLPathJoin(cnf.Conf.OvalDict.URL, "count", osFamily, release)
 | 
			
		||||
	resp, body, errs := gorequest.New().Get(url).End()
 | 
			
		||||
	if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
		return false, fmt.Errorf("HTTP GET error: %v, url: %s, resp: %v",
 | 
			
		||||
@@ -102,23 +90,12 @@ func (b Base) CheckIfOvalFetched(osFamily, release string) (fetched bool, err er
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckIfOvalFresh checks if oval entries are fresh enough
 | 
			
		||||
func (b Base) CheckIfOvalFresh(osFamily, release string) (ok bool, err error) {
 | 
			
		||||
	ovallog.Initialize(config.Conf.LogDir)
 | 
			
		||||
func (b Base) CheckIfOvalFresh(driver db.DB, osFamily, release string) (ok bool, err error) {
 | 
			
		||||
	var lastModified time.Time
 | 
			
		||||
	if !b.isFetchViaHTTP() {
 | 
			
		||||
		var ovaldb db.DB
 | 
			
		||||
		if ovaldb, err = db.NewDB(
 | 
			
		||||
			osFamily,
 | 
			
		||||
			config.Conf.OvalDBType,
 | 
			
		||||
			config.Conf.OvalDBPath,
 | 
			
		||||
			config.Conf.DebugSQL,
 | 
			
		||||
		); err != nil {
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		defer ovaldb.CloseDB()
 | 
			
		||||
		lastModified = ovaldb.GetLastModified(osFamily, release)
 | 
			
		||||
	if !cnf.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		lastModified = driver.GetLastModified(osFamily, release)
 | 
			
		||||
	} else {
 | 
			
		||||
		url, _ := util.URLPathJoin(config.Conf.OvalDBURL, "lastmodified", osFamily, release)
 | 
			
		||||
		url, _ := util.URLPathJoin(cnf.Conf.OvalDict.URL, "lastmodified", osFamily, release)
 | 
			
		||||
		resp, body, errs := gorequest.New().Get(url).End()
 | 
			
		||||
		if 0 < len(errs) || resp == nil || resp.StatusCode != 200 {
 | 
			
		||||
			return false, fmt.Errorf("HTTP GET error: %v, url: %s, resp: %v",
 | 
			
		||||
@@ -141,8 +118,3 @@ func (b Base) CheckIfOvalFresh(osFamily, release string) (ok bool, err error) {
 | 
			
		||||
	util.Log.Infof("OVAL is fresh: %s %s ", osFamily, release)
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b Base) isFetchViaHTTP() bool {
 | 
			
		||||
	// Default value of OvalDBType is sqlite3
 | 
			
		||||
	return config.Conf.OvalDBURL != "" && config.Conf.OvalDBType == "sqlite3"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -25,6 +25,7 @@ import (
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	ovalmodels "github.com/kotakanbe/goval-dictionary/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -34,20 +35,20 @@ type RedHatBase struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval returns scan result after updating CVE info by OVAL
 | 
			
		||||
func (o RedHatBase) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
func (o RedHatBase) FillWithOval(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	var relatedDefs ovalResult
 | 
			
		||||
	if o.isFetchViaHTTP() {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameViaHTTP(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(driver, r); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, defPacks := range relatedDefs.entries {
 | 
			
		||||
		o.update(r, defPacks)
 | 
			
		||||
		nCVEs += o.update(r, defPacks)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, vuln := range r.ScannedCves {
 | 
			
		||||
@@ -64,7 +65,8 @@ func (o RedHatBase) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
	return nCVEs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var kernelRelatedPackNames = map[string]bool{
 | 
			
		||||
@@ -94,9 +96,11 @@ var kernelRelatedPackNames = map[string]bool{
 | 
			
		||||
	"kernel-tools":            true,
 | 
			
		||||
	"kernel-tools-libs":       true,
 | 
			
		||||
	"kernel-tools-libs-devel": true,
 | 
			
		||||
	"perf":                    true,
 | 
			
		||||
	"python-perf":             true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o RedHatBase) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
func (o RedHatBase) update(r *models.ScanResult, defPacks defPacks) (nCVEs int) {
 | 
			
		||||
	ctype := models.NewCveContentType(o.family)
 | 
			
		||||
	for _, cve := range defPacks.def.Advisory.Cves {
 | 
			
		||||
		ovalContent := *o.convertToModel(cve.CveID, &defPacks.def)
 | 
			
		||||
@@ -105,34 +109,43 @@ func (o RedHatBase) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
			util.Log.Debugf("%s is newly detected by OVAL", cve.CveID)
 | 
			
		||||
			vinfo = models.VulnInfo{
 | 
			
		||||
				CveID:       cve.CveID,
 | 
			
		||||
				Confidence:  models.OvalMatch,
 | 
			
		||||
				Confidences: models.Confidences{models.OvalMatch},
 | 
			
		||||
				CveContents: models.NewCveContents(ovalContent),
 | 
			
		||||
			}
 | 
			
		||||
			nCVEs++
 | 
			
		||||
		} else {
 | 
			
		||||
			cveContents := vinfo.CveContents
 | 
			
		||||
			if _, ok := vinfo.CveContents[ctype]; ok {
 | 
			
		||||
				util.Log.Debugf("%s OVAL will be overwritten", cve.CveID)
 | 
			
		||||
			if v, ok := vinfo.CveContents[ctype]; ok {
 | 
			
		||||
				if v.LastModified.After(ovalContent.LastModified) {
 | 
			
		||||
					util.Log.Debugf("%s, OvalID: %d ignroed: ",
 | 
			
		||||
						cve.CveID, defPacks.def.ID)
 | 
			
		||||
					continue
 | 
			
		||||
				} else {
 | 
			
		||||
					util.Log.Debugf("%s OVAL will be overwritten", cve.CveID)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Debugf("%s also detected by OVAL", cve.CveID)
 | 
			
		||||
				cveContents = models.CveContents{}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if vinfo.Confidence.Score < models.OvalMatch.Score {
 | 
			
		||||
				vinfo.Confidence = models.OvalMatch
 | 
			
		||||
			}
 | 
			
		||||
			vinfo.Confidences.AppendIfMissing(models.OvalMatch)
 | 
			
		||||
			cveContents[ctype] = ovalContent
 | 
			
		||||
			vinfo.CveContents = cveContents
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// uniq(vinfo.PackNames + defPacks.actuallyAffectedPackNames)
 | 
			
		||||
		for _, pack := range vinfo.AffectedPackages {
 | 
			
		||||
			notFixedYet, _ := defPacks.actuallyAffectedPackNames[pack.Name]
 | 
			
		||||
			defPacks.actuallyAffectedPackNames[pack.Name] = notFixedYet
 | 
			
		||||
			if nfy, ok := defPacks.actuallyAffectedPackNames[pack.Name]; !ok {
 | 
			
		||||
				defPacks.actuallyAffectedPackNames[pack.Name] = pack.NotFixedYet
 | 
			
		||||
			} else if nfy {
 | 
			
		||||
				defPacks.actuallyAffectedPackNames[pack.Name] = true
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		vinfo.AffectedPackages = defPacks.toPackStatuses(r.Family)
 | 
			
		||||
		vinfo.AffectedPackages = defPacks.toPackStatuses()
 | 
			
		||||
		vinfo.AffectedPackages.Sort()
 | 
			
		||||
		r.ScannedCves[cve.CveID] = vinfo
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o RedHatBase) convertToModel(cveID string, def *ovalmodels.Definition) *models.CveContent {
 | 
			
		||||
@@ -157,20 +170,32 @@ func (o RedHatBase) convertToModel(cveID string, def *ovalmodels.Definition) *mo
 | 
			
		||||
			severity = cve.Impact
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sev2, sev3 := "", ""
 | 
			
		||||
		if score2 != 0 {
 | 
			
		||||
			sev2 = severity
 | 
			
		||||
		}
 | 
			
		||||
		if score3 != 0 {
 | 
			
		||||
			sev3 = severity
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// CWE-ID in RedHat OVAL may have multiple cweIDs separated by space
 | 
			
		||||
		cwes := strings.Fields(cve.Cwe)
 | 
			
		||||
 | 
			
		||||
		return &models.CveContent{
 | 
			
		||||
			Type:         models.NewCveContentType(o.family),
 | 
			
		||||
			CveID:        cve.CveID,
 | 
			
		||||
			Title:        def.Title,
 | 
			
		||||
			Summary:      def.Description,
 | 
			
		||||
			Severity:     severity,
 | 
			
		||||
			Cvss2Score:   score2,
 | 
			
		||||
			Cvss2Vector:  vec2,
 | 
			
		||||
			Cvss3Score:   score3,
 | 
			
		||||
			Cvss3Vector:  vec3,
 | 
			
		||||
			References:   refs,
 | 
			
		||||
			CweID:        cve.Cwe,
 | 
			
		||||
			Published:    def.Advisory.Issued,
 | 
			
		||||
			LastModified: def.Advisory.Updated,
 | 
			
		||||
			Type:          models.NewCveContentType(o.family),
 | 
			
		||||
			CveID:         cve.CveID,
 | 
			
		||||
			Title:         def.Title,
 | 
			
		||||
			Summary:       def.Description,
 | 
			
		||||
			Cvss2Score:    score2,
 | 
			
		||||
			Cvss2Vector:   vec2,
 | 
			
		||||
			Cvss2Severity: sev2,
 | 
			
		||||
			Cvss3Score:    score3,
 | 
			
		||||
			Cvss3Vector:   vec3,
 | 
			
		||||
			Cvss3Severity: sev3,
 | 
			
		||||
			References:    refs,
 | 
			
		||||
			CweIDs:        cwes,
 | 
			
		||||
			Published:     def.Advisory.Issued,
 | 
			
		||||
			LastModified:  def.Advisory.Updated,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
@@ -199,7 +224,7 @@ func (o RedHatBase) parseCvss3(scoreVector string) (score float64, vector string
 | 
			
		||||
		if score, err = strconv.ParseFloat(ss[0], 64); err != nil {
 | 
			
		||||
			return 0, ""
 | 
			
		||||
		}
 | 
			
		||||
		return score, strings.Join(ss[1:], "/")
 | 
			
		||||
		return score, fmt.Sprintf("CVSS:3.0/%s", ss[1])
 | 
			
		||||
	}
 | 
			
		||||
	return 0, ""
 | 
			
		||||
}
 | 
			
		||||
@@ -236,7 +261,7 @@ func NewCentOS() CentOS {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Oracle is the interface for CentOS OVAL
 | 
			
		||||
// Oracle is the interface for Oracle OVAL
 | 
			
		||||
type Oracle struct {
 | 
			
		||||
	RedHatBase
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -72,7 +72,7 @@ func TestParseCvss3(t *testing.T) {
 | 
			
		||||
			in: "5.6/CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
			out: out{
 | 
			
		||||
				score:  5.6,
 | 
			
		||||
				vector: "AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
				vector: "CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								oval/suse.go
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								oval/suse.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -21,6 +21,7 @@ import (
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	ovalmodels "github.com/kotakanbe/goval-dictionary/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -40,15 +41,15 @@ func NewSUSE() SUSE {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval returns scan result after updating CVE info by OVAL
 | 
			
		||||
func (o SUSE) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
func (o SUSE) FillWithOval(driver db.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	var relatedDefs ovalResult
 | 
			
		||||
	if o.isFetchViaHTTP() {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameViaHTTP(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(r); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		if relatedDefs, err = getDefsByPackNameFromOvalDB(driver, r); err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, defPacks := range relatedDefs.entries {
 | 
			
		||||
@@ -61,7 +62,7 @@ func (o SUSE) FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
			vuln.CveContents[models.SUSE] = cont
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return len(relatedDefs.entries), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o SUSE) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
@@ -72,7 +73,7 @@ func (o SUSE) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
		util.Log.Debugf("%s is newly detected by OVAL", defPacks.def.Title)
 | 
			
		||||
		vinfo = models.VulnInfo{
 | 
			
		||||
			CveID:       defPacks.def.Title,
 | 
			
		||||
			Confidence:  models.OvalMatch,
 | 
			
		||||
			Confidences: models.Confidences{models.OvalMatch},
 | 
			
		||||
			CveContents: models.NewCveContents(ovalContent),
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
@@ -84,19 +85,16 @@ func (o SUSE) update(r *models.ScanResult, defPacks defPacks) {
 | 
			
		||||
			util.Log.Debugf("%s is also detected by OVAL", defPacks.def.Title)
 | 
			
		||||
			cveContents = models.CveContents{}
 | 
			
		||||
		}
 | 
			
		||||
		if vinfo.Confidence.Score < models.OvalMatch.Score {
 | 
			
		||||
			vinfo.Confidence = models.OvalMatch
 | 
			
		||||
		}
 | 
			
		||||
		vinfo.Confidences.AppendIfMissing(models.OvalMatch)
 | 
			
		||||
		cveContents[ctype] = ovalContent
 | 
			
		||||
		vinfo.CveContents = cveContents
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// uniq(vinfo.PackNames + defPacks.actuallyAffectedPackNames)
 | 
			
		||||
	for _, pack := range vinfo.AffectedPackages {
 | 
			
		||||
		notFixedYet, _ := defPacks.actuallyAffectedPackNames[pack.Name]
 | 
			
		||||
		defPacks.actuallyAffectedPackNames[pack.Name] = notFixedYet
 | 
			
		||||
		defPacks.actuallyAffectedPackNames[pack.Name] = pack.NotFixedYet
 | 
			
		||||
	}
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses(r.Family)
 | 
			
		||||
	vinfo.AffectedPackages = defPacks.toPackStatuses()
 | 
			
		||||
	vinfo.AffectedPackages.Sort()
 | 
			
		||||
	r.ScannedCves[defPacks.def.Title] = vinfo
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										50
									
								
								oval/util.go
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								oval/util.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -32,7 +32,6 @@ import (
 | 
			
		||||
	debver "github.com/knqyf263/go-deb-version"
 | 
			
		||||
	rpmver "github.com/knqyf263/go-rpm-version"
 | 
			
		||||
	"github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	ovallog "github.com/kotakanbe/goval-dictionary/log"
 | 
			
		||||
	ovalmodels "github.com/kotakanbe/goval-dictionary/models"
 | 
			
		||||
	"github.com/parnurzeal/gorequest"
 | 
			
		||||
)
 | 
			
		||||
@@ -48,7 +47,7 @@ type defPacks struct {
 | 
			
		||||
	actuallyAffectedPackNames map[string]bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (e defPacks) toPackStatuses(family string) (ps models.PackageStatuses) {
 | 
			
		||||
func (e defPacks) toPackStatuses() (ps models.PackageStatuses) {
 | 
			
		||||
	for name, notFixedYet := range e.actuallyAffectedPackNames {
 | 
			
		||||
		ps = append(ps, models.PackageStatus{
 | 
			
		||||
			Name:        name,
 | 
			
		||||
@@ -69,7 +68,7 @@ func (e *ovalResult) upsert(def ovalmodels.Definition, packName string, notFixed
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	e.entries = append(e.entries, defPacks{
 | 
			
		||||
		def: def,
 | 
			
		||||
		def:                       def,
 | 
			
		||||
		actuallyAffectedPackNames: map[string]bool{packName: notFixedYet},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
@@ -109,15 +108,14 @@ func getDefsByPackNameViaHTTP(r *models.ScanResult) (
 | 
			
		||||
				NewVersionRelease: pack.FormatVer(),
 | 
			
		||||
				isSrcPack:         false,
 | 
			
		||||
			}
 | 
			
		||||
			for _, pack := range r.SrcPackages {
 | 
			
		||||
				reqChan <- request{
 | 
			
		||||
					packName:        pack.Name,
 | 
			
		||||
					binaryPackNames: pack.BinaryNames,
 | 
			
		||||
					versionRelease:  pack.Version,
 | 
			
		||||
					isSrcPack:       true,
 | 
			
		||||
				}
 | 
			
		||||
		}
 | 
			
		||||
		for _, pack := range r.SrcPackages {
 | 
			
		||||
			reqChan <- request{
 | 
			
		||||
				packName:        pack.Name,
 | 
			
		||||
				binaryPackNames: pack.BinaryNames,
 | 
			
		||||
				versionRelease:  pack.Version,
 | 
			
		||||
				isSrcPack:       true,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
@@ -128,7 +126,7 @@ func getDefsByPackNameViaHTTP(r *models.ScanResult) (
 | 
			
		||||
			select {
 | 
			
		||||
			case req := <-reqChan:
 | 
			
		||||
				url, err := util.URLPathJoin(
 | 
			
		||||
					config.Conf.OvalDBURL,
 | 
			
		||||
					config.Conf.OvalDict.URL,
 | 
			
		||||
					"packs",
 | 
			
		||||
					r.Family,
 | 
			
		||||
					r.Release,
 | 
			
		||||
@@ -218,21 +216,7 @@ func httpGet(url string, req request, resChan chan<- response, errChan chan<- er
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getDefsByPackNameFromOvalDB(r *models.ScanResult) (relatedDefs ovalResult, err error) {
 | 
			
		||||
	ovallog.Initialize(config.Conf.LogDir)
 | 
			
		||||
	path := config.Conf.OvalDBURL
 | 
			
		||||
	if config.Conf.OvalDBType == "sqlite3" {
 | 
			
		||||
		path = config.Conf.OvalDBPath
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Debugf("Open oval-dictionary db (%s): %s", config.Conf.OvalDBType, path)
 | 
			
		||||
 | 
			
		||||
	var ovaldb db.DB
 | 
			
		||||
	if ovaldb, err = db.NewDB(r.Family, config.Conf.OvalDBType,
 | 
			
		||||
		path, config.Conf.DebugSQL); err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	defer ovaldb.CloseDB()
 | 
			
		||||
 | 
			
		||||
func getDefsByPackNameFromOvalDB(driver db.DB, r *models.ScanResult) (relatedDefs ovalResult, err error) {
 | 
			
		||||
	requests := []request{}
 | 
			
		||||
	for _, pack := range r.Packages {
 | 
			
		||||
		requests = append(requests, request{
 | 
			
		||||
@@ -252,9 +236,9 @@ func getDefsByPackNameFromOvalDB(r *models.ScanResult) (relatedDefs ovalResult,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, req := range requests {
 | 
			
		||||
		definitions, err := ovaldb.GetByPackName(r.Release, req.packName)
 | 
			
		||||
		definitions, err := driver.GetByPackName(r.Release, req.packName)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return relatedDefs, fmt.Errorf("Failed to get %s OVAL info by package name: %v", r.Family, err)
 | 
			
		||||
			return relatedDefs, fmt.Errorf("Failed to get %s OVAL info by package: %#v, err: %s", r.Family, req, err)
 | 
			
		||||
		}
 | 
			
		||||
		for _, def := range definitions {
 | 
			
		||||
			affected, notFixedYet := isOvalDefAffected(def, req, r.Family, r.RunningKernel)
 | 
			
		||||
@@ -319,8 +303,12 @@ func isOvalDefAffected(def ovalmodels.Definition, req request, family string, ru
 | 
			
		||||
				// Unable to judge whether fixed or not fixed of src package(Ubuntu, Debian)
 | 
			
		||||
				return true, false
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// `offline` or `fast` scan mode can't get a updatable version.
 | 
			
		||||
			// In these mode, the blow field was set empty.
 | 
			
		||||
			// Vuls can not judge fixed or unfixed.
 | 
			
		||||
			if req.NewVersionRelease == "" {
 | 
			
		||||
				return true, true
 | 
			
		||||
				return true, false
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// compare version: newVer vs oval
 | 
			
		||||
 
 | 
			
		||||
@@ -105,9 +105,8 @@ func TestUpsert(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
func TestDefpacksToPackStatuses(t *testing.T) {
 | 
			
		||||
	type in struct {
 | 
			
		||||
		dp     defPacks
 | 
			
		||||
		family string
 | 
			
		||||
		packs  models.Packages
 | 
			
		||||
		dp    defPacks
 | 
			
		||||
		packs models.Packages
 | 
			
		||||
	}
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in  in
 | 
			
		||||
@@ -116,7 +115,6 @@ func TestDefpacksToPackStatuses(t *testing.T) {
 | 
			
		||||
		// Ubuntu
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "ubuntu",
 | 
			
		||||
				dp: defPacks{
 | 
			
		||||
					def: ovalmodels.Definition{
 | 
			
		||||
						AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
@@ -154,7 +152,7 @@ func TestDefpacksToPackStatuses(t *testing.T) {
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		actual := tt.in.dp.toPackStatuses(tt.in.family)
 | 
			
		||||
		actual := tt.in.dp.toPackStatuses()
 | 
			
		||||
		sort.Slice(actual, func(i, j int) bool {
 | 
			
		||||
			return actual[i].Name < actual[j].Name
 | 
			
		||||
		})
 | 
			
		||||
@@ -321,7 +319,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// RedHat
 | 
			
		||||
		// 5 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -339,64 +337,16 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6_7.7",
 | 
			
		||||
					packName:          "b",
 | 
			
		||||
					isSrcPack:         false,
 | 
			
		||||
					versionRelease:    "0:1.2.3-45.el6_7.7",
 | 
			
		||||
					NewVersionRelease: "",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
				def: ovalmodels.Definition{
 | 
			
		||||
					AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6_7.8",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
				def: ovalmodels.Definition{
 | 
			
		||||
					AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6_7.9",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 6 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -423,6 +373,86 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
		},
 | 
			
		||||
		// 7 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
				def: ovalmodels.Definition{
 | 
			
		||||
					AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6_7.8",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 8 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
				def: ovalmodels.Definition{
 | 
			
		||||
					AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6_7.9",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 9 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
				def: ovalmodels.Definition{
 | 
			
		||||
					AffectedPacks: []ovalmodels.Package{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:          "b",
 | 
			
		||||
					isSrcPack:         false,
 | 
			
		||||
					versionRelease:    "0:1.2.3-45.el6_7.6",
 | 
			
		||||
					NewVersionRelease: "0:1.2.3-45.el6_7.7",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
		},
 | 
			
		||||
		// 10 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -449,6 +479,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 11 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -458,8 +489,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
							Name:        "a",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "b",
 | 
			
		||||
						{Name: "b",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
							Version:     "0:1.2.3-45.el6_7.8",
 | 
			
		||||
						},
 | 
			
		||||
@@ -475,6 +505,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 12 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -500,6 +531,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 13 RedHat
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "redhat",
 | 
			
		||||
@@ -525,7 +557,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// CentOS
 | 
			
		||||
		// 14 CentOS
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -543,14 +575,16 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				req: request{
 | 
			
		||||
					packName:       "b",
 | 
			
		||||
					isSrcPack:      false,
 | 
			
		||||
					versionRelease: "0:1.2.3-45.el6.centos.7",
 | 
			
		||||
					packName:          "b",
 | 
			
		||||
					isSrcPack:         false,
 | 
			
		||||
					versionRelease:    "0:1.2.3-45.el6.centos.7",
 | 
			
		||||
					NewVersionRelease: "",
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 15
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -576,6 +610,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 16
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -601,6 +636,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 17
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -627,6 +663,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
		},
 | 
			
		||||
		// 18
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -653,6 +690,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 19
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -679,6 +717,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 20
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -704,6 +743,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// 21
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -729,7 +769,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
			affected:    false,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		// TODO: If vuls support Scientific, replace "centos" below to "scientific".
 | 
			
		||||
		// 22
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
				family: "centos",
 | 
			
		||||
@@ -753,7 +793,7 @@ func TestIsOvalDefAffected(t *testing.T) {
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			affected:    true,
 | 
			
		||||
			notFixedYet: true,
 | 
			
		||||
			notFixedYet: false,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: in{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -67,9 +67,9 @@ func (w AzureBlobWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.FormatShortText {
 | 
			
		||||
		if c.Conf.FormatList {
 | 
			
		||||
			k := key + "_short.txt"
 | 
			
		||||
			b := []byte(formatShortPlainText(r))
 | 
			
		||||
			b := []byte(formatList(r))
 | 
			
		||||
			if err := createBlockBlob(cli, k, b); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
@@ -111,19 +111,19 @@ func CheckIfAzureContainerExists() error {
 | 
			
		||||
 | 
			
		||||
	found := false
 | 
			
		||||
	for _, con := range r.Containers {
 | 
			
		||||
		if con.Name == c.Conf.AzureContainer {
 | 
			
		||||
		if con.Name == c.Conf.Azure.ContainerName {
 | 
			
		||||
			found = true
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if !found {
 | 
			
		||||
		return fmt.Errorf("Container not found. Container: %s", c.Conf.AzureContainer)
 | 
			
		||||
		return fmt.Errorf("Container not found. Container: %s", c.Conf.Azure.ContainerName)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getBlobClient() (storage.BlobStorageClient, error) {
 | 
			
		||||
	api, err := storage.NewBasicClient(c.Conf.AzureAccount, c.Conf.AzureKey)
 | 
			
		||||
	api, err := storage.NewBasicClient(c.Conf.Azure.AccountName, c.Conf.Azure.AccountKey)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return storage.BlobStorageClient{}, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -136,14 +136,14 @@ func createBlockBlob(cli storage.BlobStorageClient, k string, b []byte) error {
 | 
			
		||||
		if b, err = gz(b); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		k = k + ".gz"
 | 
			
		||||
		k += ".gz"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ref := cli.GetContainerReference(c.Conf.AzureContainer)
 | 
			
		||||
	ref := cli.GetContainerReference(c.Conf.Azure.ContainerName)
 | 
			
		||||
	blob := ref.GetBlobReference(k)
 | 
			
		||||
	if err := blob.CreateBlockBlobFromReader(bytes.NewReader(b), nil); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to upload data to %s/%s, %s",
 | 
			
		||||
			c.Conf.AzureContainer, k, err)
 | 
			
		||||
			c.Conf.Azure.ContainerName, k, err)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										73
									
								
								report/chatwork.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								report/chatwork.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ChatWorkWriter send report to ChatWork
 | 
			
		||||
type ChatWorkWriter struct{}
 | 
			
		||||
 | 
			
		||||
func (w ChatWorkWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	conf := config.Conf.ChatWork
 | 
			
		||||
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		serverInfo := fmt.Sprintf("%s", r.ServerInfo())
 | 
			
		||||
		if err = chatWorkpostMessage(conf.Room, conf.APIToken, serverInfo); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, vinfo := range r.ScannedCves {
 | 
			
		||||
			maxCvss := vinfo.MaxCvssScore()
 | 
			
		||||
			severity := strings.ToUpper(maxCvss.Value.Severity)
 | 
			
		||||
			if severity == "" {
 | 
			
		||||
				severity = "?"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			message := fmt.Sprintf(`%s[info][title]"https://nvd.nist.gov/vuln/detail/%s" %s %s[/title]%s[/info]`,
 | 
			
		||||
				serverInfo,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				strconv.FormatFloat(maxCvss.Value.Score, 'f', 1, 64),
 | 
			
		||||
				severity,
 | 
			
		||||
				vinfo.Summaries(config.Conf.Lang, r.Family)[0].Value)
 | 
			
		||||
 | 
			
		||||
			if err = chatWorkpostMessage(conf.Room, conf.APIToken, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func chatWorkpostMessage(room, token, message string) error {
 | 
			
		||||
	uri := fmt.Sprintf("https://api.chatwork.com/v2/rooms/%s/messages=%s", room, token)
 | 
			
		||||
 | 
			
		||||
	payload := url.Values{
 | 
			
		||||
		"body": {message},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	reqs, err := http.NewRequest("POST", uri, strings.NewReader(payload.Encode()))
 | 
			
		||||
 | 
			
		||||
	reqs.Header.Add("X-ChatWorkToken", token)
 | 
			
		||||
	reqs.Header.Add("Content-Type", "application/x-www-form-urlencoded")
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	client := &http.Client{}
 | 
			
		||||
 | 
			
		||||
	resp, err := client.Do(reqs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer resp.Body.Close()
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								report/chatwork_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								report/chatwork_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
package report
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -28,10 +28,8 @@ import (
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	cveconfig "github.com/kotakanbe/go-cve-dictionary/config"
 | 
			
		||||
	cvedb "github.com/kotakanbe/go-cve-dictionary/db"
 | 
			
		||||
	cve "github.com/kotakanbe/go-cve-dictionary/models"
 | 
			
		||||
	log "github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// CveClient is api client of CVE disctionary service.
 | 
			
		||||
@@ -43,12 +41,12 @@ type cvedictClient struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api *cvedictClient) initialize() {
 | 
			
		||||
	api.baseURL = config.Conf.CveDBURL
 | 
			
		||||
	api.baseURL = config.Conf.CveDict.URL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) CheckHealth() error {
 | 
			
		||||
	if !api.isFetchViaHTTP() {
 | 
			
		||||
		util.Log.Debugf("get cve-dictionary from %s", config.Conf.CveDBType)
 | 
			
		||||
	if !config.Conf.CveDict.IsFetchViaHTTP() {
 | 
			
		||||
		util.Log.Debugf("get cve-dictionary from %s", config.Conf.CveDict.Type)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -70,12 +68,25 @@ type response struct {
 | 
			
		||||
	CveDetail cve.CveDetail
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) FetchCveDetails(cveIDs []string) (cveDetails []*cve.CveDetail, err error) {
 | 
			
		||||
	if !api.isFetchViaHTTP() {
 | 
			
		||||
		return api.FetchCveDetailsFromCveDB(cveIDs)
 | 
			
		||||
func (api cvedictClient) FetchCveDetails(driver cvedb.DB, cveIDs []string) (cveDetails []cve.CveDetail, err error) {
 | 
			
		||||
	if !config.Conf.CveDict.IsFetchViaHTTP() {
 | 
			
		||||
		for _, cveID := range cveIDs {
 | 
			
		||||
			cveDetail, err := driver.Get(cveID)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, fmt.Errorf("Failed to fetch CVE. err: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
			if len(cveDetail.CveID) == 0 {
 | 
			
		||||
				cveDetails = append(cveDetails, cve.CveDetail{
 | 
			
		||||
					CveID: cveID,
 | 
			
		||||
				})
 | 
			
		||||
			} else {
 | 
			
		||||
				cveDetails = append(cveDetails, *cveDetail)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	api.baseURL = config.Conf.CveDBURL
 | 
			
		||||
	api.baseURL = config.Conf.CveDict.URL
 | 
			
		||||
	reqChan := make(chan string, len(cveIDs))
 | 
			
		||||
	resChan := make(chan response, len(cveIDs))
 | 
			
		||||
	errChan := make(chan error, len(cveIDs))
 | 
			
		||||
@@ -112,54 +123,25 @@ func (api cvedictClient) FetchCveDetails(cveIDs []string) (cveDetails []*cve.Cve
 | 
			
		||||
		select {
 | 
			
		||||
		case res := <-resChan:
 | 
			
		||||
			if len(res.CveDetail.CveID) == 0 {
 | 
			
		||||
				cveDetails = append(cveDetails, &cve.CveDetail{
 | 
			
		||||
				cveDetails = append(cveDetails, cve.CveDetail{
 | 
			
		||||
					CveID: res.Key,
 | 
			
		||||
				})
 | 
			
		||||
			} else {
 | 
			
		||||
				cveDetails = append(cveDetails, &res.CveDetail)
 | 
			
		||||
				cveDetails = append(cveDetails, res.CveDetail)
 | 
			
		||||
			}
 | 
			
		||||
		case err := <-errChan:
 | 
			
		||||
			errs = append(errs, err)
 | 
			
		||||
		case <-timeout:
 | 
			
		||||
			return []*cve.CveDetail{}, fmt.Errorf("Timeout Fetching CVE")
 | 
			
		||||
			return nil, fmt.Errorf("Timeout Fetching CVE")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(errs) != 0 {
 | 
			
		||||
		return []*cve.CveDetail{},
 | 
			
		||||
		return nil,
 | 
			
		||||
			fmt.Errorf("Failed to fetch CVE. err: %v", errs)
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) FetchCveDetailsFromCveDB(cveIDs []string) (cveDetails []*cve.CveDetail, err error) {
 | 
			
		||||
	util.Log.Debugf("open cve-dictionary db (%s)", config.Conf.CveDBType)
 | 
			
		||||
	cveconfig.Conf.DBType = config.Conf.CveDBType
 | 
			
		||||
	if config.Conf.CveDBType == "sqlite3" {
 | 
			
		||||
		cveconfig.Conf.DBPath = config.Conf.CveDBPath
 | 
			
		||||
	} else {
 | 
			
		||||
		cveconfig.Conf.DBPath = config.Conf.CveDBURL
 | 
			
		||||
	}
 | 
			
		||||
	cveconfig.Conf.DebugSQL = config.Conf.DebugSQL
 | 
			
		||||
 | 
			
		||||
	var driver cvedb.DB
 | 
			
		||||
	if driver, err = cvedb.NewDB(cveconfig.Conf.DBType, cveconfig.Conf.DBPath, cveconfig.Conf.DebugSQL); err != nil {
 | 
			
		||||
		log.Error(err)
 | 
			
		||||
		return []*cve.CveDetail{}, fmt.Errorf("Failed to New DB. err: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, cveID := range cveIDs {
 | 
			
		||||
		cveDetail := driver.Get(cveID)
 | 
			
		||||
		if len(cveDetail.CveID) == 0 {
 | 
			
		||||
			cveDetails = append(cveDetails, &cve.CveDetail{
 | 
			
		||||
				CveID: cveID,
 | 
			
		||||
			})
 | 
			
		||||
		} else {
 | 
			
		||||
			cveDetails = append(cveDetails, cveDetail)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) httpGet(key, url string, resChan chan<- response, errChan chan<- error) {
 | 
			
		||||
	var body string
 | 
			
		||||
	var errs []error
 | 
			
		||||
@@ -194,36 +176,22 @@ func (api cvedictClient) httpGet(key, url string, resChan chan<- response, errCh
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type responseGetCveDetailByCpeName struct {
 | 
			
		||||
	CpeName    string
 | 
			
		||||
	CveDetails []cve.CveDetail
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) isFetchViaHTTP() bool {
 | 
			
		||||
	// Default value of CveDBType is sqlite3
 | 
			
		||||
	if config.Conf.CveDBURL != "" && config.Conf.CveDBType == "sqlite3" {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) FetchCveDetailsByCpeName(cpeName string) ([]*cve.CveDetail, error) {
 | 
			
		||||
	if api.isFetchViaHTTP() {
 | 
			
		||||
		api.baseURL = config.Conf.CveDBURL
 | 
			
		||||
func (api cvedictClient) FetchCveDetailsByCpeName(driver cvedb.DB, cpeName string) ([]cve.CveDetail, error) {
 | 
			
		||||
	if config.Conf.CveDict.IsFetchViaHTTP() {
 | 
			
		||||
		api.baseURL = config.Conf.CveDict.URL
 | 
			
		||||
		url, err := util.URLPathJoin(api.baseURL, "cpes")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return []*cve.CveDetail{}, err
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		query := map[string]string{"name": cpeName}
 | 
			
		||||
		util.Log.Debugf("HTTP Request to %s, query: %#v", url, query)
 | 
			
		||||
		return api.httpPost(cpeName, url, query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return api.FetchCveDetailsByCpeNameFromDB(cpeName)
 | 
			
		||||
	return driver.GetByCpeURI(cpeName)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) httpPost(key, url string, query map[string]string) ([]*cve.CveDetail, error) {
 | 
			
		||||
func (api cvedictClient) httpPost(key, url string, query map[string]string) ([]cve.CveDetail, error) {
 | 
			
		||||
	var body string
 | 
			
		||||
	var errs []error
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
@@ -244,33 +212,13 @@ func (api cvedictClient) httpPost(key, url string, query map[string]string) ([]*
 | 
			
		||||
	}
 | 
			
		||||
	err := backoff.RetryNotify(f, backoff.NewExponentialBackOff(), notify)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return []*cve.CveDetail{}, fmt.Errorf("HTTP Error %s", err)
 | 
			
		||||
		return nil, fmt.Errorf("HTTP Error %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cveDetails := []*cve.CveDetail{}
 | 
			
		||||
	cveDetails := []cve.CveDetail{}
 | 
			
		||||
	if err := json.Unmarshal([]byte(body), &cveDetails); err != nil {
 | 
			
		||||
		return []*cve.CveDetail{},
 | 
			
		||||
		return nil,
 | 
			
		||||
			fmt.Errorf("Failed to Unmarshall. body: %s, err: %s", body, err)
 | 
			
		||||
	}
 | 
			
		||||
	return cveDetails, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (api cvedictClient) FetchCveDetailsByCpeNameFromDB(cpeName string) (cveDetails []*cve.CveDetail, err error) {
 | 
			
		||||
	util.Log.Debugf("open cve-dictionary db (%s)", config.Conf.CveDBType)
 | 
			
		||||
	cveconfig.Conf.DBType = config.Conf.CveDBType
 | 
			
		||||
	if config.Conf.CveDBType == "sqlite3" {
 | 
			
		||||
		cveconfig.Conf.DBPath = config.Conf.CveDBPath
 | 
			
		||||
	} else {
 | 
			
		||||
		cveconfig.Conf.DBPath = config.Conf.CveDBURL
 | 
			
		||||
	}
 | 
			
		||||
	cveconfig.Conf.DebugSQL = config.Conf.DebugSQL
 | 
			
		||||
 | 
			
		||||
	var driver cvedb.DB
 | 
			
		||||
	if driver, err = cvedb.NewDB(cveconfig.Conf.DBType, cveconfig.Conf.DBPath, cveconfig.Conf.DebugSQL); err != nil {
 | 
			
		||||
		log.Error(err)
 | 
			
		||||
		return []*cve.CveDetail{}, fmt.Errorf("Failed to New DB. err: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Opening DB (%s).", driver.Name())
 | 
			
		||||
	return driver.GetByCpeName(cpeName), nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										188
									
								
								report/db_client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								report/db_client.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,188 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	gostdb "github.com/knqyf263/gost/db"
 | 
			
		||||
	cvedb "github.com/kotakanbe/go-cve-dictionary/db"
 | 
			
		||||
	ovaldb "github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	exploitdb "github.com/mozqnet/go-exploitdb/db"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// DBClient is a dictionarie's db client for reporting
 | 
			
		||||
type DBClient struct {
 | 
			
		||||
	CveDB     cvedb.DB
 | 
			
		||||
	OvalDB    ovaldb.DB
 | 
			
		||||
	GostDB    gostdb.DB
 | 
			
		||||
	ExploitDB exploitdb.DB
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DBClientConf has a configuration of Vulnerability DBs
 | 
			
		||||
type DBClientConf struct {
 | 
			
		||||
	CveDictCnf  config.GoCveDictConf
 | 
			
		||||
	OvalDictCnf config.GovalDictConf
 | 
			
		||||
	GostCnf     config.GostConf
 | 
			
		||||
	ExploitCnf  config.ExploitConf
 | 
			
		||||
	DebugSQL    bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewDBClient returns db clients
 | 
			
		||||
func NewDBClient(cnf DBClientConf) (dbclient *DBClient, locked bool, err error) {
 | 
			
		||||
	cveDriver, locked, err := NewCveDB(cnf)
 | 
			
		||||
	if locked {
 | 
			
		||||
		return nil, true, fmt.Errorf("CveDB is locked: %s",
 | 
			
		||||
			cnf.OvalDictCnf.SQLite3Path)
 | 
			
		||||
	} else if err != nil {
 | 
			
		||||
		return nil, locked, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ovaldb, locked, err := NewOvalDB(cnf)
 | 
			
		||||
	if locked {
 | 
			
		||||
		return nil, true, fmt.Errorf("OvalDB is locked: %s",
 | 
			
		||||
			cnf.OvalDictCnf.SQLite3Path)
 | 
			
		||||
	} else if err != nil {
 | 
			
		||||
		util.Log.Warnf("Unable to use OvalDB: %s, err: %s",
 | 
			
		||||
			cnf.OvalDictCnf.SQLite3Path, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	gostdb, locked, err := NewGostDB(cnf)
 | 
			
		||||
	if locked {
 | 
			
		||||
		return nil, true, fmt.Errorf("gostDB is locked: %s",
 | 
			
		||||
			cnf.GostCnf.SQLite3Path)
 | 
			
		||||
	} else if err != nil {
 | 
			
		||||
		util.Log.Warnf("Unable to use gostDB: %s, err: %s",
 | 
			
		||||
			cnf.GostCnf.SQLite3Path, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	exploitdb, locked, err := NewExploitDB(cnf)
 | 
			
		||||
	if locked {
 | 
			
		||||
		return nil, true, fmt.Errorf("exploitDB is locked: %s",
 | 
			
		||||
			cnf.ExploitCnf.SQLite3Path)
 | 
			
		||||
	} else if err != nil {
 | 
			
		||||
		util.Log.Warnf("Unable to use exploitDB: %s, err: %s",
 | 
			
		||||
			cnf.ExploitCnf.SQLite3Path, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &DBClient{
 | 
			
		||||
		CveDB:     cveDriver,
 | 
			
		||||
		OvalDB:    ovaldb,
 | 
			
		||||
		GostDB:    gostdb,
 | 
			
		||||
		ExploitDB: exploitdb,
 | 
			
		||||
	}, false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewCveDB returns cve db client
 | 
			
		||||
func NewCveDB(cnf DBClientConf) (driver cvedb.DB, locked bool, err error) {
 | 
			
		||||
	if config.Conf.CveDict.IsFetchViaHTTP() {
 | 
			
		||||
		return nil, false, nil
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Debugf("open cve-dictionary db (%s)", cnf.CveDictCnf.Type)
 | 
			
		||||
	path := cnf.CveDictCnf.URL
 | 
			
		||||
	if cnf.CveDictCnf.Type == "sqlite3" {
 | 
			
		||||
		path = cnf.CveDictCnf.SQLite3Path
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Open cve-dictionary db (%s): %s", cnf.CveDictCnf.Type, path)
 | 
			
		||||
	driver, locked, err = cvedb.NewDB(cnf.CveDictCnf.Type, path, cnf.DebugSQL)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err = fmt.Errorf("Failed to init CVE DB. err: %s, path: %s", err, path)
 | 
			
		||||
		return nil, locked, err
 | 
			
		||||
	}
 | 
			
		||||
	return driver, false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewOvalDB returns oval db client
 | 
			
		||||
func NewOvalDB(cnf DBClientConf) (driver ovaldb.DB, locked bool, err error) {
 | 
			
		||||
	if config.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		return nil, false, nil
 | 
			
		||||
	}
 | 
			
		||||
	path := cnf.OvalDictCnf.URL
 | 
			
		||||
	if cnf.OvalDictCnf.Type == "sqlite3" {
 | 
			
		||||
		path = cnf.OvalDictCnf.SQLite3Path
 | 
			
		||||
 | 
			
		||||
		if _, err := os.Stat(path); os.IsNotExist(err) {
 | 
			
		||||
			util.Log.Warnf("--ovaldb-path=%s is not found. It's recommended to use OVAL to improve scanning accuracy. For details, see https://github.com/kotakanbe/goval-dictionary#usage", path)
 | 
			
		||||
			return nil, false, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Open oval-dictionary db (%s): %s", cnf.OvalDictCnf.Type, path)
 | 
			
		||||
	driver, locked, err = ovaldb.NewDB("", cnf.OvalDictCnf.Type, path, cnf.DebugSQL)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		err = fmt.Errorf("Failed to new OVAL DB. err: %s", err)
 | 
			
		||||
		if locked {
 | 
			
		||||
			return nil, true, err
 | 
			
		||||
		}
 | 
			
		||||
		return nil, false, err
 | 
			
		||||
	}
 | 
			
		||||
	return driver, false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewGostDB returns db client for Gost
 | 
			
		||||
func NewGostDB(cnf DBClientConf) (driver gostdb.DB, locked bool, err error) {
 | 
			
		||||
	if config.Conf.Gost.IsFetchViaHTTP() {
 | 
			
		||||
		return nil, false, nil
 | 
			
		||||
	}
 | 
			
		||||
	path := cnf.GostCnf.URL
 | 
			
		||||
	if cnf.GostCnf.Type == "sqlite3" {
 | 
			
		||||
		path = cnf.GostCnf.SQLite3Path
 | 
			
		||||
 | 
			
		||||
		if _, err := os.Stat(path); os.IsNotExist(err) {
 | 
			
		||||
			util.Log.Warnf("--gostdb-path=%s is not found. If the scan target server is Debian, RHEL or CentOS, it's recommended to use gost to improve scanning accuracy. To use gost database, see https://github.com/knqyf263/gost#fetch-redhat", path)
 | 
			
		||||
			return nil, false, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Open gost db (%s): %s", cnf.GostCnf.Type, path)
 | 
			
		||||
	if driver, locked, err = gostdb.NewDB(cnf.GostCnf.Type, path, cnf.DebugSQL); err != nil {
 | 
			
		||||
		if locked {
 | 
			
		||||
			util.Log.Errorf("gostDB is locked: %s", err)
 | 
			
		||||
			return nil, true, err
 | 
			
		||||
		}
 | 
			
		||||
		return nil, false, err
 | 
			
		||||
	}
 | 
			
		||||
	return driver, false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewExploitDB returns db client for Exploit
 | 
			
		||||
func NewExploitDB(cnf DBClientConf) (driver exploitdb.DB, locked bool, err error) {
 | 
			
		||||
	if config.Conf.Exploit.IsFetchViaHTTP() {
 | 
			
		||||
		return nil, false, nil
 | 
			
		||||
	}
 | 
			
		||||
	path := cnf.ExploitCnf.URL
 | 
			
		||||
	if cnf.ExploitCnf.Type == "sqlite3" {
 | 
			
		||||
		path = cnf.ExploitCnf.SQLite3Path
 | 
			
		||||
 | 
			
		||||
		if _, err := os.Stat(path); os.IsNotExist(err) {
 | 
			
		||||
			util.Log.Warnf("--exploitdb-path=%s is not found. It's recommended to use exploit to improve scanning accuracy. To use exploit db database, see https://github.com/mozqnet/go-exploitdb", path)
 | 
			
		||||
			return nil, false, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Open exploit db (%s): %s", cnf.ExploitCnf.Type, path)
 | 
			
		||||
	if driver, locked, err = exploitdb.NewDB(cnf.ExploitCnf.Type, path, cnf.DebugSQL); err != nil {
 | 
			
		||||
		if locked {
 | 
			
		||||
			util.Log.Errorf("exploitDB is locked: %s", err)
 | 
			
		||||
			return nil, true, err
 | 
			
		||||
		}
 | 
			
		||||
		return nil, false, err
 | 
			
		||||
	}
 | 
			
		||||
	return driver, false, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CloseDB close dbs
 | 
			
		||||
func (d DBClient) CloseDB() {
 | 
			
		||||
	if d.CveDB != nil {
 | 
			
		||||
		if err := d.CveDB.CloseDB(); err != nil {
 | 
			
		||||
			util.Log.Errorf("Failed to close DB: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if d.OvalDB != nil {
 | 
			
		||||
		if err := d.OvalDB.CloseDB(); err != nil {
 | 
			
		||||
			util.Log.Errorf("Failed to close DB: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -58,7 +58,11 @@ func (w EMailWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
					r.ServerInfo(),
 | 
			
		||||
					r.ScannedCves.FormatCveSummary())
 | 
			
		||||
			}
 | 
			
		||||
			message = formatFullPlainText(r)
 | 
			
		||||
			if conf.FormatList {
 | 
			
		||||
				message = formatList(r)
 | 
			
		||||
			} else {
 | 
			
		||||
				message = formatFullPlainText(r)
 | 
			
		||||
			}
 | 
			
		||||
			if err := sender.Send(subject, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										74
									
								
								report/hipchat.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								report/hipchat.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,74 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// HipChatWriter send report to HipChat
 | 
			
		||||
type HipChatWriter struct{}
 | 
			
		||||
 | 
			
		||||
func (w HipChatWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	conf := config.Conf.HipChat
 | 
			
		||||
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		serverInfo := fmt.Sprintf("%s", r.ServerInfo())
 | 
			
		||||
		if err = postMessage(conf.Room, conf.AuthToken, serverInfo); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, vinfo := range r.ScannedCves {
 | 
			
		||||
			maxCvss := vinfo.MaxCvssScore()
 | 
			
		||||
			severity := strings.ToUpper(maxCvss.Value.Severity)
 | 
			
		||||
			if severity == "" {
 | 
			
		||||
				severity = "?"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			message := fmt.Sprintf(`<a href="https://nvd.nist.gov/vuln/detail\%s"> %s </a> <br/>%s (%s)<br/>%s`,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				strconv.FormatFloat(maxCvss.Value.Score, 'f', 1, 64),
 | 
			
		||||
				severity,
 | 
			
		||||
				vinfo.Summaries(config.Conf.Lang, r.Family)[0].Value,
 | 
			
		||||
			)
 | 
			
		||||
 | 
			
		||||
			if err = postMessage(conf.Room, conf.AuthToken, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func postMessage(room, token, message string) error {
 | 
			
		||||
	uri := fmt.Sprintf("https://api.hipchat.com/v2/room/%s/notification?auth_token=%s", room, token)
 | 
			
		||||
 | 
			
		||||
	payload := url.Values{
 | 
			
		||||
		"color":          {"purple"},
 | 
			
		||||
		"message_format": {"html"},
 | 
			
		||||
		"message":        {message},
 | 
			
		||||
	}
 | 
			
		||||
	reqs, err := http.NewRequest("POST", uri, strings.NewReader(payload.Encode()))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	reqs.Header.Add("Content-Type", "application/x-www-form-urlencoded")
 | 
			
		||||
 | 
			
		||||
	client := &http.Client{}
 | 
			
		||||
 | 
			
		||||
	resp, err := client.Do(reqs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer resp.Body.Close()
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								report/hipchat_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								report/hipchat_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
package report
 | 
			
		||||
							
								
								
									
										62
									
								
								report/http.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								report/http.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
/* 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 report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/pkg/errors"
 | 
			
		||||
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// HTTPRequestWriter writes results to HTTP request
 | 
			
		||||
type HTTPRequestWriter struct{}
 | 
			
		||||
 | 
			
		||||
// Write sends results as HTTP response
 | 
			
		||||
func (w HTTPRequestWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		b := new(bytes.Buffer)
 | 
			
		||||
		json.NewEncoder(b).Encode(r)
 | 
			
		||||
		_, err = http.Post(c.Conf.HTTP.URL, "application/json; charset=utf-8", b)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HTTPResponseWriter writes results to HTTP response
 | 
			
		||||
type HTTPResponseWriter struct {
 | 
			
		||||
	Writer http.ResponseWriter
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Write sends results as HTTP response
 | 
			
		||||
func (w HTTPResponseWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	res, err := json.Marshal(rs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.Wrap(err, "Failed to marshal scah results")
 | 
			
		||||
	}
 | 
			
		||||
	w.Writer.Header().Set("Content-Type", "application/json")
 | 
			
		||||
	_, err = w.Writer.Write(res)
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -72,7 +72,7 @@ func (w LocalFileWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.FormatShortText {
 | 
			
		||||
		if c.Conf.FormatList {
 | 
			
		||||
			var p string
 | 
			
		||||
			if c.Conf.Diff {
 | 
			
		||||
				p = path + "_short_diff.txt"
 | 
			
		||||
@@ -81,7 +81,7 @@ func (w LocalFileWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := writeFile(
 | 
			
		||||
				p, []byte(formatShortPlainText(r)), 0600); err != nil {
 | 
			
		||||
				p, []byte(formatList(r)), 0600); err != nil {
 | 
			
		||||
				return fmt.Errorf(
 | 
			
		||||
					"Failed to write text files. path: %s, err: %s", p, err)
 | 
			
		||||
			}
 | 
			
		||||
@@ -129,13 +129,7 @@ func writeFile(path string, data []byte, perm os.FileMode) error {
 | 
			
		||||
		if data, err = gz(data); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		path = path + ".gz"
 | 
			
		||||
		path += ".gz"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := ioutil.WriteFile(
 | 
			
		||||
		path, []byte(data), perm); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
	return ioutil.WriteFile(path, []byte(data), perm)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										583
									
								
								report/report.go
									
									
									
									
									
								
							
							
						
						
									
										583
									
								
								report/report.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -18,13 +18,31 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/BurntSushi/toml"
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/contrib/owasp-dependency-check/parser"
 | 
			
		||||
	"github.com/future-architect/vuls/cwe"
 | 
			
		||||
	"github.com/future-architect/vuls/exploit"
 | 
			
		||||
	"github.com/future-architect/vuls/github"
 | 
			
		||||
	"github.com/future-architect/vuls/gost"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/oval"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/hashicorp/uuid"
 | 
			
		||||
	gostdb "github.com/knqyf263/gost/db"
 | 
			
		||||
	cvedb "github.com/kotakanbe/go-cve-dictionary/db"
 | 
			
		||||
	ovaldb "github.com/kotakanbe/goval-dictionary/db"
 | 
			
		||||
	exploitdb "github.com/mozqnet/go-exploitdb/db"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -33,16 +51,52 @@ const (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// FillCveInfos fills CVE Detailed Information
 | 
			
		||||
func FillCveInfos(rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
 | 
			
		||||
	var filled []models.ScanResult
 | 
			
		||||
func FillCveInfos(dbclient DBClient, rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
 | 
			
		||||
	var filledResults []models.ScanResult
 | 
			
		||||
	reportedAt := time.Now()
 | 
			
		||||
	hostname, _ := os.Hostname()
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		if c.Conf.RefreshCve || needToRefreshCve(r) {
 | 
			
		||||
			if err := FillCveInfo(&r); err != nil {
 | 
			
		||||
			if ovalSupported(&r) {
 | 
			
		||||
				r.ScannedCves = models.VulnInfos{}
 | 
			
		||||
			}
 | 
			
		||||
			cpeURIs := []string{}
 | 
			
		||||
			if len(r.Container.ContainerID) == 0 {
 | 
			
		||||
				cpeURIs = c.Conf.Servers[r.ServerName].CpeNames
 | 
			
		||||
				owaspDCXMLPath := c.Conf.Servers[r.ServerName].OwaspDCXMLPath
 | 
			
		||||
				if owaspDCXMLPath != "" {
 | 
			
		||||
					cpes, err := parser.Parse(owaspDCXMLPath)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						return nil, fmt.Errorf("Failed to read OWASP Dependency Check XML: %s, %s, %s",
 | 
			
		||||
							r.ServerName, owaspDCXMLPath, err)
 | 
			
		||||
					}
 | 
			
		||||
					cpeURIs = append(cpeURIs, cpes...)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				if s, ok := c.Conf.Servers[r.ServerName]; ok {
 | 
			
		||||
					if con, ok := s.Containers[r.Container.Name]; ok {
 | 
			
		||||
						cpeURIs = con.Cpes
 | 
			
		||||
						owaspDCXMLPath := con.OwaspDCXMLPath
 | 
			
		||||
						if owaspDCXMLPath != "" {
 | 
			
		||||
							cpes, err := parser.Parse(owaspDCXMLPath)
 | 
			
		||||
							if err != nil {
 | 
			
		||||
								return nil, fmt.Errorf("Failed to read OWASP Dependency Check XML: %s, %s, %s",
 | 
			
		||||
									r.ServerInfo(), owaspDCXMLPath, err)
 | 
			
		||||
							}
 | 
			
		||||
							cpeURIs = append(cpeURIs, cpes...)
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if err := FillCveInfo(dbclient, &r, cpeURIs); err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			r.Lang = c.Conf.Lang
 | 
			
		||||
			r.ReportedAt = reportedAt
 | 
			
		||||
			r.ReportedVersion = c.Version
 | 
			
		||||
			r.ReportedRevision = c.Revision
 | 
			
		||||
			r.ReportedBy = hostname
 | 
			
		||||
			r.Config.Report = c.Conf
 | 
			
		||||
			r.Config.Report.Servers = map[string]c.ServerInfo{
 | 
			
		||||
				r.ServerName: c.Conf.Servers[r.ServerName],
 | 
			
		||||
@@ -50,37 +104,38 @@ func FillCveInfos(rs []models.ScanResult, dir string) ([]models.ScanResult, erro
 | 
			
		||||
			if err := overwriteJSONFile(dir, r); err != nil {
 | 
			
		||||
				return nil, fmt.Errorf("Failed to write JSON: %s", err)
 | 
			
		||||
			}
 | 
			
		||||
			filled = append(filled, r)
 | 
			
		||||
			filledResults = append(filledResults, r)
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Debugf("No need to refresh")
 | 
			
		||||
			filled = append(filled, r)
 | 
			
		||||
			filledResults = append(filledResults, r)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.Diff {
 | 
			
		||||
		previous, err := loadPrevious(filled)
 | 
			
		||||
		prevs, err := loadPrevious(filledResults)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		diff, err := diff(filled, previous)
 | 
			
		||||
		diff, err := diff(filledResults, prevs)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		filled = []models.ScanResult{}
 | 
			
		||||
		filledResults = []models.ScanResult{}
 | 
			
		||||
		for _, r := range diff {
 | 
			
		||||
			if err := fillCveDetail(&r); err != nil {
 | 
			
		||||
			if err := fillCveDetail(dbclient.CveDB, &r); err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			filled = append(filled, r)
 | 
			
		||||
			filledResults = append(filledResults, r)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	filtered := []models.ScanResult{}
 | 
			
		||||
	for _, r := range filled {
 | 
			
		||||
	for _, r := range filledResults {
 | 
			
		||||
		r = r.FilterByCvssOver(c.Conf.CvssScoreOver)
 | 
			
		||||
		r = r.FilterIgnoreCves(c.Conf.Servers[r.ServerName].IgnoreCves)
 | 
			
		||||
		r = r.FilterIgnoreCves()
 | 
			
		||||
		r = r.FilterUnfixed()
 | 
			
		||||
		r = r.FilterIgnorePkgs()
 | 
			
		||||
		if c.Conf.IgnoreUnscoredCves {
 | 
			
		||||
			r.ScannedCves = r.ScannedCves.FindScoredVulns()
 | 
			
		||||
		}
 | 
			
		||||
@@ -90,48 +145,96 @@ func FillCveInfos(rs []models.ScanResult, dir string) ([]models.ScanResult, erro
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillCveInfo fill scanResult with cve info.
 | 
			
		||||
func FillCveInfo(r *models.ScanResult) error {
 | 
			
		||||
func FillCveInfo(dbclient DBClient, r *models.ScanResult, cpeURIs []string, integrations ...c.IntegrationConf) error {
 | 
			
		||||
	util.Log.Debugf("need to refresh")
 | 
			
		||||
 | 
			
		||||
	util.Log.Infof("Fill CVE detailed information with OVAL")
 | 
			
		||||
	if err := FillWithOval(r); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill OVAL information: %s", err)
 | 
			
		||||
	nCVEs, err := FillWithOval(dbclient.OvalDB, r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill with OVAL: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("%s: %d CVEs are detected with OVAL",
 | 
			
		||||
		r.FormatServerName(), nCVEs)
 | 
			
		||||
 | 
			
		||||
	for i, v := range r.ScannedCves {
 | 
			
		||||
		for j, p := range v.AffectedPackages {
 | 
			
		||||
			if p.NotFixedYet && p.FixState == "" {
 | 
			
		||||
				p.FixState = "Not fixed yet"
 | 
			
		||||
				r.ScannedCves[i].AffectedPackages[j] = p
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nCVEs, err = fillVulnByCpeURIs(dbclient.CveDB, r, cpeURIs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to detect vulns of %s: %s", cpeURIs, err)
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("%s: %d CVEs are detected with CPE", r.FormatServerName(), nCVEs)
 | 
			
		||||
 | 
			
		||||
	if len(integrations) != 0 {
 | 
			
		||||
		for k, v := range integrations[0].GitHubConf {
 | 
			
		||||
			c.Conf.Servers[r.ServerName].GitHubRepos[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	nCVEs, err = fillGitHubSecurityAlerts(r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to access GitHub Security Alerts: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("%s: %d CVEs are detected with GitHub Security Alerts", r.FormatServerName(), nCVEs)
 | 
			
		||||
 | 
			
		||||
	nCVEs, err = FillWithGost(dbclient.GostDB, r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill with gost: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("%s: %d unfixed CVEs are detected with gost",
 | 
			
		||||
		r.FormatServerName(), nCVEs)
 | 
			
		||||
 | 
			
		||||
	util.Log.Infof("Fill CVE detailed information with CVE-DB")
 | 
			
		||||
	if err := fillWithCveDB(r); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill CVE information: %s", err)
 | 
			
		||||
	if err := fillCveDetail(dbclient.CveDB, r); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill with CVE: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for cveID := range r.ScannedCves {
 | 
			
		||||
		vinfo := r.ScannedCves[cveID]
 | 
			
		||||
		r.ScannedCves[cveID] = *vinfo.NilToEmpty()
 | 
			
		||||
	util.Log.Infof("Fill exploit information with Exploit-DB")
 | 
			
		||||
	nExploitCve, err := FillWithExploit(dbclient.ExploitDB, r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to fill with exploit: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	util.Log.Infof("%s: %d exploits are detected",
 | 
			
		||||
		r.FormatServerName(), nExploitCve)
 | 
			
		||||
 | 
			
		||||
	enAlertCnt, jaAlertCnt := fillAlerts(r)
 | 
			
		||||
	util.Log.Infof("%s: en: %d, ja: %d alerts are detected",
 | 
			
		||||
		r.FormatServerName(), enAlertCnt, jaAlertCnt)
 | 
			
		||||
 | 
			
		||||
	fillCweDict(r)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// fillCveDetail fetches NVD, JVN from CVE Database, and then set to fields.
 | 
			
		||||
func fillCveDetail(r *models.ScanResult) error {
 | 
			
		||||
// fillCveDetail fetches NVD, JVN from CVE Database
 | 
			
		||||
func fillCveDetail(driver cvedb.DB, r *models.ScanResult) error {
 | 
			
		||||
	var cveIDs []string
 | 
			
		||||
	for _, v := range r.ScannedCves {
 | 
			
		||||
		cveIDs = append(cveIDs, v.CveID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ds, err := CveClient.FetchCveDetails(cveIDs)
 | 
			
		||||
	ds, err := CveClient.FetchCveDetails(driver, cveIDs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	for _, d := range ds {
 | 
			
		||||
		nvd := models.ConvertNvdToModel(d.CveID, d.Nvd)
 | 
			
		||||
		nvd := models.ConvertNvdJSONToModel(d.CveID, d.NvdJSON)
 | 
			
		||||
		if nvd == nil {
 | 
			
		||||
			nvd = models.ConvertNvdXMLToModel(d.CveID, d.NvdXML)
 | 
			
		||||
		}
 | 
			
		||||
		jvn := models.ConvertJvnToModel(d.CveID, d.Jvn)
 | 
			
		||||
 | 
			
		||||
		for cveID, vinfo := range r.ScannedCves {
 | 
			
		||||
			if vinfo.CveID == d.CveID {
 | 
			
		||||
				if vinfo.CveContents == nil {
 | 
			
		||||
					vinfo.CveContents = models.CveContents{}
 | 
			
		||||
				}
 | 
			
		||||
				for _, con := range []models.CveContent{*nvd, *jvn} {
 | 
			
		||||
					if !con.Empty() {
 | 
			
		||||
						vinfo.CveContents[con.Type] = con
 | 
			
		||||
				for _, con := range []*models.CveContent{nvd, jvn} {
 | 
			
		||||
					if con != nil && !con.Empty() {
 | 
			
		||||
						vinfo.CveContents[con.Type] = *con
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				r.ScannedCves[cveID] = vinfo
 | 
			
		||||
@@ -142,23 +245,11 @@ func fillCveDetail(r *models.ScanResult) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fillWithCveDB(r *models.ScanResult) error {
 | 
			
		||||
	sInfo := c.Conf.Servers[r.ServerName]
 | 
			
		||||
	if err := fillVulnByCpeNames(sInfo.CpeNames, r.ScannedCves); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := fillCveDetail(r); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithOval fetches OVAL database, and then set to fields.
 | 
			
		||||
func FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
// FillWithOval fetches OVAL database
 | 
			
		||||
func FillWithOval(driver ovaldb.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	var ovalClient oval.Client
 | 
			
		||||
	var ovalFamily string
 | 
			
		||||
 | 
			
		||||
	// TODO
 | 
			
		||||
	switch r.Family {
 | 
			
		||||
	case c.Debian:
 | 
			
		||||
		ovalClient = oval.NewDebian()
 | 
			
		||||
@@ -184,57 +275,407 @@ func FillWithOval(r *models.ScanResult) (err error) {
 | 
			
		||||
		ovalClient = oval.NewAlpine()
 | 
			
		||||
		ovalFamily = c.Alpine
 | 
			
		||||
	case c.Amazon, c.Raspbian, c.FreeBSD, c.Windows:
 | 
			
		||||
		return nil
 | 
			
		||||
		return 0, nil
 | 
			
		||||
	case c.ServerTypePseudo:
 | 
			
		||||
		return nil
 | 
			
		||||
		return 0, nil
 | 
			
		||||
	default:
 | 
			
		||||
		return fmt.Errorf("OVAL for %s is not implemented yet", r.Family)
 | 
			
		||||
		if r.Family == "" {
 | 
			
		||||
			return 0, fmt.Errorf("Probably an error occurred during scanning. Check the error message")
 | 
			
		||||
		}
 | 
			
		||||
		return 0, fmt.Errorf("OVAL for %s is not implemented yet", r.Family)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Check whether oval is already fetched: %s %s",
 | 
			
		||||
		ovalFamily, r.Release)
 | 
			
		||||
	ok, err := ovalClient.CheckIfOvalFetched(ovalFamily, r.Release)
 | 
			
		||||
	if !c.Conf.OvalDict.IsFetchViaHTTP() {
 | 
			
		||||
		if driver == nil {
 | 
			
		||||
			return 0, nil
 | 
			
		||||
		}
 | 
			
		||||
		if err = driver.NewOvalDB(ovalFamily); err != nil {
 | 
			
		||||
			return 0, fmt.Errorf("Failed to New Oval DB. err: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	util.Log.Debugf("Check whether oval fetched: %s %s", ovalFamily, r.Release)
 | 
			
		||||
	ok, err := ovalClient.CheckIfOvalFetched(driver, ovalFamily, r.Release)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
	if !ok {
 | 
			
		||||
		util.Log.Warnf("OVAL entries of %s %s are not found. It's recommended to use OVAL to improve scanning accuracy. For details, see https://github.com/kotakanbe/goval-dictionary#usage , Then report with --ovaldb-path or --ovaldb-url flag", ovalFamily, r.Release)
 | 
			
		||||
		return nil
 | 
			
		||||
		return 0, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err = ovalClient.CheckIfOvalFresh(ovalFamily, r.Release)
 | 
			
		||||
	_, err = ovalClient.CheckIfOvalFresh(driver, ovalFamily, r.Release)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		return 0, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := ovalClient.FillWithOval(r); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return ovalClient.FillWithOval(driver, r)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fillVulnByCpeNames(cpeNames []string, scannedVulns models.VulnInfos) error {
 | 
			
		||||
	for _, name := range cpeNames {
 | 
			
		||||
		details, err := CveClient.FetchCveDetailsByCpeName(name)
 | 
			
		||||
// FillWithGost fills CVEs with gost dataabase
 | 
			
		||||
// https://github.com/knqyf263/gost
 | 
			
		||||
func FillWithGost(driver gostdb.DB, r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	gostClient := gost.NewClient(r.Family)
 | 
			
		||||
	// TODO chekc if fetched
 | 
			
		||||
	// TODO chekc if fresh enough
 | 
			
		||||
	return gostClient.FillWithGost(driver, r)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FillWithExploit fills Exploits with exploit dataabase
 | 
			
		||||
// https://github.com/mozqnet/go-exploitdb
 | 
			
		||||
func FillWithExploit(driver exploitdb.DB, r *models.ScanResult) (nExploitCve int, err error) {
 | 
			
		||||
	// TODO chekc if fetched
 | 
			
		||||
	// TODO chekc if fresh enough
 | 
			
		||||
	return exploit.FillWithExploit(driver, r)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fillVulnByCpeURIs(driver cvedb.DB, r *models.ScanResult, cpeURIs []string) (nCVEs int, err error) {
 | 
			
		||||
	for _, name := range cpeURIs {
 | 
			
		||||
		details, err := CveClient.FetchCveDetailsByCpeName(driver, name)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		for _, detail := range details {
 | 
			
		||||
			if val, ok := scannedVulns[detail.CveID]; ok {
 | 
			
		||||
				names := val.CpeNames
 | 
			
		||||
			if val, ok := r.ScannedCves[detail.CveID]; ok {
 | 
			
		||||
				names := val.CpeURIs
 | 
			
		||||
				names = util.AppendIfMissing(names, name)
 | 
			
		||||
				val.CpeNames = names
 | 
			
		||||
				val.Confidence = models.CpeNameMatch
 | 
			
		||||
				scannedVulns[detail.CveID] = val
 | 
			
		||||
				val.CpeURIs = names
 | 
			
		||||
				val.Confidences.AppendIfMissing(models.CpeNameMatch)
 | 
			
		||||
				r.ScannedCves[detail.CveID] = val
 | 
			
		||||
			} else {
 | 
			
		||||
				v := models.VulnInfo{
 | 
			
		||||
					CveID:      detail.CveID,
 | 
			
		||||
					CpeNames:   []string{name},
 | 
			
		||||
					Confidence: models.CpeNameMatch,
 | 
			
		||||
					CveID:       detail.CveID,
 | 
			
		||||
					CpeURIs:     []string{name},
 | 
			
		||||
					Confidences: models.Confidences{models.CpeNameMatch},
 | 
			
		||||
				}
 | 
			
		||||
				scannedVulns[detail.CveID] = v
 | 
			
		||||
				r.ScannedCves[detail.CveID] = v
 | 
			
		||||
				nCVEs++
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return nCVEs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// https://help.github.com/articles/about-security-alerts-for-vulnerable-dependencies/
 | 
			
		||||
func fillGitHubSecurityAlerts(r *models.ScanResult) (nCVEs int, err error) {
 | 
			
		||||
	repos := c.Conf.Servers[r.ServerName].GitHubRepos
 | 
			
		||||
	for ownerRepo, setting := range repos {
 | 
			
		||||
		ss := strings.Split(ownerRepo, "/")
 | 
			
		||||
		owner, repo := ss[0], ss[1]
 | 
			
		||||
		n, err := github.FillGitHubSecurityAlerts(r, owner, repo, setting.Token)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		nCVEs += n
 | 
			
		||||
	}
 | 
			
		||||
	return nCVEs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fillCweDict(r *models.ScanResult) {
 | 
			
		||||
	uniqCweIDMap := map[string]bool{}
 | 
			
		||||
	for _, vinfo := range r.ScannedCves {
 | 
			
		||||
		for _, cont := range vinfo.CveContents {
 | 
			
		||||
			for _, id := range cont.CweIDs {
 | 
			
		||||
				if strings.HasPrefix(id, "CWE-") {
 | 
			
		||||
					id = strings.TrimPrefix(id, "CWE-")
 | 
			
		||||
					uniqCweIDMap[id] = true
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// TODO check the format of CWEID, clean CWEID
 | 
			
		||||
	// JVN, NVD XML, JSON, OVALs
 | 
			
		||||
 | 
			
		||||
	dict := map[string]models.CweDictEntry{}
 | 
			
		||||
	for id := range uniqCweIDMap {
 | 
			
		||||
		entry := models.CweDictEntry{}
 | 
			
		||||
		if e, ok := cwe.CweDictEn[id]; ok {
 | 
			
		||||
			if rank, ok := cwe.OwaspTopTen2017[id]; ok {
 | 
			
		||||
				entry.OwaspTopTen2017 = rank
 | 
			
		||||
			}
 | 
			
		||||
			entry.En = &e
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Debugf("CWE-ID %s is not found in English CWE Dict", id)
 | 
			
		||||
			entry.En = &cwe.Cwe{CweID: id}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.Lang == "ja" {
 | 
			
		||||
			if e, ok := cwe.CweDictJa[id]; ok {
 | 
			
		||||
				if rank, ok := cwe.OwaspTopTen2017[id]; ok {
 | 
			
		||||
					entry.OwaspTopTen2017 = rank
 | 
			
		||||
				}
 | 
			
		||||
				entry.Ja = &e
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Debugf("CWE-ID %s is not found in Japanese CWE Dict", id)
 | 
			
		||||
				entry.Ja = &cwe.Cwe{CweID: id}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		dict[id] = entry
 | 
			
		||||
	}
 | 
			
		||||
	r.CweDict = dict
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fillAlerts(r *models.ScanResult) (enCnt int, jaCnt int) {
 | 
			
		||||
	for cveID, vuln := range r.ScannedCves {
 | 
			
		||||
		enAs, jaAs := models.GetAlertsByCveID(cveID, "en"), models.GetAlertsByCveID(cveID, "ja")
 | 
			
		||||
		vuln.AlertDict = models.AlertDict{
 | 
			
		||||
			Ja: jaAs,
 | 
			
		||||
			En: enAs,
 | 
			
		||||
		}
 | 
			
		||||
		r.ScannedCves[cveID] = vuln
 | 
			
		||||
		enCnt += len(enAs)
 | 
			
		||||
		jaCnt += len(jaAs)
 | 
			
		||||
	}
 | 
			
		||||
	return enCnt, jaCnt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const reUUID = "[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}"
 | 
			
		||||
 | 
			
		||||
// EnsureUUIDs generate a new UUID of the scan target server if UUID is not assigned yet.
 | 
			
		||||
// And then set the generated UUID to config.toml and scan results.
 | 
			
		||||
func EnsureUUIDs(configPath string, results models.ScanResults) error {
 | 
			
		||||
	// Sort Host->Container
 | 
			
		||||
	sort.Slice(results, func(i, j int) bool {
 | 
			
		||||
		if results[i].ServerName == results[j].ServerName {
 | 
			
		||||
			return results[i].Container.ContainerID < results[j].Container.ContainerID
 | 
			
		||||
		}
 | 
			
		||||
		return results[i].ServerName < results[j].ServerName
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	for i, r := range results {
 | 
			
		||||
		server := c.Conf.Servers[r.ServerName]
 | 
			
		||||
		if server.UUIDs == nil {
 | 
			
		||||
			server.UUIDs = map[string]string{}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		name := ""
 | 
			
		||||
		if r.IsContainer() {
 | 
			
		||||
			name = fmt.Sprintf("%s@%s", r.Container.Name, r.ServerName)
 | 
			
		||||
 | 
			
		||||
			// Scanning with the -containers-only flag at scan time, the UUID of Container Host may not be generated,
 | 
			
		||||
			// so check it. Otherwise create a UUID of the Container Host and set it.
 | 
			
		||||
			serverUUID := ""
 | 
			
		||||
			if id, ok := server.UUIDs[r.ServerName]; !ok {
 | 
			
		||||
				serverUUID = uuid.GenerateUUID()
 | 
			
		||||
			} else {
 | 
			
		||||
				matched, err := regexp.MatchString(reUUID, id)
 | 
			
		||||
				if !matched || err != nil {
 | 
			
		||||
					serverUUID = uuid.GenerateUUID()
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if serverUUID != "" {
 | 
			
		||||
				server.UUIDs[r.ServerName] = serverUUID
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			name = r.ServerName
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if id, ok := server.UUIDs[name]; ok {
 | 
			
		||||
			matched, err := regexp.MatchString(reUUID, id)
 | 
			
		||||
			if !matched || err != nil {
 | 
			
		||||
				util.Log.Warnf("UUID is invalid. Re-generate UUID %s: %s", id, err)
 | 
			
		||||
			} else {
 | 
			
		||||
				if r.IsContainer() {
 | 
			
		||||
					results[i].Container.UUID = id
 | 
			
		||||
					results[i].ServerUUID = server.UUIDs[r.ServerName]
 | 
			
		||||
				} else {
 | 
			
		||||
					results[i].ServerUUID = id
 | 
			
		||||
				}
 | 
			
		||||
				// continue if the UUID has already assigned and valid
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Generate a new UUID and set to config and scan result
 | 
			
		||||
		id := uuid.GenerateUUID()
 | 
			
		||||
		server.UUIDs[name] = id
 | 
			
		||||
		server = cleanForTOMLEncoding(server, c.Conf.Default)
 | 
			
		||||
		c.Conf.Servers[r.ServerName] = server
 | 
			
		||||
 | 
			
		||||
		if r.IsContainer() {
 | 
			
		||||
			results[i].Container.UUID = id
 | 
			
		||||
			results[i].ServerUUID = server.UUIDs[r.ServerName]
 | 
			
		||||
		} else {
 | 
			
		||||
			results[i].ServerUUID = id
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for name, server := range c.Conf.Servers {
 | 
			
		||||
		server = cleanForTOMLEncoding(server, c.Conf.Default)
 | 
			
		||||
		c.Conf.Servers[name] = server
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	email := &c.Conf.EMail
 | 
			
		||||
	if email.SMTPAddr == "" {
 | 
			
		||||
		email = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	slack := &c.Conf.Slack
 | 
			
		||||
	if slack.HookURL == "" {
 | 
			
		||||
		slack = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cveDict := &c.Conf.CveDict
 | 
			
		||||
	ovalDict := &c.Conf.OvalDict
 | 
			
		||||
	gost := &c.Conf.Gost
 | 
			
		||||
	exploit := &c.Conf.Exploit
 | 
			
		||||
	http := &c.Conf.HTTP
 | 
			
		||||
	if http.URL == "" {
 | 
			
		||||
		http = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	syslog := &c.Conf.Syslog
 | 
			
		||||
	if syslog.Host == "" {
 | 
			
		||||
		syslog = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	aws := &c.Conf.AWS
 | 
			
		||||
	if aws.S3Bucket == "" {
 | 
			
		||||
		aws = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	azure := &c.Conf.Azure
 | 
			
		||||
	if azure.AccountName == "" {
 | 
			
		||||
		azure = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	stride := &c.Conf.Stride
 | 
			
		||||
	if stride.HookURL == "" {
 | 
			
		||||
		stride = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	hipChat := &c.Conf.HipChat
 | 
			
		||||
	if hipChat.AuthToken == "" {
 | 
			
		||||
		hipChat = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	chatWork := &c.Conf.ChatWork
 | 
			
		||||
	if chatWork.APIToken == "" {
 | 
			
		||||
		chatWork = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	saas := &c.Conf.Saas
 | 
			
		||||
	if saas.GroupID == 0 {
 | 
			
		||||
		saas = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	c := struct {
 | 
			
		||||
		CveDict  *c.GoCveDictConf `toml:"cveDict"`
 | 
			
		||||
		OvalDict *c.GovalDictConf `toml:"ovalDict"`
 | 
			
		||||
		Gost     *c.GostConf      `toml:"gost"`
 | 
			
		||||
		Exploit  *c.ExploitConf   `toml:"exploit"`
 | 
			
		||||
		Slack    *c.SlackConf     `toml:"slack"`
 | 
			
		||||
		Email    *c.SMTPConf      `toml:"email"`
 | 
			
		||||
		HTTP     *c.HTTPConf      `toml:"http"`
 | 
			
		||||
		Syslog   *c.SyslogConf    `toml:"syslog"`
 | 
			
		||||
		AWS      *c.AWS           `toml:"aws"`
 | 
			
		||||
		Azure    *c.Azure         `toml:"azure"`
 | 
			
		||||
		Stride   *c.StrideConf    `toml:"stride"`
 | 
			
		||||
		HipChat  *c.HipChatConf   `toml:"hipChat"`
 | 
			
		||||
		ChatWork *c.ChatWorkConf  `toml:"chatWork"`
 | 
			
		||||
		Saas     *c.SaasConf      `toml:"saas"`
 | 
			
		||||
 | 
			
		||||
		Default c.ServerInfo            `toml:"default"`
 | 
			
		||||
		Servers map[string]c.ServerInfo `toml:"servers"`
 | 
			
		||||
	}{
 | 
			
		||||
		CveDict:  cveDict,
 | 
			
		||||
		OvalDict: ovalDict,
 | 
			
		||||
		Gost:     gost,
 | 
			
		||||
		Exploit:  exploit,
 | 
			
		||||
		Slack:    slack,
 | 
			
		||||
		Email:    email,
 | 
			
		||||
		HTTP:     http,
 | 
			
		||||
		Syslog:   syslog,
 | 
			
		||||
		AWS:      aws,
 | 
			
		||||
		Azure:    azure,
 | 
			
		||||
		Stride:   stride,
 | 
			
		||||
		HipChat:  hipChat,
 | 
			
		||||
		ChatWork: chatWork,
 | 
			
		||||
		Saas:     saas,
 | 
			
		||||
 | 
			
		||||
		Default: c.Conf.Default,
 | 
			
		||||
		Servers: c.Conf.Servers,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// rename the current config.toml to config.toml.bak
 | 
			
		||||
	info, err := os.Lstat(configPath)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to lstat %s: %s", configPath, err)
 | 
			
		||||
	}
 | 
			
		||||
	realPath := configPath
 | 
			
		||||
	if info.Mode()&os.ModeSymlink == os.ModeSymlink {
 | 
			
		||||
		if realPath, err = os.Readlink(configPath); err != nil {
 | 
			
		||||
			return fmt.Errorf("Failed to Read link %s: %s", configPath, err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if err := os.Rename(realPath, realPath+".bak"); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to rename %s: %s", configPath, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var buf bytes.Buffer
 | 
			
		||||
	if err := toml.NewEncoder(&buf).Encode(c); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to encode to toml: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	str := strings.Replace(buf.String(), "\n  [", "\n\n  [", -1)
 | 
			
		||||
	str = fmt.Sprintf("%s\n\n%s",
 | 
			
		||||
		"# See REAME for details: https://vuls.io/docs/en/usage-settings.html",
 | 
			
		||||
		str)
 | 
			
		||||
 | 
			
		||||
	return ioutil.WriteFile(realPath, []byte(str), 0600)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func cleanForTOMLEncoding(server c.ServerInfo, def c.ServerInfo) c.ServerInfo {
 | 
			
		||||
	if reflect.DeepEqual(server.Optional, def.Optional) {
 | 
			
		||||
		server.Optional = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.User == server.User {
 | 
			
		||||
		server.User = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.Host == server.Host {
 | 
			
		||||
		server.Host = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.Port == server.Port {
 | 
			
		||||
		server.Port = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.KeyPath == server.KeyPath {
 | 
			
		||||
		server.KeyPath = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if reflect.DeepEqual(server.ScanMode, def.ScanMode) {
 | 
			
		||||
		server.ScanMode = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.Type == server.Type {
 | 
			
		||||
		server.Type = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if reflect.DeepEqual(server.CpeNames, def.CpeNames) {
 | 
			
		||||
		server.CpeNames = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if def.OwaspDCXMLPath == server.OwaspDCXMLPath {
 | 
			
		||||
		server.OwaspDCXMLPath = ""
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if reflect.DeepEqual(server.IgnoreCves, def.IgnoreCves) {
 | 
			
		||||
		server.IgnoreCves = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if reflect.DeepEqual(server.Enablerepo, def.Enablerepo) {
 | 
			
		||||
		server.Enablerepo = nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for k, v := range def.Optional {
 | 
			
		||||
		if vv, ok := server.Optional[k]; ok && v == vv {
 | 
			
		||||
			delete(server.Optional, k)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return server
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								report/s3.go
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								report/s3.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -41,10 +41,10 @@ type S3Writer struct{}
 | 
			
		||||
 | 
			
		||||
func getS3() *s3.S3 {
 | 
			
		||||
	Config := &aws.Config{
 | 
			
		||||
		Region: aws.String(c.Conf.AwsRegion),
 | 
			
		||||
		Region: aws.String(c.Conf.AWS.Region),
 | 
			
		||||
		Credentials: credentials.NewChainCredentials([]credentials.Provider{
 | 
			
		||||
			&credentials.EnvProvider{},
 | 
			
		||||
			&credentials.SharedCredentialsProvider{Filename: "", Profile: c.Conf.AwsProfile},
 | 
			
		||||
			&credentials.SharedCredentialsProvider{Filename: "", Profile: c.Conf.AWS.Profile},
 | 
			
		||||
			&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())},
 | 
			
		||||
		}),
 | 
			
		||||
	}
 | 
			
		||||
@@ -82,9 +82,9 @@ func (w S3Writer) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.Conf.FormatShortText {
 | 
			
		||||
		if c.Conf.FormatList {
 | 
			
		||||
			k := key + "_short.txt"
 | 
			
		||||
			text := formatShortPlainText(r)
 | 
			
		||||
			text := formatList(r)
 | 
			
		||||
			if err := putObject(svc, k, []byte(text)); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
@@ -120,20 +120,20 @@ func CheckIfBucketExists() error {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf(
 | 
			
		||||
			"Failed to list buckets. err: %s, profile: %s, region: %s",
 | 
			
		||||
			err, c.Conf.AwsProfile, c.Conf.AwsRegion)
 | 
			
		||||
			err, c.Conf.AWS.Profile, c.Conf.AWS.Region)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	found := false
 | 
			
		||||
	for _, bucket := range result.Buckets {
 | 
			
		||||
		if *bucket.Name == c.Conf.S3Bucket {
 | 
			
		||||
		if *bucket.Name == c.Conf.AWS.S3Bucket {
 | 
			
		||||
			found = true
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if !found {
 | 
			
		||||
		return fmt.Errorf(
 | 
			
		||||
			"Failed to find the buckets. profile: %s, region: %s, bukdet: %s",
 | 
			
		||||
			c.Conf.AwsProfile, c.Conf.AwsRegion, c.Conf.S3Bucket)
 | 
			
		||||
			"Failed to find the buckets. profile: %s, region: %s, bucket: %s",
 | 
			
		||||
			c.Conf.AWS.Profile, c.Conf.AWS.Region, c.Conf.AWS.S3Bucket)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@@ -144,16 +144,22 @@ func putObject(svc *s3.S3, k string, b []byte) error {
 | 
			
		||||
		if b, err = gz(b); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		k = k + ".gz"
 | 
			
		||||
		k += ".gz"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := svc.PutObject(&s3.PutObjectInput{
 | 
			
		||||
		Bucket: aws.String(c.Conf.S3Bucket),
 | 
			
		||||
		Key:    aws.String(path.Join(c.Conf.S3ResultsDir, k)),
 | 
			
		||||
	putObjectInput := &s3.PutObjectInput{
 | 
			
		||||
		Bucket: aws.String(c.Conf.AWS.S3Bucket),
 | 
			
		||||
		Key:    aws.String(path.Join(c.Conf.AWS.S3ResultsDir, k)),
 | 
			
		||||
		Body:   bytes.NewReader(b),
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.AWS.S3ServerSideEncryption != "" {
 | 
			
		||||
		putObjectInput.ServerSideEncryption = aws.String(c.Conf.AWS.S3ServerSideEncryption)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := svc.PutObject(putObjectInput); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to upload data to %s/%s, %s",
 | 
			
		||||
			c.Conf.S3Bucket, k, err)
 | 
			
		||||
			c.Conf.AWS.S3Bucket, k, err)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										153
									
								
								report/saas.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								report/saas.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,153 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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 report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"path"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/aws/aws-sdk-go/aws"
 | 
			
		||||
	"github.com/aws/aws-sdk-go/aws/credentials"
 | 
			
		||||
	"github.com/aws/aws-sdk-go/aws/session"
 | 
			
		||||
	"github.com/aws/aws-sdk-go/service/s3"
 | 
			
		||||
	"github.com/aws/aws-sdk-go/service/sts"
 | 
			
		||||
	c "github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// SaasWriter writes results to SaaS
 | 
			
		||||
type SaasWriter struct{}
 | 
			
		||||
 | 
			
		||||
// TempCredential : TempCredential
 | 
			
		||||
type TempCredential struct {
 | 
			
		||||
	Credential   *sts.Credentials `json:"Credential"`
 | 
			
		||||
	S3Bucket     string           `json:"S3Bucket"`
 | 
			
		||||
	S3ResultsDir string           `json:"S3ResultsDir"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type payload struct {
 | 
			
		||||
	GroupID int    `json:"GroupID"`
 | 
			
		||||
	Token   string `json:"Token"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UploadSaas : UploadSaas
 | 
			
		||||
func (w SaasWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	// dir string, configPath string, config *c.Config
 | 
			
		||||
	if len(rs) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	payload := payload{
 | 
			
		||||
		GroupID: c.Conf.Saas.GroupID,
 | 
			
		||||
		Token:   c.Conf.Saas.Token,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var body []byte
 | 
			
		||||
	if body, err = json.Marshal(payload); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to Marshal to JSON: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var req *http.Request
 | 
			
		||||
	if req, err = http.NewRequest("POST", c.Conf.Saas.URL, bytes.NewBuffer(body)); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	req.Header.Set("Content-Type", "application/json")
 | 
			
		||||
	req.Header.Set("Accept", "application/json")
 | 
			
		||||
 | 
			
		||||
	proxy := c.Conf.HTTPProxy
 | 
			
		||||
	var client http.Client
 | 
			
		||||
	if proxy != "" {
 | 
			
		||||
		proxyURL, _ := url.Parse(proxy)
 | 
			
		||||
		client = http.Client{
 | 
			
		||||
			Transport: &http.Transport{
 | 
			
		||||
				Proxy: http.ProxyURL(proxyURL),
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		client = http.Client{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var resp *http.Response
 | 
			
		||||
	if resp, err = client.Do(req); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer resp.Body.Close()
 | 
			
		||||
	if resp.StatusCode != 200 {
 | 
			
		||||
		return fmt.Errorf("Failed to get Credential. Request JSON : %s,", string(body))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var t []byte
 | 
			
		||||
	if t, err = ioutil.ReadAll(resp.Body); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var tempCredential TempCredential
 | 
			
		||||
	if err = json.Unmarshal(t, &tempCredential); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to unmarshal saas credential file. err : %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	credential := credentials.NewStaticCredentialsFromCreds(credentials.Value{
 | 
			
		||||
		AccessKeyID:     *tempCredential.Credential.AccessKeyId,
 | 
			
		||||
		SecretAccessKey: *tempCredential.Credential.SecretAccessKey,
 | 
			
		||||
		SessionToken:    *tempCredential.Credential.SessionToken,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	var sess *session.Session
 | 
			
		||||
	if sess, err = session.NewSession(&aws.Config{
 | 
			
		||||
		Credentials: credential,
 | 
			
		||||
		Region:      aws.String("ap-northeast-1"),
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to new aws session. err : %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	svc := s3.New(sess)
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		s3Key := renameKeyNameUTC(r.ScannedAt, r.ServerUUID, r.Container)
 | 
			
		||||
		var b []byte
 | 
			
		||||
		if b, err = json.Marshal(r); err != nil {
 | 
			
		||||
			return fmt.Errorf("Failed to Marshal to JSON: %s", err)
 | 
			
		||||
		}
 | 
			
		||||
		util.Log.Infof("Uploading...: ServerName: %s, ", r.ServerName)
 | 
			
		||||
		putObjectInput := &s3.PutObjectInput{
 | 
			
		||||
			Bucket: aws.String(tempCredential.S3Bucket),
 | 
			
		||||
			Key:    aws.String(path.Join(tempCredential.S3ResultsDir, s3Key)),
 | 
			
		||||
			Body:   bytes.NewReader(b),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if _, err := svc.PutObject(putObjectInput); err != nil {
 | 
			
		||||
			return fmt.Errorf("Failed to upload data to %s/%s, %s",
 | 
			
		||||
				tempCredential.S3Bucket, s3Key, err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func renameKeyNameUTC(scannedAt time.Time, uuid string, container models.Container) string {
 | 
			
		||||
	timestr := scannedAt.UTC().Format(time.RFC3339)
 | 
			
		||||
	if len(container.ContainerID) == 0 {
 | 
			
		||||
		return fmt.Sprintf("%s/%s.json", timestr, uuid)
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%s/%s@%s.json", timestr, container.UUID, uuid)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										107
									
								
								report/slack.go
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								report/slack.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -39,12 +39,11 @@ type field struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type message struct {
 | 
			
		||||
	Text            string             `json:"text"`
 | 
			
		||||
	Username        string             `json:"username"`
 | 
			
		||||
	IconEmoji       string             `json:"icon_emoji"`
 | 
			
		||||
	Channel         string             `json:"channel"`
 | 
			
		||||
	ThreadTimeStamp string             `json:"thread_ts"`
 | 
			
		||||
	Attachments     []slack.Attachment `json:"attachments"`
 | 
			
		||||
	Text        string             `json:"text"`
 | 
			
		||||
	Username    string             `json:"username"`
 | 
			
		||||
	IconEmoji   string             `json:"icon_emoji"`
 | 
			
		||||
	Channel     string             `json:"channel"`
 | 
			
		||||
	Attachments []slack.Attachment `json:"attachments"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SlackWriter send report to slack
 | 
			
		||||
@@ -61,12 +60,8 @@ func (w SlackWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if 0 < len(r.Errors) {
 | 
			
		||||
			serverInfo := fmt.Sprintf("*%s*", r.ServerInfo())
 | 
			
		||||
			notifyUsers := getNotifyUsers(config.Conf.Slack.NotifyUsers)
 | 
			
		||||
			txt := fmt.Sprintf("%s\n%s\nError: %s",
 | 
			
		||||
				notifyUsers, serverInfo, r.Errors)
 | 
			
		||||
			msg := message{
 | 
			
		||||
				Text:      txt,
 | 
			
		||||
				Text:      msgText(r),
 | 
			
		||||
				Username:  conf.AuthUser,
 | 
			
		||||
				IconEmoji: conf.IconEmoji,
 | 
			
		||||
				Channel:   channel,
 | 
			
		||||
@@ -179,10 +174,22 @@ func msgText(r models.ScanResult) string {
 | 
			
		||||
		notifyUsers = getNotifyUsers(config.Conf.Slack.NotifyUsers)
 | 
			
		||||
	}
 | 
			
		||||
	serverInfo := fmt.Sprintf("*%s*", r.ServerInfo())
 | 
			
		||||
	return fmt.Sprintf("%s\n%s\n>%s",
 | 
			
		||||
 | 
			
		||||
	if 0 < len(r.Errors) {
 | 
			
		||||
		return fmt.Sprintf("%s\n%s\n%s\n%s\n%s\nError: %s",
 | 
			
		||||
			notifyUsers,
 | 
			
		||||
			serverInfo,
 | 
			
		||||
			r.ScannedCves.FormatCveSummary(),
 | 
			
		||||
			r.ScannedCves.FormatFixedStatus(r.Packages),
 | 
			
		||||
			r.FormatUpdatablePacksSummary(),
 | 
			
		||||
			r.Errors)
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%s\n%s\n%s\n%s\n%s",
 | 
			
		||||
		notifyUsers,
 | 
			
		||||
		serverInfo,
 | 
			
		||||
		r.ScannedCves.FormatCveSummary())
 | 
			
		||||
		r.ScannedCves.FormatCveSummary(),
 | 
			
		||||
		r.ScannedCves.FormatFixedStatus(r.Packages),
 | 
			
		||||
		r.FormatUpdatablePacksSummary())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func toSlackAttachments(r models.ScanResult) (attaches []slack.Attachment) {
 | 
			
		||||
@@ -197,9 +204,12 @@ func toSlackAttachments(r models.ScanResult) (attaches []slack.Attachment) {
 | 
			
		||||
				curent = append(curent, affected.Name)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for _, n := range vinfo.CpeNames {
 | 
			
		||||
		for _, n := range vinfo.CpeURIs {
 | 
			
		||||
			curent = append(curent, n)
 | 
			
		||||
		}
 | 
			
		||||
		for _, n := range vinfo.GitHubSecurityAlerts {
 | 
			
		||||
			curent = append(curent, n.PackageName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		new := []string{}
 | 
			
		||||
		for _, affected := range vinfo.AffectedPackages {
 | 
			
		||||
@@ -213,14 +223,17 @@ func toSlackAttachments(r models.ScanResult) (attaches []slack.Attachment) {
 | 
			
		||||
				new = append(new, "?")
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for range vinfo.CpeNames {
 | 
			
		||||
		for range vinfo.CpeURIs {
 | 
			
		||||
			new = append(new, "?")
 | 
			
		||||
		}
 | 
			
		||||
		for range vinfo.GitHubSecurityAlerts {
 | 
			
		||||
			new = append(new, "?")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		a := slack.Attachment{
 | 
			
		||||
			Title:      vinfo.CveID,
 | 
			
		||||
			TitleLink:  "https://nvd.nist.gov/vuln/detail/" + vinfo.CveID,
 | 
			
		||||
			Text:       attachmentText(vinfo, r.Family),
 | 
			
		||||
			Text:       attachmentText(vinfo, r.Family, r.CweDict, r.Packages),
 | 
			
		||||
			MarkdownIn: []string{"text", "pretext"},
 | 
			
		||||
			Fields: []slack.AttachmentField{
 | 
			
		||||
				{
 | 
			
		||||
@@ -235,7 +248,7 @@ func toSlackAttachments(r models.ScanResult) (attaches []slack.Attachment) {
 | 
			
		||||
					Short: true,
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			Color: color(vinfo.MaxCvssScore().Value.Score),
 | 
			
		||||
			Color: cvssColor(vinfo.MaxCvssScore().Value.Score),
 | 
			
		||||
		}
 | 
			
		||||
		attaches = append(attaches, a)
 | 
			
		||||
	}
 | 
			
		||||
@@ -243,7 +256,7 @@ func toSlackAttachments(r models.ScanResult) (attaches []slack.Attachment) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// https://api.slack.com/docs/attachments
 | 
			
		||||
func color(cvssScore float64) string {
 | 
			
		||||
func cvssColor(cvssScore float64) string {
 | 
			
		||||
	switch {
 | 
			
		||||
	case 7 <= cvssScore:
 | 
			
		||||
		return "danger"
 | 
			
		||||
@@ -256,10 +269,15 @@ func color(cvssScore float64) string {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func attachmentText(vinfo models.VulnInfo, osFamily string) string {
 | 
			
		||||
func attachmentText(vinfo models.VulnInfo, osFamily string, cweDict map[string]models.CweDictEntry, packs models.Packages) string {
 | 
			
		||||
	maxCvss := vinfo.MaxCvssScore()
 | 
			
		||||
	vectors := []string{}
 | 
			
		||||
	for _, cvss := range vinfo.Cvss2Scores() {
 | 
			
		||||
 | 
			
		||||
	scores := append(vinfo.Cvss3Scores(), vinfo.Cvss2Scores(osFamily)...)
 | 
			
		||||
	for _, cvss := range scores {
 | 
			
		||||
		if cvss.Value.Severity == "" {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		calcURL := ""
 | 
			
		||||
		switch cvss.Value.Type {
 | 
			
		||||
		case models.CVSS2:
 | 
			
		||||
@@ -273,9 +291,10 @@ func attachmentText(vinfo models.VulnInfo, osFamily string) string {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if cont, ok := vinfo.CveContents[cvss.Type]; ok {
 | 
			
		||||
			v := fmt.Sprintf("<%s|%s> (<%s|%s>)",
 | 
			
		||||
			v := fmt.Sprintf("<%s|%s> %s (<%s|%s>)",
 | 
			
		||||
				calcURL,
 | 
			
		||||
				cvss.Value.Format(),
 | 
			
		||||
				fmt.Sprintf("%3.1f/%s", cvss.Value.Score, cvss.Value.Vector),
 | 
			
		||||
				cvss.Value.Severity,
 | 
			
		||||
				cont.SourceLink,
 | 
			
		||||
				cvss.Type)
 | 
			
		||||
			vectors = append(vectors, v)
 | 
			
		||||
@@ -288,9 +307,10 @@ func attachmentText(vinfo models.VulnInfo, osFamily string) string {
 | 
			
		||||
						v, k))
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				v := fmt.Sprintf("<%s|%s> (%s)",
 | 
			
		||||
				v := fmt.Sprintf("<%s|%s> %s (%s)",
 | 
			
		||||
					calcURL,
 | 
			
		||||
					cvss.Value.Format(),
 | 
			
		||||
					fmt.Sprintf("%3.1f/%s", cvss.Value.Score, cvss.Value.Vector),
 | 
			
		||||
					cvss.Value.Severity,
 | 
			
		||||
					strings.Join(links, ", "))
 | 
			
		||||
				vectors = append(vectors, v)
 | 
			
		||||
			}
 | 
			
		||||
@@ -302,27 +322,42 @@ func attachmentText(vinfo models.VulnInfo, osFamily string) string {
 | 
			
		||||
		severity = "?"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return fmt.Sprintf("*%4.1f (%s)* %s\n%s\n```%s```",
 | 
			
		||||
	nwvec := vinfo.AttackVector()
 | 
			
		||||
	if nwvec == "Network" || nwvec == "remote" {
 | 
			
		||||
		nwvec = fmt.Sprintf("*%s*", nwvec)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mitigation := ""
 | 
			
		||||
	if vinfo.Mitigations(osFamily)[0].Type != models.Unknown {
 | 
			
		||||
		mitigation = fmt.Sprintf("\nMitigation:\n```%s```\n",
 | 
			
		||||
			vinfo.Mitigations(osFamily)[0].Value)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return fmt.Sprintf("*%4.1f (%s)* %s %s\n%s\n```\n%s\n```%s\n%s\n",
 | 
			
		||||
		maxCvss.Value.Score,
 | 
			
		||||
		severity,
 | 
			
		||||
		cweIDs(vinfo, osFamily),
 | 
			
		||||
		nwvec,
 | 
			
		||||
		vinfo.PatchStatus(packs),
 | 
			
		||||
		strings.Join(vectors, "\n"),
 | 
			
		||||
		vinfo.Summaries(config.Conf.Lang, osFamily)[0].Value,
 | 
			
		||||
		mitigation,
 | 
			
		||||
		cweIDs(vinfo, osFamily, cweDict),
 | 
			
		||||
	)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func cweIDs(vinfo models.VulnInfo, osFamily string) string {
 | 
			
		||||
func cweIDs(vinfo models.VulnInfo, osFamily string, cweDict models.CweDict) string {
 | 
			
		||||
	links := []string{}
 | 
			
		||||
	for _, cwe := range vinfo.CveContents.CweIDs(osFamily) {
 | 
			
		||||
		if config.Conf.Lang == "ja" {
 | 
			
		||||
			links = append(links, fmt.Sprintf("<%s|%s>",
 | 
			
		||||
				cweJvnURL(cwe.Value), cwe.Value))
 | 
			
		||||
		} else {
 | 
			
		||||
			links = append(links, fmt.Sprintf("<%s|%s>",
 | 
			
		||||
				cweURL(cwe.Value), cwe.Value))
 | 
			
		||||
	for _, c := range vinfo.CveContents.UniqCweIDs(osFamily) {
 | 
			
		||||
		name, url, top10Rank, top10URL := cweDict.Get(c.Value, osFamily)
 | 
			
		||||
		line := ""
 | 
			
		||||
		if top10Rank != "" {
 | 
			
		||||
			line = fmt.Sprintf("<%s|[OWASP Top %s]>",
 | 
			
		||||
				top10URL, top10Rank)
 | 
			
		||||
		}
 | 
			
		||||
		links = append(links, fmt.Sprintf("%s <%s|%s>: %s",
 | 
			
		||||
			line, url, c.Value, name))
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(links, " / ")
 | 
			
		||||
	return strings.Join(links, "\n")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// See testcase
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -44,9 +44,9 @@ func (w StdoutWriter) Write(rs ...models.ScanResult) error {
 | 
			
		||||
		fmt.Print("\n")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if c.Conf.FormatShortText {
 | 
			
		||||
	if c.Conf.FormatList {
 | 
			
		||||
		for _, r := range rs {
 | 
			
		||||
			fmt.Println(formatShortPlainText(r))
 | 
			
		||||
			fmt.Println(formatList(r))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										81
									
								
								report/stride.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								report/stride.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// StrideWriter send report to Stride
 | 
			
		||||
type StrideWriter struct{}
 | 
			
		||||
type strideSender struct{}
 | 
			
		||||
 | 
			
		||||
func (w StrideWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	conf := config.Conf.Stride
 | 
			
		||||
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		w := strideSender{}
 | 
			
		||||
 | 
			
		||||
		serverInfo := fmt.Sprintf("%s", r.ServerInfo())
 | 
			
		||||
		message := fmt.Sprintf(`{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":" %s  "}]}]}}`,
 | 
			
		||||
			serverInfo,
 | 
			
		||||
		)
 | 
			
		||||
		if err = w.sendMessage(conf.HookURL, conf.AuthToken, message); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, vinfo := range r.ScannedCves {
 | 
			
		||||
			maxCvss := vinfo.MaxCvssScore()
 | 
			
		||||
			severity := strings.ToUpper(maxCvss.Value.Severity)
 | 
			
		||||
			if severity == "" {
 | 
			
		||||
				severity = "?"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			message = fmt.Sprintf(`{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":" %s ","marks": [ { "type": "link", "attrs": { "href": "https://nvd.nist.gov/vuln/detail/%s", "title": "cve" } } ]}]}]}}`,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
			)
 | 
			
		||||
			if err = w.sendMessage(conf.HookURL, conf.AuthToken, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			message = fmt.Sprintf(`{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":" %s (%s) "}]}]}}`,
 | 
			
		||||
				strconv.FormatFloat(maxCvss.Value.Score, 'f', 1, 64),
 | 
			
		||||
				severity,
 | 
			
		||||
			)
 | 
			
		||||
			if err = w.sendMessage(conf.HookURL, conf.AuthToken, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			message = fmt.Sprintf(`{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":" %s "}]}]}}`,
 | 
			
		||||
				vinfo.Summaries(config.Conf.Lang, r.Family)[0].Value,
 | 
			
		||||
			)
 | 
			
		||||
			if err = w.sendMessage(conf.HookURL, conf.AuthToken, message); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (w strideSender) sendMessage(uri, token, jsonStr string) error {
 | 
			
		||||
	reqs, err := http.NewRequest("POST", uri, bytes.NewBuffer([]byte(jsonStr)))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	reqs.Header.Add("Content-Type", "application/json")
 | 
			
		||||
	reqs.Header.Add("Authorization", "Bearer "+token)
 | 
			
		||||
	client := &http.Client{}
 | 
			
		||||
	resp, err := client.Do(reqs)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer resp.Body.Close()
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								report/stride_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								report/stride_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
package report
 | 
			
		||||
							
								
								
									
										111
									
								
								report/syslog.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								report/syslog.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2018  Future Corporation , 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 report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	syslog "github.com/RackSec/srslog"
 | 
			
		||||
 | 
			
		||||
	"github.com/pkg/errors"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// SyslogWriter send report to syslog
 | 
			
		||||
type SyslogWriter struct{}
 | 
			
		||||
 | 
			
		||||
func (w SyslogWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	conf := config.Conf.Syslog
 | 
			
		||||
	facility, _ := conf.GetFacility()
 | 
			
		||||
	severity, _ := conf.GetSeverity()
 | 
			
		||||
	raddr := fmt.Sprintf("%s:%s", conf.Host, conf.Port)
 | 
			
		||||
 | 
			
		||||
	sysLog, err := syslog.Dial(conf.Protocol, raddr, severity|facility, conf.Tag)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return errors.Wrap(err, "Failed to initialize syslog client")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		messages := w.encodeSyslog(r)
 | 
			
		||||
		for _, m := range messages {
 | 
			
		||||
			if _, err = fmt.Fprintf(sysLog, m); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (w SyslogWriter) encodeSyslog(result models.ScanResult) (messages []string) {
 | 
			
		||||
	ipv4Addrs := strings.Join(result.IPv4Addrs, ",")
 | 
			
		||||
	ipv6Addrs := strings.Join(result.IPv6Addrs, ",")
 | 
			
		||||
 | 
			
		||||
	var commonKvPairs []string
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`scanned_at="%s"`, result.ScannedAt))
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`server_name="%s"`, result.ServerName))
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`os_family="%s"`, result.Family))
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`os_release="%s"`, result.Release))
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`ipv4_addr="%s"`, ipv4Addrs))
 | 
			
		||||
	commonKvPairs = append(commonKvPairs, fmt.Sprintf(`ipv6_addr="%s"`, ipv6Addrs))
 | 
			
		||||
 | 
			
		||||
	for cveID, vinfo := range result.ScannedCves {
 | 
			
		||||
		kvPairs := commonKvPairs
 | 
			
		||||
 | 
			
		||||
		var pkgNames []string
 | 
			
		||||
		for _, pkg := range vinfo.AffectedPackages {
 | 
			
		||||
			pkgNames = append(pkgNames, pkg.Name)
 | 
			
		||||
		}
 | 
			
		||||
		pkgs := strings.Join(pkgNames, ",")
 | 
			
		||||
		kvPairs = append(kvPairs, fmt.Sprintf(`packages="%s"`, pkgs))
 | 
			
		||||
 | 
			
		||||
		kvPairs = append(kvPairs, fmt.Sprintf(`cve_id="%s"`, cveID))
 | 
			
		||||
		for _, cvss := range vinfo.Cvss2Scores(result.Family) {
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`cvss_score_%s_v2="%.2f"`, cvss.Type, cvss.Value.Score))
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`cvss_vector_%s_v2="%s"`, cvss.Type, cvss.Value.Vector))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, cvss := range vinfo.Cvss3Scores() {
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`cvss_score_%s_v3="%.2f"`, cvss.Type, cvss.Value.Score))
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`cvss_vector_%s_v3="%s"`, cvss.Type, cvss.Value.Vector))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if content, ok := vinfo.CveContents[models.NvdXML]; ok {
 | 
			
		||||
			cwes := strings.Join(content.CweIDs, ",")
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`cwe_ids="%s"`, cwes))
 | 
			
		||||
			if config.Conf.Syslog.Verbose {
 | 
			
		||||
				kvPairs = append(kvPairs, fmt.Sprintf(`source_link="%s"`, content.SourceLink))
 | 
			
		||||
				kvPairs = append(kvPairs, fmt.Sprintf(`summary="%s"`, content.Summary))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if content, ok := vinfo.CveContents[models.RedHat]; ok {
 | 
			
		||||
			kvPairs = append(kvPairs, fmt.Sprintf(`title="%s"`, content.Title))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// message: key1="value1" key2="value2"...
 | 
			
		||||
		messages = append(messages, strings.Join(kvPairs, " "))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(messages) == 0 {
 | 
			
		||||
		commonKvPairs = append(commonKvPairs, `message="No CVE-IDs are found"`)
 | 
			
		||||
		messages = append(messages, strings.Join(commonKvPairs, " "))
 | 
			
		||||
	}
 | 
			
		||||
	return messages
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										111
									
								
								report/syslog_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								report/syslog_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"sort"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestSyslogWriterEncodeSyslog(t *testing.T) {
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		result           models.ScanResult
 | 
			
		||||
		expectedMessages []string
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			result: models.ScanResult{
 | 
			
		||||
				ScannedAt:  time.Date(2018, 6, 13, 16, 10, 0, 0, time.UTC),
 | 
			
		||||
				ServerName: "teste01",
 | 
			
		||||
				Family:     "ubuntu",
 | 
			
		||||
				Release:    "16.04",
 | 
			
		||||
				IPv4Addrs:  []string{"192.168.0.1", "10.0.2.15"},
 | 
			
		||||
				ScannedCves: models.VulnInfos{
 | 
			
		||||
					"CVE-2017-0001": models.VulnInfo{
 | 
			
		||||
						AffectedPackages: models.PackageStatuses{
 | 
			
		||||
							models.PackageStatus{Name: "pkg1"},
 | 
			
		||||
							models.PackageStatus{Name: "pkg2"},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					"CVE-2017-0002": models.VulnInfo{
 | 
			
		||||
						AffectedPackages: models.PackageStatuses{
 | 
			
		||||
							models.PackageStatus{Name: "pkg3"},
 | 
			
		||||
							models.PackageStatus{Name: "pkg4"},
 | 
			
		||||
						},
 | 
			
		||||
						CveContents: models.CveContents{
 | 
			
		||||
							models.NvdXML: models.CveContent{
 | 
			
		||||
								Cvss2Score:    5.0,
 | 
			
		||||
								Cvss2Vector:   "AV:L/AC:L/Au:N/C:N/I:N/A:C",
 | 
			
		||||
								Cvss2Severity: "MEDIUM",
 | 
			
		||||
								CweIDs:        []string{"CWE-20"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			expectedMessages: []string{
 | 
			
		||||
				`scanned_at="2018-06-13 16:10:00 +0000 UTC" server_name="teste01" os_family="ubuntu" os_release="16.04" ipv4_addr="192.168.0.1,10.0.2.15" ipv6_addr="" packages="pkg1,pkg2" cve_id="CVE-2017-0001"`,
 | 
			
		||||
				`scanned_at="2018-06-13 16:10:00 +0000 UTC" server_name="teste01" os_family="ubuntu" os_release="16.04" ipv4_addr="192.168.0.1,10.0.2.15" ipv6_addr="" packages="pkg3,pkg4" cve_id="CVE-2017-0002" cvss_score_nvdxml_v2="5.00" cvss_vector_nvdxml_v2="AV:L/AC:L/Au:N/C:N/I:N/A:C" cwe_ids="CWE-20"`,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			result: models.ScanResult{
 | 
			
		||||
				ScannedAt:  time.Date(2018, 6, 13, 17, 10, 0, 0, time.UTC),
 | 
			
		||||
				ServerName: "teste02",
 | 
			
		||||
				Family:     "centos",
 | 
			
		||||
				Release:    "6",
 | 
			
		||||
				IPv6Addrs:  []string{"2001:0DB8::1"},
 | 
			
		||||
				ScannedCves: models.VulnInfos{
 | 
			
		||||
					"CVE-2017-0003": models.VulnInfo{
 | 
			
		||||
						AffectedPackages: models.PackageStatuses{
 | 
			
		||||
							models.PackageStatus{Name: "pkg5"},
 | 
			
		||||
						},
 | 
			
		||||
						CveContents: models.CveContents{
 | 
			
		||||
							models.RedHat: models.CveContent{
 | 
			
		||||
								Cvss3Score:  5.0,
 | 
			
		||||
								Cvss3Vector: "AV:L/AC:L/Au:N/C:N/I:N/A:C",
 | 
			
		||||
								CweIDs:      []string{"CWE-284"},
 | 
			
		||||
								Title:       "RHSA-2017:0001: pkg5 security update (Important)",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			expectedMessages: []string{
 | 
			
		||||
				`scanned_at="2018-06-13 17:10:00 +0000 UTC" server_name="teste02" os_family="centos" os_release="6" ipv4_addr="" ipv6_addr="2001:0DB8::1" packages="pkg5" cve_id="CVE-2017-0003" cvss_score_redhat_v3="5.00" cvss_vector_redhat_v3="AV:L/AC:L/Au:N/C:N/I:N/A:C" title="RHSA-2017:0001: pkg5 security update (Important)"`,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			result: models.ScanResult{
 | 
			
		||||
				ScannedAt:   time.Date(2018, 6, 13, 12, 10, 0, 0, time.UTC),
 | 
			
		||||
				ServerName:  "teste03",
 | 
			
		||||
				Family:      "centos",
 | 
			
		||||
				Release:     "7",
 | 
			
		||||
				IPv6Addrs:   []string{"2001:0DB8::1"},
 | 
			
		||||
				ScannedCves: models.VulnInfos{},
 | 
			
		||||
			},
 | 
			
		||||
			expectedMessages: []string{
 | 
			
		||||
				`scanned_at="2018-06-13 12:10:00 +0000 UTC" server_name="teste03" os_family="centos" os_release="7" ipv4_addr="" ipv6_addr="2001:0DB8::1" message="No CVE-IDs are found"`,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		messages := SyslogWriter{}.encodeSyslog(tt.result)
 | 
			
		||||
		if len(messages) != len(tt.expectedMessages) {
 | 
			
		||||
			t.Fatalf("test: %d, Message Length: expected %d, actual: %d",
 | 
			
		||||
				i, len(tt.expectedMessages), len(messages))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		sort.Slice(messages, func(i, j int) bool {
 | 
			
		||||
			return messages[i] < messages[j]
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		for j, m := range messages {
 | 
			
		||||
			e := tt.expectedMessages[j]
 | 
			
		||||
			if e != m {
 | 
			
		||||
				t.Errorf("test: %d, Messsage %d: \nexpected %s \nactual   %s", i, j, e, m)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										77
									
								
								report/telegram.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								report/telegram.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TelegramWriter sends report to Telegram
 | 
			
		||||
type TelegramWriter struct{}
 | 
			
		||||
 | 
			
		||||
func (w TelegramWriter) Write(rs ...models.ScanResult) (err error) {
 | 
			
		||||
	conf := config.Conf.Telegram
 | 
			
		||||
	for _, r := range rs {
 | 
			
		||||
		msgs := []string{fmt.Sprintf("*%s*\n%s\n%s\n%s",
 | 
			
		||||
			r.ServerInfo(),
 | 
			
		||||
			r.ScannedCves.FormatCveSummary(),
 | 
			
		||||
			r.ScannedCves.FormatFixedStatus(r.Packages),
 | 
			
		||||
			r.FormatUpdatablePacksSummary())}
 | 
			
		||||
		for _, vinfo := range r.ScannedCves {
 | 
			
		||||
			maxCvss := vinfo.MaxCvssScore()
 | 
			
		||||
			severity := strings.ToUpper(maxCvss.Value.Severity)
 | 
			
		||||
			if severity == "" {
 | 
			
		||||
				severity = "?"
 | 
			
		||||
			}
 | 
			
		||||
			msgs = append(msgs, fmt.Sprintf(`[%s](https://nvd.nist.gov/vuln/detail/%s) _%s %s %s_\n%s`,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				vinfo.CveID,
 | 
			
		||||
				strconv.FormatFloat(maxCvss.Value.Score, 'f', 1, 64),
 | 
			
		||||
				severity,
 | 
			
		||||
				maxCvss.Value.Vector,
 | 
			
		||||
				vinfo.Summaries(config.Conf.Lang, r.Family)[0].Value))
 | 
			
		||||
			if len(msgs) == 5 {
 | 
			
		||||
				if err = sendMessage(conf.ChatID, conf.Token, strings.Join(msgs, "\n\n")); err != nil {
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
				msgs = []string{}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if len(msgs) != 0 {
 | 
			
		||||
			if err = sendMessage(conf.ChatID, conf.Token, strings.Join(msgs, "\n\n")); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func sendMessage(chatID, token, message string) error {
 | 
			
		||||
	uri := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", token)
 | 
			
		||||
	payload := `{"text": "` + strings.Replace(message, `"`, `\"`, -1) + `", "chat_id": "` + chatID + `", "parse_mode": "Markdown" }`
 | 
			
		||||
	req, err := http.NewRequest("POST", uri, bytes.NewBuffer([]byte(payload)))
 | 
			
		||||
	req.Header.Add("Content-Type", "application/json")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	client := &http.Client{}
 | 
			
		||||
	resp, err := client.Do(req)
 | 
			
		||||
	if checkResponse(resp) != nil && err != nil {
 | 
			
		||||
		fmt.Println(err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer resp.Body.Close()
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func checkResponse(r *http.Response) error {
 | 
			
		||||
	if c := r.StatusCode; 200 <= c && c <= 299 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Errorf("API call to %s failed: %s", r.Request.URL.String(), r.Status)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								report/telegram_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								report/telegram_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
package report
 | 
			
		||||
							
								
								
									
										328
									
								
								report/tui.go
									
									
									
									
									
								
							
							
						
						
									
										328
									
								
								report/tui.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -26,13 +26,14 @@ import (
 | 
			
		||||
	"text/template"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/alert"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/google/subcommands"
 | 
			
		||||
	"github.com/gosuri/uitable"
 | 
			
		||||
	"github.com/jroimartin/gocui"
 | 
			
		||||
	log "github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var scanResults models.ScanResults
 | 
			
		||||
@@ -52,18 +53,16 @@ func RunTui(results models.ScanResults) subcommands.ExitStatus {
 | 
			
		||||
		return scanResults[i].ServerName < scanResults[j].ServerName
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	// g, err := gocui.NewGui(gocui.OutputNormal)
 | 
			
		||||
	g := gocui.NewGui()
 | 
			
		||||
	if err := g.Init(); err != nil {
 | 
			
		||||
		log.Errorf("%s", err)
 | 
			
		||||
	g, err := gocui.NewGui(gocui.OutputNormal)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		util.Log.Errorf("%s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
	defer g.Close()
 | 
			
		||||
 | 
			
		||||
	g.SetLayout(layout)
 | 
			
		||||
	// g.SetManagerFunc(layout)
 | 
			
		||||
	g.SetManagerFunc(layout)
 | 
			
		||||
	if err := keybindings(g); err != nil {
 | 
			
		||||
		log.Errorf("%s", err)
 | 
			
		||||
		util.Log.Errorf("%s", err)
 | 
			
		||||
		return subcommands.ExitFailure
 | 
			
		||||
	}
 | 
			
		||||
	g.SelBgColor = gocui.ColorGreen
 | 
			
		||||
@@ -72,7 +71,7 @@ func RunTui(results models.ScanResults) subcommands.ExitStatus {
 | 
			
		||||
 | 
			
		||||
	if err := g.MainLoop(); err != nil {
 | 
			
		||||
		g.Close()
 | 
			
		||||
		log.Errorf("%s", err)
 | 
			
		||||
		util.Log.Errorf("%s", err)
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
	return subcommands.ExitSuccess
 | 
			
		||||
@@ -186,19 +185,19 @@ func nextView(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	var err error
 | 
			
		||||
 | 
			
		||||
	if v == nil {
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	}
 | 
			
		||||
	switch v.Name() {
 | 
			
		||||
	case "side":
 | 
			
		||||
		err = g.SetCurrentView("summary")
 | 
			
		||||
		_, err = g.SetCurrentView("summary")
 | 
			
		||||
	case "summary":
 | 
			
		||||
		err = g.SetCurrentView("detail")
 | 
			
		||||
		_, err = g.SetCurrentView("detail")
 | 
			
		||||
	case "detail":
 | 
			
		||||
		err = g.SetCurrentView("changelog")
 | 
			
		||||
		_, err = g.SetCurrentView("changelog")
 | 
			
		||||
	case "changelog":
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	default:
 | 
			
		||||
		err = g.SetCurrentView("summary")
 | 
			
		||||
		_, err = g.SetCurrentView("summary")
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
@@ -207,19 +206,19 @@ func previousView(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	var err error
 | 
			
		||||
 | 
			
		||||
	if v == nil {
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	}
 | 
			
		||||
	switch v.Name() {
 | 
			
		||||
	case "side":
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	case "summary":
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	case "detail":
 | 
			
		||||
		err = g.SetCurrentView("summary")
 | 
			
		||||
		_, err = g.SetCurrentView("summary")
 | 
			
		||||
	case "changelog":
 | 
			
		||||
		err = g.SetCurrentView("detail")
 | 
			
		||||
		_, err = g.SetCurrentView("detail")
 | 
			
		||||
	default:
 | 
			
		||||
		err = g.SetCurrentView("side")
 | 
			
		||||
		_, err = g.SetCurrentView("side")
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
@@ -402,7 +401,7 @@ func cursorPageUp(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
func previousSummary(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	if v != nil {
 | 
			
		||||
		// cursor to summary
 | 
			
		||||
		if err := g.SetCurrentView("summary"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("summary"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		// move next line
 | 
			
		||||
@@ -410,7 +409,7 @@ func previousSummary(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		// cursor to detail
 | 
			
		||||
		if err := g.SetCurrentView("detail"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("detail"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -420,7 +419,7 @@ func previousSummary(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
func nextSummary(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	if v != nil {
 | 
			
		||||
		// cursor to summary
 | 
			
		||||
		if err := g.SetCurrentView("summary"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("summary"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		// move next line
 | 
			
		||||
@@ -428,7 +427,7 @@ func nextSummary(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		// cursor to detail
 | 
			
		||||
		if err := g.SetCurrentView("detail"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("detail"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -468,10 +467,7 @@ func changeHost(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	if err := setDetailLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := setChangelogLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return setChangelogLayout(g)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func redrawDetail(g *gocui.Gui) error {
 | 
			
		||||
@@ -479,10 +475,7 @@ func redrawDetail(g *gocui.Gui) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := setDetailLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return setDetailLayout(g)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func redrawChangelog(g *gocui.Gui) error {
 | 
			
		||||
@@ -490,10 +483,7 @@ func redrawChangelog(g *gocui.Gui) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := setChangelogLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return setChangelogLayout(g)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getLine(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
@@ -511,7 +501,7 @@ func getLine(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		fmt.Fprintln(v, l)
 | 
			
		||||
		if err := g.SetCurrentView("msg"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("msg"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -534,7 +524,7 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		fmt.Fprintln(v, l)
 | 
			
		||||
		if err := g.SetCurrentView("msg"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("msg"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -545,10 +535,8 @@ func delMsg(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
	if err := g.DeleteView("msg"); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := g.SetCurrentView("summary"); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	_, err := g.SetCurrentView("summary")
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func quit(g *gocui.Gui, v *gocui.View) error {
 | 
			
		||||
@@ -565,11 +553,7 @@ func layout(g *gocui.Gui) error {
 | 
			
		||||
	if err := setDetailLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := setChangelogLayout(g); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
	return setChangelogLayout(g)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func debug(g *gocui.Gui, str string) error {
 | 
			
		||||
@@ -601,7 +585,7 @@ func setSideLayout(g *gocui.Gui) error {
 | 
			
		||||
		}
 | 
			
		||||
		currentScanResult = scanResults[0]
 | 
			
		||||
		vinfos = scanResults[0].ScannedCves.ToSortedSlice()
 | 
			
		||||
		if err := g.SetCurrentView("side"); err != nil {
 | 
			
		||||
		if _, err := g.SetCurrentView("side"); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -615,7 +599,7 @@ func setSummaryLayout(g *gocui.Gui) error {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		lines := summaryLines()
 | 
			
		||||
		lines := summaryLines(currentScanResult)
 | 
			
		||||
		fmt.Fprintf(v, lines)
 | 
			
		||||
 | 
			
		||||
		v.Highlight = true
 | 
			
		||||
@@ -625,37 +609,48 @@ func setSummaryLayout(g *gocui.Gui) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func summaryLines() string {
 | 
			
		||||
func summaryLines(r models.ScanResult) string {
 | 
			
		||||
	stable := uitable.New()
 | 
			
		||||
	stable.MaxColWidth = 1000
 | 
			
		||||
	stable.Wrap = false
 | 
			
		||||
 | 
			
		||||
	if len(currentScanResult.Errors) != 0 {
 | 
			
		||||
	if len(r.Errors) != 0 {
 | 
			
		||||
		return "Error: Scan with --debug to view the details"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	indexFormat := ""
 | 
			
		||||
	if len(currentScanResult.ScannedCves) < 10 {
 | 
			
		||||
	if len(r.ScannedCves) < 10 {
 | 
			
		||||
		indexFormat = "[%1d]"
 | 
			
		||||
	} else if len(currentScanResult.ScannedCves) < 100 {
 | 
			
		||||
	} else if len(r.ScannedCves) < 100 {
 | 
			
		||||
		indexFormat = "[%2d]"
 | 
			
		||||
	} else {
 | 
			
		||||
		indexFormat = "[%3d]"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, vinfo := range vinfos {
 | 
			
		||||
		summary := vinfo.Titles(
 | 
			
		||||
			config.Conf.Lang, currentScanResult.Family)[0].Value
 | 
			
		||||
		cvssScore := fmt.Sprintf("| %4.1f",
 | 
			
		||||
			vinfo.MaxCvssScore().Value.Score)
 | 
			
		||||
	for i, vinfo := range r.ScannedCves.ToSortedSlice() {
 | 
			
		||||
		max := vinfo.MaxCvssScore().Value.Score
 | 
			
		||||
		cvssScore := "|     "
 | 
			
		||||
		if 0 < max {
 | 
			
		||||
			cvssScore = fmt.Sprintf("| %4.1f", max)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		packname := vinfo.AffectedPackages.FormatTuiSummary()
 | 
			
		||||
		packname += strings.Join(vinfo.CpeURIs, ", ")
 | 
			
		||||
		packname += vinfo.GitHubSecurityAlerts.String()
 | 
			
		||||
 | 
			
		||||
		alert := "  "
 | 
			
		||||
		if vinfo.AlertDict.HasAlert() {
 | 
			
		||||
			alert = "! "
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var cols []string
 | 
			
		||||
		cols = []string{
 | 
			
		||||
			fmt.Sprintf(indexFormat, i+1),
 | 
			
		||||
			vinfo.CveID,
 | 
			
		||||
			cvssScore,
 | 
			
		||||
			fmt.Sprintf("| %3d |", vinfo.Confidence.Score),
 | 
			
		||||
			summary,
 | 
			
		||||
			alert + vinfo.CveID,
 | 
			
		||||
			cvssScore + " |",
 | 
			
		||||
			fmt.Sprintf("%8s |", vinfo.AttackVector()),
 | 
			
		||||
			fmt.Sprintf("%7s |", vinfo.PatchStatus(r.Packages)),
 | 
			
		||||
			packname,
 | 
			
		||||
		}
 | 
			
		||||
		icols := make([]interface{}, len(cols))
 | 
			
		||||
		for j := range cols {
 | 
			
		||||
@@ -695,16 +690,12 @@ func setDetailLayout(g *gocui.Gui) error {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func setChangelogLayout(g *gocui.Gui) error {
 | 
			
		||||
	maxX, maxY := g.Size()
 | 
			
		||||
 | 
			
		||||
	summaryView, err := g.View("summary")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	_, cy := summaryView.Cursor()
 | 
			
		||||
	_, oy := summaryView.Origin()
 | 
			
		||||
	currentVinfo = cy + oy
 | 
			
		||||
 | 
			
		||||
	maxX, maxY := g.Size()
 | 
			
		||||
	if v, err := g.SetView("changelog", int(float64(maxX)*0.5), int(float64(maxY)*0.2), maxX, maxY); err != nil {
 | 
			
		||||
		if err != gocui.ErrUnknownView {
 | 
			
		||||
			return err
 | 
			
		||||
@@ -713,17 +704,102 @@ func setChangelogLayout(g *gocui.Gui) error {
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		lines := []string{}
 | 
			
		||||
		lines := []string{
 | 
			
		||||
			"Affected Packages, Processes",
 | 
			
		||||
			"============================",
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		_, cy := summaryView.Cursor()
 | 
			
		||||
		_, oy := summaryView.Origin()
 | 
			
		||||
		currentVinfo = cy + oy
 | 
			
		||||
		vinfo := vinfos[currentVinfo]
 | 
			
		||||
		vinfo.AffectedPackages.Sort()
 | 
			
		||||
		for _, affected := range vinfo.AffectedPackages {
 | 
			
		||||
			// packages detected by OVAL may not be actually installed
 | 
			
		||||
			if pack, ok := currentScanResult.Packages[affected.Name]; ok {
 | 
			
		||||
				var line string
 | 
			
		||||
				if pack.Repository != "" {
 | 
			
		||||
					line = fmt.Sprintf("* %s (%s)",
 | 
			
		||||
						pack.FormatVersionFromTo(affected.NotFixedYet, affected.FixState),
 | 
			
		||||
						pack.Repository)
 | 
			
		||||
				} else {
 | 
			
		||||
					line = fmt.Sprintf("* %s",
 | 
			
		||||
						pack.FormatVersionFromTo(affected.NotFixedYet, affected.FixState),
 | 
			
		||||
					)
 | 
			
		||||
				}
 | 
			
		||||
				lines = append(lines, line)
 | 
			
		||||
 | 
			
		||||
				if len(pack.AffectedProcs) != 0 {
 | 
			
		||||
					for _, p := range pack.AffectedProcs {
 | 
			
		||||
						lines = append(lines, fmt.Sprintf("  * PID: %s %s", p.PID, p.Name))
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					// lines = append(lines, fmt.Sprintf("  * No affected process"))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		sort.Strings(vinfo.CpeURIs)
 | 
			
		||||
		for _, uri := range vinfo.CpeURIs {
 | 
			
		||||
			lines = append(lines, "* "+uri)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, alert := range vinfo.GitHubSecurityAlerts {
 | 
			
		||||
			lines = append(lines, "* "+alert.PackageName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, adv := range vinfo.DistroAdvisories {
 | 
			
		||||
			lines = append(lines, "\n",
 | 
			
		||||
				"Advisories",
 | 
			
		||||
				"==========",
 | 
			
		||||
			)
 | 
			
		||||
			lines = append(lines, adv.Format())
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, affected := range vinfo.AffectedPackages {
 | 
			
		||||
			pack := currentScanResult.Packages[affected.Name]
 | 
			
		||||
			for _, p := range currentScanResult.Packages {
 | 
			
		||||
				if pack.Name == p.Name {
 | 
			
		||||
					lines = append(lines, p.FormatChangelog(), "\n")
 | 
			
		||||
		if len(vinfo.Exploits) != 0 {
 | 
			
		||||
			lines = append(lines, "\n",
 | 
			
		||||
				"Exploit Codes",
 | 
			
		||||
				"=============",
 | 
			
		||||
			)
 | 
			
		||||
			for _, exploit := range vinfo.Exploits {
 | 
			
		||||
				lines = append(lines, fmt.Sprintf("* [%s](%s)", exploit.Description, exploit.URL))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(vinfo.AlertDict.En) > 0 {
 | 
			
		||||
			lines = append(lines, "\n",
 | 
			
		||||
				"USCERT Alert",
 | 
			
		||||
				"=============",
 | 
			
		||||
			)
 | 
			
		||||
			for _, alert := range vinfo.AlertDict.En {
 | 
			
		||||
				lines = append(lines, fmt.Sprintf("* [%s](%s)", alert.Title, alert.URL))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(vinfo.AlertDict.Ja) > 0 {
 | 
			
		||||
			lines = append(lines, "\n",
 | 
			
		||||
				"JPCERT Alert",
 | 
			
		||||
				"=============",
 | 
			
		||||
			)
 | 
			
		||||
			for _, alert := range vinfo.AlertDict.Ja {
 | 
			
		||||
				if config.Conf.Lang == "ja" {
 | 
			
		||||
					lines = append(lines, fmt.Sprintf("* [%s](%s)", alert.Title, alert.URL))
 | 
			
		||||
				} else {
 | 
			
		||||
					lines = append(lines, fmt.Sprintf("* [JPCERT](%s)", alert.URL))
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if currentScanResult.IsDeepScanMode() {
 | 
			
		||||
			lines = append(lines, "\n",
 | 
			
		||||
				"ChangeLogs",
 | 
			
		||||
				"==========",
 | 
			
		||||
			)
 | 
			
		||||
			for _, affected := range vinfo.AffectedPackages {
 | 
			
		||||
				pack := currentScanResult.Packages[affected.Name]
 | 
			
		||||
				for _, p := range currentScanResult.Packages {
 | 
			
		||||
					if pack.Name == p.Name {
 | 
			
		||||
						lines = append(lines, p.FormatChangelog(), "\n")
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -740,13 +816,16 @@ func setChangelogLayout(g *gocui.Gui) error {
 | 
			
		||||
type dataForTmpl struct {
 | 
			
		||||
	CveID            string
 | 
			
		||||
	Cvsses           string
 | 
			
		||||
	Exploits         []models.Exploit
 | 
			
		||||
	Summary          string
 | 
			
		||||
	Confidence       models.Confidence
 | 
			
		||||
	Cwes             []models.CveContentStr
 | 
			
		||||
	Mitigation       string
 | 
			
		||||
	Confidences      models.Confidences
 | 
			
		||||
	Cwes             []models.CweDictEntry
 | 
			
		||||
	Alerts           []alert.Alert
 | 
			
		||||
	Links            []string
 | 
			
		||||
	References       []models.Reference
 | 
			
		||||
	Packages         []string
 | 
			
		||||
	CpeNames         []string
 | 
			
		||||
	CpeURIs          []string
 | 
			
		||||
	PublishedDate    time.Time
 | 
			
		||||
	LastModifiedDate time.Time
 | 
			
		||||
}
 | 
			
		||||
@@ -767,20 +846,6 @@ func detailLines() (string, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vinfo := vinfos[currentVinfo]
 | 
			
		||||
 | 
			
		||||
	packsVer := []string{}
 | 
			
		||||
	vinfo.AffectedPackages.Sort()
 | 
			
		||||
	for _, affected := range vinfo.AffectedPackages {
 | 
			
		||||
		// packages detected by OVAL may not be actually installed
 | 
			
		||||
		if pack, ok := r.Packages[affected.Name]; ok {
 | 
			
		||||
			packsVer = append(packsVer, pack.FormatVersionFromTo(affected.NotFixedYet))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	sort.Strings(vinfo.CpeNames)
 | 
			
		||||
	for _, name := range vinfo.CpeNames {
 | 
			
		||||
		packsVer = append(packsVer, name)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	links := []string{vinfo.CveContents.SourceLinks(
 | 
			
		||||
		config.Conf.Lang, r.Family, vinfo.CveID)[0].Value,
 | 
			
		||||
		vinfo.Cvss2CalcURL(),
 | 
			
		||||
@@ -792,35 +857,57 @@ func detailLines() (string, error) {
 | 
			
		||||
	refs := []models.Reference{}
 | 
			
		||||
	for _, rr := range vinfo.CveContents.References(r.Family) {
 | 
			
		||||
		for _, ref := range rr.Value {
 | 
			
		||||
			if ref.Source == "" {
 | 
			
		||||
				ref.Source = "-"
 | 
			
		||||
			}
 | 
			
		||||
			refs = append(refs, ref)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	summary := vinfo.Summaries(r.Lang, r.Family)[0]
 | 
			
		||||
	mitigation := vinfo.Mitigations(r.Family)[0]
 | 
			
		||||
 | 
			
		||||
	table := uitable.New()
 | 
			
		||||
	table.MaxColWidth = maxColWidth
 | 
			
		||||
	table.Wrap = true
 | 
			
		||||
	scores := append(vinfo.Cvss3Scores(), vinfo.Cvss2Scores()...)
 | 
			
		||||
	scores := append(vinfo.Cvss3Scores(), vinfo.Cvss2Scores(r.Family)...)
 | 
			
		||||
	var cols []interface{}
 | 
			
		||||
	for _, score := range scores {
 | 
			
		||||
		if score.Value.Score == 0 && score.Value.Severity == "" {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		scoreStr := "-"
 | 
			
		||||
		if 0 < score.Value.Score {
 | 
			
		||||
			scoreStr = fmt.Sprintf("%3.1f", score.Value.Score)
 | 
			
		||||
		}
 | 
			
		||||
		scoreVec := fmt.Sprintf("%s/%s", scoreStr, score.Value.Vector)
 | 
			
		||||
		cols = []interface{}{
 | 
			
		||||
			scoreVec,
 | 
			
		||||
			score.Value.Severity,
 | 
			
		||||
			score.Value.Format(),
 | 
			
		||||
			score.Type,
 | 
			
		||||
		}
 | 
			
		||||
		table.AddRow(cols...)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uniqCweIDs := vinfo.CveContents.UniqCweIDs(r.Family)
 | 
			
		||||
	cwes := []models.CweDictEntry{}
 | 
			
		||||
	for _, cweID := range uniqCweIDs {
 | 
			
		||||
		if strings.HasPrefix(cweID.Value, "CWE-") {
 | 
			
		||||
			if dict, ok := r.CweDict[strings.TrimPrefix(cweID.Value, "CWE-")]; ok {
 | 
			
		||||
				cwes = append(cwes, dict)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := dataForTmpl{
 | 
			
		||||
		CveID:      vinfo.CveID,
 | 
			
		||||
		Cvsses:     fmt.Sprintf("%s\n", table),
 | 
			
		||||
		Summary:    fmt.Sprintf("%s (%s)", summary.Value, summary.Type),
 | 
			
		||||
		Confidence: vinfo.Confidence,
 | 
			
		||||
		Cwes:       vinfo.CveContents.CweIDs(r.Family),
 | 
			
		||||
		Links:      util.Distinct(links),
 | 
			
		||||
		Packages:   packsVer,
 | 
			
		||||
		References: refs,
 | 
			
		||||
		CveID:       vinfo.CveID,
 | 
			
		||||
		Cvsses:      fmt.Sprintf("%s\n", table),
 | 
			
		||||
		Summary:     fmt.Sprintf("%s (%s)", summary.Value, summary.Type),
 | 
			
		||||
		Mitigation:  fmt.Sprintf("%s (%s)", mitigation.Value, mitigation.Type),
 | 
			
		||||
		Confidences: vinfo.Confidences,
 | 
			
		||||
		Cwes:        cwes,
 | 
			
		||||
		Links:       util.Distinct(links),
 | 
			
		||||
		References:  refs,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	buf := bytes.NewBuffer(nil) // create empty buffer
 | 
			
		||||
@@ -833,47 +920,42 @@ func detailLines() (string, error) {
 | 
			
		||||
 | 
			
		||||
const mdTemplate = `
 | 
			
		||||
{{.CveID}}
 | 
			
		||||
==============
 | 
			
		||||
================
 | 
			
		||||
 | 
			
		||||
CVSS Scores
 | 
			
		||||
--------------
 | 
			
		||||
-----------
 | 
			
		||||
{{.Cvsses }}
 | 
			
		||||
 | 
			
		||||
Summary
 | 
			
		||||
--------------
 | 
			
		||||
-----------
 | 
			
		||||
 {{.Summary }}
 | 
			
		||||
 | 
			
		||||
Mitigation
 | 
			
		||||
-----------
 | 
			
		||||
 {{.Mitigation }}
 | 
			
		||||
 | 
			
		||||
Links
 | 
			
		||||
--------------
 | 
			
		||||
-----------
 | 
			
		||||
{{range $link := .Links -}}
 | 
			
		||||
* {{$link}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
CWE
 | 
			
		||||
--------------
 | 
			
		||||
-----------
 | 
			
		||||
{{range .Cwes -}}
 | 
			
		||||
* {{.Value}} ({{.Type}})
 | 
			
		||||
* {{.En.CweID}} [{{.En.Name}}](https://cwe.mitre.org/data/definitions/{{.En.CweID}}.html)
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
Package/CPE
 | 
			
		||||
--------------
 | 
			
		||||
{{range $pack := .Packages -}}
 | 
			
		||||
* {{$pack}}
 | 
			
		||||
{{end -}}
 | 
			
		||||
{{range $name := .CpeNames -}}
 | 
			
		||||
{{range $name := .CpeURIs -}}
 | 
			
		||||
* {{$name}}
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
Confidence
 | 
			
		||||
--------------
 | 
			
		||||
 {{.Confidence }}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-----------
 | 
			
		||||
{{range $confidence := .Confidences -}}
 | 
			
		||||
* {{$confidence.DetectionMethod}}
 | 
			
		||||
{{end}}
 | 
			
		||||
References
 | 
			
		||||
--------------
 | 
			
		||||
-----------
 | 
			
		||||
{{range .References -}}
 | 
			
		||||
* [{{.Source}}]( {{.Link}} )
 | 
			
		||||
* [{{.Source}}]({{.Link}})
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
`
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										365
									
								
								report/util.go
									
									
									
									
									
								
							
							
						
						
									
										365
									
								
								report/util.go
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -18,11 +18,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"strings"
 | 
			
		||||
@@ -32,9 +34,10 @@ import (
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/gosuri/uitable"
 | 
			
		||||
	"github.com/olekukonko/tablewriter"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const maxColWidth = 80
 | 
			
		||||
const maxColWidth = 100
 | 
			
		||||
 | 
			
		||||
func formatScanSummary(rs ...models.ScanResult) string {
 | 
			
		||||
	table := uitable.New()
 | 
			
		||||
@@ -46,7 +49,7 @@ func formatScanSummary(rs ...models.ScanResult) string {
 | 
			
		||||
			cols = []interface{}{
 | 
			
		||||
				r.FormatServerName(),
 | 
			
		||||
				fmt.Sprintf("%s%s", r.Family, r.Release),
 | 
			
		||||
				r.Packages.FormatUpdatablePacksSummary(),
 | 
			
		||||
				r.FormatUpdatablePacksSummary(),
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			cols = []interface{}{
 | 
			
		||||
@@ -71,7 +74,10 @@ func formatOneLineSummary(rs ...models.ScanResult) string {
 | 
			
		||||
			cols = []interface{}{
 | 
			
		||||
				r.FormatServerName(),
 | 
			
		||||
				r.ScannedCves.FormatCveSummary(),
 | 
			
		||||
				r.Packages.FormatUpdatablePacksSummary(),
 | 
			
		||||
				r.ScannedCves.FormatFixedStatus(r.Packages),
 | 
			
		||||
				r.FormatUpdatablePacksSummary(),
 | 
			
		||||
				r.FormatExploitCveSummary(),
 | 
			
		||||
				r.FormatAlertSummary(),
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			cols = []interface{}{
 | 
			
		||||
@@ -85,7 +91,7 @@ func formatOneLineSummary(rs ...models.ScanResult) string {
 | 
			
		||||
	return fmt.Sprintf("%s\n", table)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func formatShortPlainText(r models.ScanResult) string {
 | 
			
		||||
func formatList(r models.ScanResult) string {
 | 
			
		||||
	header := r.FormatTextReportHeadedr()
 | 
			
		||||
	if len(r.Errors) != 0 {
 | 
			
		||||
		return fmt.Sprintf(
 | 
			
		||||
@@ -98,63 +104,58 @@ func formatShortPlainText(r models.ScanResult) string {
 | 
			
		||||
%s
 | 
			
		||||
No CVE-IDs are found in updatable packages.
 | 
			
		||||
%s
 | 
			
		||||
	 `, header, r.Packages.FormatUpdatablePacksSummary())
 | 
			
		||||
`, header, r.FormatUpdatablePacksSummary())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	stable := uitable.New()
 | 
			
		||||
	stable.MaxColWidth = maxColWidth
 | 
			
		||||
	stable.Wrap = true
 | 
			
		||||
	for _, vuln := range r.ScannedCves.ToSortedSlice() {
 | 
			
		||||
		summaries := vuln.Summaries(config.Conf.Lang, r.Family)
 | 
			
		||||
		links := vuln.CveContents.SourceLinks(
 | 
			
		||||
			config.Conf.Lang, r.Family, vuln.CveID)
 | 
			
		||||
	data := [][]string{}
 | 
			
		||||
	for _, vinfo := range r.ScannedCves.ToSortedSlice() {
 | 
			
		||||
		max := vinfo.MaxCvssScore().Value.Score
 | 
			
		||||
		// v2max := vinfo.MaxCvss2Score().Value.Score
 | 
			
		||||
		// v3max := vinfo.MaxCvss3Score().Value.Score
 | 
			
		||||
 | 
			
		||||
		vlinks := []string{}
 | 
			
		||||
		for name, url := range vuln.VendorLinks(r.Family) {
 | 
			
		||||
			vlinks = append(vlinks, fmt.Sprintf("%s (%s)", url, name))
 | 
			
		||||
		// packname := vinfo.AffectedPackages.FormatTuiSummary()
 | 
			
		||||
		// packname += strings.Join(vinfo.CpeURIs, ", ")
 | 
			
		||||
 | 
			
		||||
		exploits := ""
 | 
			
		||||
		if 0 < len(vinfo.Exploits) {
 | 
			
		||||
			exploits = "   Y"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cvsses := ""
 | 
			
		||||
		for _, cvss := range vuln.Cvss2Scores() {
 | 
			
		||||
			cvsses += fmt.Sprintf("%s (%s)\n", cvss.Value.Format(), cvss.Type)
 | 
			
		||||
		}
 | 
			
		||||
		cvsses += vuln.Cvss2CalcURL() + "\n"
 | 
			
		||||
		for _, cvss := range vuln.Cvss3Scores() {
 | 
			
		||||
			cvsses += fmt.Sprintf("%s (%s)\n", cvss.Value.Format(), cvss.Type)
 | 
			
		||||
		}
 | 
			
		||||
		if 0 < len(vuln.Cvss3Scores()) {
 | 
			
		||||
			cvsses += vuln.Cvss3CalcURL() + "\n"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		maxCvss := vuln.FormatMaxCvssScore()
 | 
			
		||||
		rightCol := fmt.Sprintf(`%s
 | 
			
		||||
%s
 | 
			
		||||
---
 | 
			
		||||
%s
 | 
			
		||||
%s
 | 
			
		||||
%sConfidence: %v`,
 | 
			
		||||
			maxCvss,
 | 
			
		||||
			summaries[0].Value,
 | 
			
		||||
			links[0].Value,
 | 
			
		||||
			strings.Join(vlinks, "\n"),
 | 
			
		||||
			cvsses,
 | 
			
		||||
			//  packsVer,
 | 
			
		||||
			vuln.Confidence,
 | 
			
		||||
		)
 | 
			
		||||
 | 
			
		||||
		leftCol := fmt.Sprintf("%s", vuln.CveID)
 | 
			
		||||
		scols := []string{leftCol, rightCol}
 | 
			
		||||
		cols := make([]interface{}, len(scols))
 | 
			
		||||
		for i := range cols {
 | 
			
		||||
			cols[i] = scols[i]
 | 
			
		||||
		}
 | 
			
		||||
		stable.AddRow(cols...)
 | 
			
		||||
		stable.AddRow("")
 | 
			
		||||
		data = append(data, []string{
 | 
			
		||||
			vinfo.CveID,
 | 
			
		||||
			vinfo.AlertDict.FormatSource(),
 | 
			
		||||
			fmt.Sprintf("%4.1f", max),
 | 
			
		||||
			// fmt.Sprintf("%4.1f", v2max),
 | 
			
		||||
			// fmt.Sprintf("%4.1f", v3max),
 | 
			
		||||
			fmt.Sprintf("%8s", vinfo.AttackVector()),
 | 
			
		||||
			fmt.Sprintf("%7s", vinfo.PatchStatus(r.Packages)),
 | 
			
		||||
			// packname,
 | 
			
		||||
			fmt.Sprintf("https://nvd.nist.gov/vuln/detail/%s", vinfo.CveID),
 | 
			
		||||
			exploits,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Sprintf("%s\n%s\n", header, stable)
 | 
			
		||||
 | 
			
		||||
	b := bytes.Buffer{}
 | 
			
		||||
	table := tablewriter.NewWriter(&b)
 | 
			
		||||
	table.SetHeader([]string{
 | 
			
		||||
		"CVE-ID",
 | 
			
		||||
		"CERT",
 | 
			
		||||
		"CVSS",
 | 
			
		||||
		// "v3",
 | 
			
		||||
		// "v2",
 | 
			
		||||
		"Attack",
 | 
			
		||||
		"Fixed",
 | 
			
		||||
		// "Pkg",
 | 
			
		||||
		"NVD",
 | 
			
		||||
		"Exploit",
 | 
			
		||||
	})
 | 
			
		||||
	table.SetBorder(true)
 | 
			
		||||
	table.AppendBulk(data)
 | 
			
		||||
	table.Render()
 | 
			
		||||
	return fmt.Sprintf("%s\n%s", header, b.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func formatFullPlainText(r models.ScanResult) string {
 | 
			
		||||
func formatFullPlainText(r models.ScanResult) (lines string) {
 | 
			
		||||
	header := r.FormatTextReportHeadedr()
 | 
			
		||||
	if len(r.Errors) != 0 {
 | 
			
		||||
		return fmt.Sprintf(
 | 
			
		||||
@@ -167,62 +168,138 @@ func formatFullPlainText(r models.ScanResult) string {
 | 
			
		||||
%s
 | 
			
		||||
No CVE-IDs are found in updatable packages.
 | 
			
		||||
%s
 | 
			
		||||
	 `, header, r.Packages.FormatUpdatablePacksSummary())
 | 
			
		||||
`, header, r.FormatUpdatablePacksSummary())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	table := uitable.New()
 | 
			
		||||
	table.MaxColWidth = maxColWidth
 | 
			
		||||
	table.Wrap = true
 | 
			
		||||
	lines = header + "\n"
 | 
			
		||||
 | 
			
		||||
	for _, vuln := range r.ScannedCves.ToSortedSlice() {
 | 
			
		||||
		table.AddRow(vuln.CveID)
 | 
			
		||||
		table.AddRow("----------------")
 | 
			
		||||
		table.AddRow("Max Score", vuln.FormatMaxCvssScore())
 | 
			
		||||
		for _, cvss := range vuln.Cvss2Scores() {
 | 
			
		||||
			table.AddRow(cvss.Type, cvss.Value.Format())
 | 
			
		||||
		}
 | 
			
		||||
		data := [][]string{}
 | 
			
		||||
		data = append(data, []string{"Max Score", vuln.FormatMaxCvssScore()})
 | 
			
		||||
		for _, cvss := range vuln.Cvss3Scores() {
 | 
			
		||||
			table.AddRow(cvss.Type, cvss.Value.Format())
 | 
			
		||||
		}
 | 
			
		||||
		if 0 < len(vuln.Cvss2Scores()) {
 | 
			
		||||
			table.AddRow("CVSSv2 Calc", vuln.Cvss2CalcURL())
 | 
			
		||||
		}
 | 
			
		||||
		if 0 < len(vuln.Cvss3Scores()) {
 | 
			
		||||
			table.AddRow("CVSSv3 Calc", vuln.Cvss3CalcURL())
 | 
			
		||||
		}
 | 
			
		||||
		table.AddRow("Summary", vuln.Summaries(
 | 
			
		||||
			config.Conf.Lang, r.Family)[0].Value)
 | 
			
		||||
 | 
			
		||||
		links := vuln.CveContents.SourceLinks(
 | 
			
		||||
			config.Conf.Lang, r.Family, vuln.CveID)
 | 
			
		||||
		table.AddRow("Source", links[0].Value)
 | 
			
		||||
 | 
			
		||||
		vlinks := vuln.VendorLinks(r.Family)
 | 
			
		||||
		for name, url := range vlinks {
 | 
			
		||||
			table.AddRow(name, url)
 | 
			
		||||
			if cvssstr := cvss.Value.Format(); cvssstr != "" {
 | 
			
		||||
				data = append(data, []string{string(cvss.Type), cvssstr})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, v := range vuln.CveContents.CweIDs(r.Family) {
 | 
			
		||||
			table.AddRow(fmt.Sprintf("%s (%s)", v.Value, v.Type), cweURL(v.Value))
 | 
			
		||||
		for _, cvss := range vuln.Cvss2Scores(r.Family) {
 | 
			
		||||
			if cvssstr := cvss.Value.Format(); cvssstr != "" {
 | 
			
		||||
				data = append(data, []string{string(cvss.Type), cvssstr})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		data = append(data, []string{"Summary", vuln.Summaries(
 | 
			
		||||
			config.Conf.Lang, r.Family)[0].Value})
 | 
			
		||||
 | 
			
		||||
		mitigation := vuln.Mitigations(r.Family)[0]
 | 
			
		||||
		if mitigation.Type != models.Unknown {
 | 
			
		||||
			data = append(data, []string{"Mitigation", mitigation.Value})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cweURLs, top10URLs := []string{}, []string{}
 | 
			
		||||
		for _, v := range vuln.CveContents.UniqCweIDs(r.Family) {
 | 
			
		||||
			name, url, top10Rank, top10URL := r.CweDict.Get(v.Value, r.Lang)
 | 
			
		||||
			if top10Rank != "" {
 | 
			
		||||
				data = append(data, []string{"CWE",
 | 
			
		||||
					fmt.Sprintf("[OWASP Top%s] %s: %s (%s)",
 | 
			
		||||
						top10Rank, v.Value, name, v.Type)})
 | 
			
		||||
				top10URLs = append(top10URLs, top10URL)
 | 
			
		||||
			} else {
 | 
			
		||||
				data = append(data, []string{"CWE", fmt.Sprintf("%s: %s (%s)",
 | 
			
		||||
					v.Value, name, v.Type)})
 | 
			
		||||
			}
 | 
			
		||||
			cweURLs = append(cweURLs, url)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		packsVer := []string{}
 | 
			
		||||
		vuln.AffectedPackages.Sort()
 | 
			
		||||
		for _, affected := range vuln.AffectedPackages {
 | 
			
		||||
			if pack, ok := r.Packages[affected.Name]; ok {
 | 
			
		||||
				packsVer = append(packsVer, pack.FormatVersionFromTo(affected.NotFixedYet))
 | 
			
		||||
				var line string
 | 
			
		||||
				if pack.Repository != "" {
 | 
			
		||||
					line = fmt.Sprintf("%s (%s)",
 | 
			
		||||
						pack.FormatVersionFromTo(affected.NotFixedYet, affected.FixState),
 | 
			
		||||
						pack.Repository)
 | 
			
		||||
				} else {
 | 
			
		||||
					line = fmt.Sprintf("%s",
 | 
			
		||||
						pack.FormatVersionFromTo(affected.NotFixedYet, affected.FixState),
 | 
			
		||||
					)
 | 
			
		||||
				}
 | 
			
		||||
				data = append(data, []string{"Affected Pkg", line})
 | 
			
		||||
 | 
			
		||||
				if len(pack.AffectedProcs) != 0 {
 | 
			
		||||
					for _, p := range pack.AffectedProcs {
 | 
			
		||||
						data = append(data, []string{"",
 | 
			
		||||
							fmt.Sprintf("  - PID: %s %s", p.PID, p.Name)})
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		sort.Strings(vuln.CpeNames)
 | 
			
		||||
		for _, name := range vuln.CpeNames {
 | 
			
		||||
			packsVer = append(packsVer, name)
 | 
			
		||||
		sort.Strings(vuln.CpeURIs)
 | 
			
		||||
		for _, name := range vuln.CpeURIs {
 | 
			
		||||
			data = append(data, []string{"CPE", name})
 | 
			
		||||
		}
 | 
			
		||||
		table.AddRow("Package/CPE", strings.Join(packsVer, "\n"))
 | 
			
		||||
		table.AddRow("Confidence", vuln.Confidence)
 | 
			
		||||
 | 
			
		||||
		table.AddRow("\n")
 | 
			
		||||
		for _, alert := range vuln.GitHubSecurityAlerts {
 | 
			
		||||
			data = append(data, []string{"GitHub", alert.PackageName})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, confidence := range vuln.Confidences {
 | 
			
		||||
			data = append(data, []string{"Confidence", confidence.String()})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		links := vuln.CveContents.SourceLinks(
 | 
			
		||||
			config.Conf.Lang, r.Family, vuln.CveID)
 | 
			
		||||
		data = append(data, []string{"Source", links[0].Value})
 | 
			
		||||
 | 
			
		||||
		if 0 < len(vuln.Cvss2Scores(r.Family)) {
 | 
			
		||||
			data = append(data, []string{"CVSSv2 Calc", vuln.Cvss2CalcURL()})
 | 
			
		||||
		}
 | 
			
		||||
		if 0 < len(vuln.Cvss3Scores()) {
 | 
			
		||||
			data = append(data, []string{"CVSSv3 Calc", vuln.Cvss3CalcURL()})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		vlinks := vuln.VendorLinks(r.Family)
 | 
			
		||||
		for name, url := range vlinks {
 | 
			
		||||
			data = append(data, []string{name, url})
 | 
			
		||||
		}
 | 
			
		||||
		for _, url := range cweURLs {
 | 
			
		||||
			data = append(data, []string{"CWE", url})
 | 
			
		||||
		}
 | 
			
		||||
		for _, exploit := range vuln.Exploits {
 | 
			
		||||
			data = append(data, []string{string(exploit.ExploitType), exploit.URL})
 | 
			
		||||
		}
 | 
			
		||||
		for _, url := range top10URLs {
 | 
			
		||||
			data = append(data, []string{"OWASP Top10", url})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, alert := range vuln.AlertDict.Ja {
 | 
			
		||||
			data = append(data, []string{"JPCERT Alert", alert.URL})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, alert := range vuln.AlertDict.En {
 | 
			
		||||
			data = append(data, []string{"USCERT Alert", alert.URL})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// for _, rr := range vuln.CveContents.References(r.Family) {
 | 
			
		||||
		// for _, ref := range rr.Value {
 | 
			
		||||
		// data = append(data, []string{ref.Source, ref.Link})
 | 
			
		||||
		// }
 | 
			
		||||
		// }
 | 
			
		||||
 | 
			
		||||
		b := bytes.Buffer{}
 | 
			
		||||
		table := tablewriter.NewWriter(&b)
 | 
			
		||||
		table.SetColWidth(80)
 | 
			
		||||
		table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
 | 
			
		||||
		table.SetHeader([]string{
 | 
			
		||||
			vuln.CveID,
 | 
			
		||||
			"",
 | 
			
		||||
		})
 | 
			
		||||
		table.SetBorder(true)
 | 
			
		||||
		table.AppendBulk(data)
 | 
			
		||||
		table.Render()
 | 
			
		||||
		lines += b.String() + "\n"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return fmt.Sprintf("%s\n%s", header, table)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func cweURL(cweID string) string {
 | 
			
		||||
@@ -245,6 +322,16 @@ func formatChangelogs(r models.ScanResult) string {
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(buf, "\n")
 | 
			
		||||
}
 | 
			
		||||
func ovalSupported(r *models.ScanResult) bool {
 | 
			
		||||
	switch r.Family {
 | 
			
		||||
	case
 | 
			
		||||
		config.Amazon,
 | 
			
		||||
		config.FreeBSD,
 | 
			
		||||
		config.Raspbian:
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func needToRefreshCve(r models.ScanResult) bool {
 | 
			
		||||
	if r.Lang != config.Conf.Lang {
 | 
			
		||||
@@ -273,27 +360,35 @@ func overwriteJSONFile(dir string, r models.ScanResult) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func loadPrevious(current models.ScanResults) (previous models.ScanResults, err error) {
 | 
			
		||||
func loadPrevious(currs models.ScanResults) (prevs models.ScanResults, err error) {
 | 
			
		||||
	dirs, err := ListValidJSONDirs()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, result := range current {
 | 
			
		||||
	for _, result := range currs {
 | 
			
		||||
		filename := result.ServerName + ".json"
 | 
			
		||||
		if result.Container.Name != "" {
 | 
			
		||||
			filename = fmt.Sprintf("%s@%s.json", result.Container.Name, result.ServerName)
 | 
			
		||||
		}
 | 
			
		||||
		for _, dir := range dirs[1:] {
 | 
			
		||||
			var r *models.ScanResult
 | 
			
		||||
			path := filepath.Join(dir, result.ServerName+".json")
 | 
			
		||||
			if r, err = loadOneServerScanResult(path); err != nil {
 | 
			
		||||
			path := filepath.Join(dir, filename)
 | 
			
		||||
			r, err := loadOneServerScanResult(path)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				util.Log.Errorf("%s", err)
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			if r.Family == result.Family && r.Release == result.Release {
 | 
			
		||||
				previous = append(previous, *r)
 | 
			
		||||
				prevs = append(prevs, *r)
 | 
			
		||||
				util.Log.Infof("Previous json found: %s", path)
 | 
			
		||||
				break
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Infof("Previous json is different family.Release: %s, pre: %s.%s cur: %s.%s",
 | 
			
		||||
					path, r.Family, r.Release, result.Family, result.Release)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return previous, nil
 | 
			
		||||
	return prevs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func diff(curResults, preResults models.ScanResults) (diffed models.ScanResults, err error) {
 | 
			
		||||
@@ -301,7 +396,7 @@ func diff(curResults, preResults models.ScanResults) (diffed models.ScanResults,
 | 
			
		||||
		found := false
 | 
			
		||||
		var previous models.ScanResult
 | 
			
		||||
		for _, r := range preResults {
 | 
			
		||||
			if current.ServerName == r.ServerName {
 | 
			
		||||
			if current.ServerName == r.ServerName && current.Container.Name == r.Container.Name {
 | 
			
		||||
				found = true
 | 
			
		||||
				previous = r
 | 
			
		||||
				break
 | 
			
		||||
@@ -337,8 +432,20 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
 | 
			
		||||
		if previousCveIDsSet[v.CveID] {
 | 
			
		||||
			if isCveInfoUpdated(v.CveID, previous, current) {
 | 
			
		||||
				updated[v.CveID] = v
 | 
			
		||||
				util.Log.Debugf("updated: %s", v.CveID)
 | 
			
		||||
 | 
			
		||||
				// TODO commented out beause  a bug of diff logic when multiple oval defs found for a certain CVE-ID and same updated_at
 | 
			
		||||
				// if these OVAL defs have different affected packages, this logic detects as updated.
 | 
			
		||||
				// This logic will be uncommented after integration with ghost https://github.com/knqyf263/gost
 | 
			
		||||
				// } else if isCveFixed(v, previous) {
 | 
			
		||||
				// updated[v.CveID] = v
 | 
			
		||||
				// util.Log.Debugf("fixed: %s", v.CveID)
 | 
			
		||||
 | 
			
		||||
			} else {
 | 
			
		||||
				util.Log.Debugf("same: %s", v.CveID)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			util.Log.Debugf("new: %s", v.CveID)
 | 
			
		||||
			new[v.CveID] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -349,36 +456,54 @@ func getDiffCves(previous, current models.ScanResult) models.VulnInfos {
 | 
			
		||||
	return updated
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func isCveFixed(current models.VulnInfo, previous models.ScanResult) bool {
 | 
			
		||||
	preVinfo, _ := previous.ScannedCves[current.CveID]
 | 
			
		||||
	pre := map[string]bool{}
 | 
			
		||||
	for _, h := range preVinfo.AffectedPackages {
 | 
			
		||||
		pre[h.Name] = h.NotFixedYet
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cur := map[string]bool{}
 | 
			
		||||
	for _, h := range current.AffectedPackages {
 | 
			
		||||
		cur[h.Name] = h.NotFixedYet
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return !reflect.DeepEqual(pre, cur)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func isCveInfoUpdated(cveID string, previous, current models.ScanResult) bool {
 | 
			
		||||
	cTypes := []models.CveContentType{
 | 
			
		||||
		models.NVD,
 | 
			
		||||
		models.JVN,
 | 
			
		||||
		models.NvdXML,
 | 
			
		||||
		models.Jvn,
 | 
			
		||||
		models.NewCveContentType(current.Family),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	prevLastModified := map[models.CveContentType]time.Time{}
 | 
			
		||||
	for _, c := range previous.ScannedCves {
 | 
			
		||||
		if cveID == c.CveID {
 | 
			
		||||
			for _, cType := range cTypes {
 | 
			
		||||
				content, _ := c.CveContents[cType]
 | 
			
		||||
				prevLastModified[cType] = content.LastModified
 | 
			
		||||
			}
 | 
			
		||||
			break
 | 
			
		||||
	preVinfo, ok := previous.ScannedCves[cveID]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	for _, cType := range cTypes {
 | 
			
		||||
		if content, ok := preVinfo.CveContents[cType]; ok {
 | 
			
		||||
			prevLastModified[cType] = content.LastModified
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	curLastModified := map[models.CveContentType]time.Time{}
 | 
			
		||||
	for _, c := range current.ScannedCves {
 | 
			
		||||
		if cveID == c.CveID {
 | 
			
		||||
			for _, cType := range cTypes {
 | 
			
		||||
				content, _ := c.CveContents[cType]
 | 
			
		||||
				curLastModified[cType] = content.LastModified
 | 
			
		||||
			}
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	curVinfo, ok := current.ScannedCves[cveID]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	for _, cType := range cTypes {
 | 
			
		||||
		if equal := prevLastModified[cType].Equal(curLastModified[cType]); !equal {
 | 
			
		||||
		if content, ok := curVinfo.CveContents[cType]; ok {
 | 
			
		||||
			curLastModified[cType] = content.LastModified
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, t := range cTypes {
 | 
			
		||||
		if !curLastModified[t].Equal(prevLastModified[t]) {
 | 
			
		||||
			util.Log.Debugf("%s LastModified not equal: \n%s\n%s",
 | 
			
		||||
				cveID, curLastModified[t], prevLastModified[t])
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,23 @@
 | 
			
		||||
package report
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/future-architect/vuls/config"
 | 
			
		||||
	"github.com/future-architect/vuls/models"
 | 
			
		||||
	"github.com/future-architect/vuls/util"
 | 
			
		||||
	"github.com/k0kubun/pp"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestMain(m *testing.M) {
 | 
			
		||||
	util.Log = util.NewCustomLogger(config.ServerInfo{})
 | 
			
		||||
	code := m.Run()
 | 
			
		||||
	os.Exit(code)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
	f := "2006-01-02"
 | 
			
		||||
	old, _ := time.Parse(f, "2015-12-15")
 | 
			
		||||
@@ -33,7 +42,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0001",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
@@ -47,7 +56,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0001",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0001",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
@@ -68,7 +77,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.Jvn,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									LastModified: old,
 | 
			
		||||
								},
 | 
			
		||||
@@ -82,7 +91,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0002",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.Jvn,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									LastModified: old,
 | 
			
		||||
								},
 | 
			
		||||
@@ -104,7 +113,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0003",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									LastModified: new,
 | 
			
		||||
								},
 | 
			
		||||
@@ -119,7 +128,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0003",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									LastModified: old,
 | 
			
		||||
								},
 | 
			
		||||
@@ -141,7 +150,7 @@ func TestIsCveInfoUpdated(t *testing.T) {
 | 
			
		||||
							CveID: "CVE-2017-0004",
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NVD,
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2017-0002",
 | 
			
		||||
									LastModified: old,
 | 
			
		||||
								},
 | 
			
		||||
@@ -185,18 +194,18 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
							CveID:            "CVE-2012-6702",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{{Name: "libexpat1"}},
 | 
			
		||||
							DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
							CpeNames:         []string{},
 | 
			
		||||
							CpeURIs:          []string{},
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2014-9761": {
 | 
			
		||||
							CveID:            "CVE-2014-9761",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{{Name: "libc-bin"}},
 | 
			
		||||
							DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
							CpeNames:         []string{},
 | 
			
		||||
							CpeURIs:          []string{},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Packages: models.Packages{},
 | 
			
		||||
					Errors:   []string{},
 | 
			
		||||
					Optional: [][]interface{}{},
 | 
			
		||||
					Optional: map[string]interface{}{},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			inPrevious: models.ScanResults{
 | 
			
		||||
@@ -210,18 +219,18 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
							CveID:            "CVE-2012-6702",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{{Name: "libexpat1"}},
 | 
			
		||||
							DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
							CpeNames:         []string{},
 | 
			
		||||
							CpeURIs:          []string{},
 | 
			
		||||
						},
 | 
			
		||||
						"CVE-2014-9761": {
 | 
			
		||||
							CveID:            "CVE-2014-9761",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{{Name: "libc-bin"}},
 | 
			
		||||
							DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
							CpeNames:         []string{},
 | 
			
		||||
							CpeURIs:          []string{},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Packages: models.Packages{},
 | 
			
		||||
					Errors:   []string{},
 | 
			
		||||
					Optional: [][]interface{}{},
 | 
			
		||||
					Optional: map[string]interface{}{},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			out: models.ScanResult{
 | 
			
		||||
@@ -232,7 +241,7 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
				Packages:    models.Packages{},
 | 
			
		||||
				ScannedCves: models.VulnInfos{},
 | 
			
		||||
				Errors:      []string{},
 | 
			
		||||
				Optional:    [][]interface{}{},
 | 
			
		||||
				Optional:    map[string]interface{}{},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
@@ -247,7 +256,7 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
							CveID:            "CVE-2016-6662",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{{Name: "mysql-libs"}},
 | 
			
		||||
							DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
							CpeNames:         []string{},
 | 
			
		||||
							CpeURIs:          []string{},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Packages: models.Packages{
 | 
			
		||||
@@ -285,7 +294,7 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
						CveID:            "CVE-2016-6662",
 | 
			
		||||
						AffectedPackages: models.PackageStatuses{{Name: "mysql-libs"}},
 | 
			
		||||
						DistroAdvisories: []models.DistroAdvisory{},
 | 
			
		||||
						CpeNames:         []string{},
 | 
			
		||||
						CpeURIs:          []string{},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				Packages: models.Packages{
 | 
			
		||||
@@ -325,3 +334,104 @@ func TestDiff(t *testing.T) {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIsCveFixed(t *testing.T) {
 | 
			
		||||
	type In struct {
 | 
			
		||||
		v    models.VulnInfo
 | 
			
		||||
		prev models.ScanResult
 | 
			
		||||
	}
 | 
			
		||||
	var tests = []struct {
 | 
			
		||||
		in       In
 | 
			
		||||
		expected bool
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			in: In{
 | 
			
		||||
				v: models.VulnInfo{
 | 
			
		||||
					CveID: "CVE-2016-6662",
 | 
			
		||||
					AffectedPackages: models.PackageStatuses{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "mysql-libs",
 | 
			
		||||
							NotFixedYet: false,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					CveContents: models.NewCveContents(
 | 
			
		||||
						models.CveContent{
 | 
			
		||||
							Type:         models.NvdXML,
 | 
			
		||||
							CveID:        "CVE-2016-6662",
 | 
			
		||||
							LastModified: time.Time{},
 | 
			
		||||
						},
 | 
			
		||||
					),
 | 
			
		||||
				},
 | 
			
		||||
				prev: models.ScanResult{
 | 
			
		||||
					ScannedCves: models.VulnInfos{
 | 
			
		||||
						"CVE-2016-6662": {
 | 
			
		||||
							CveID: "CVE-2016-6662",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{
 | 
			
		||||
								{
 | 
			
		||||
									Name:        "mysql-libs",
 | 
			
		||||
									NotFixedYet: true,
 | 
			
		||||
								},
 | 
			
		||||
							},
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2016-6662",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
							),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			expected: true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			in: In{
 | 
			
		||||
				v: models.VulnInfo{
 | 
			
		||||
					CveID: "CVE-2016-6662",
 | 
			
		||||
					AffectedPackages: models.PackageStatuses{
 | 
			
		||||
						{
 | 
			
		||||
							Name:        "mysql-libs",
 | 
			
		||||
							NotFixedYet: true,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					CveContents: models.NewCveContents(
 | 
			
		||||
						models.CveContent{
 | 
			
		||||
							Type:         models.NvdXML,
 | 
			
		||||
							CveID:        "CVE-2016-6662",
 | 
			
		||||
							LastModified: time.Time{},
 | 
			
		||||
						},
 | 
			
		||||
					),
 | 
			
		||||
				},
 | 
			
		||||
				prev: models.ScanResult{
 | 
			
		||||
					ScannedCves: models.VulnInfos{
 | 
			
		||||
						"CVE-2016-6662": {
 | 
			
		||||
							CveID: "CVE-2016-6662",
 | 
			
		||||
							AffectedPackages: models.PackageStatuses{
 | 
			
		||||
								{
 | 
			
		||||
									Name:        "mysql-libs",
 | 
			
		||||
									NotFixedYet: true,
 | 
			
		||||
								},
 | 
			
		||||
							},
 | 
			
		||||
							CveContents: models.NewCveContents(
 | 
			
		||||
								models.CveContent{
 | 
			
		||||
									Type:         models.NvdXML,
 | 
			
		||||
									CveID:        "CVE-2016-6662",
 | 
			
		||||
									LastModified: time.Time{},
 | 
			
		||||
								},
 | 
			
		||||
							),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			expected: false,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, tt := range tests {
 | 
			
		||||
		actual := isCveFixed(tt.in.v, tt.in.prev)
 | 
			
		||||
		if actual != tt.expected {
 | 
			
		||||
			t.Errorf("[%d] actual: %t, expected: %t", i, actual, tt.expected)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* Vuls - Vulnerability Scanner
 | 
			
		||||
Copyright (C) 2016  Future Architect, Inc. Japan.
 | 
			
		||||
Copyright (C) 2016  Future Corporation , 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
 | 
			
		||||
@@ -64,7 +64,14 @@ func detectAlpine(c config.ServerInfo) (itsMe bool, os osTypeInterface) {
 | 
			
		||||
	return false, os
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) checkDependencies() error {
 | 
			
		||||
func (o *alpine) checkScanMode() error {
 | 
			
		||||
	if o.getServerInfo().Mode.IsOffline() {
 | 
			
		||||
		return fmt.Errorf("Remove offline scan mode, Alpine needs internet connection")
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) checkDeps() error {
 | 
			
		||||
	o.log.Infof("Dependencies... No need")
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@@ -82,6 +89,24 @@ func (o *alpine) apkUpdate() error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) preCure() error {
 | 
			
		||||
	o.log.Infof("Scanning in %s", o.getServerInfo().Mode)
 | 
			
		||||
	if err := o.detectIPAddr(); err != nil {
 | 
			
		||||
		o.log.Debugf("Failed to detect IP addresses: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
	// Ignore this error as it just failed to detect the IP addresses
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) postScan() error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) detectIPAddr() (err error) {
 | 
			
		||||
	o.ServerInfo.IPv4Addrs, o.ServerInfo.IPv6Addrs, err = o.ip()
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) scanPackages() error {
 | 
			
		||||
	if err := o.apkUpdate(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
@@ -123,6 +148,11 @@ func (o *alpine) scanInstalledPackages() (models.Packages, error) {
 | 
			
		||||
	return o.parseApkInfo(r.Stdout)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) parseInstalledPackages(stdout string) (models.Packages, models.SrcPackages, error) {
 | 
			
		||||
	installedPackages, err := o.parseApkInfo(stdout)
 | 
			
		||||
	return installedPackages, nil, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (o *alpine) parseApkInfo(stdout string) (models.Packages, error) {
 | 
			
		||||
	packs := models.Packages{}
 | 
			
		||||
	scanner := bufio.NewScanner(strings.NewReader(stdout))
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user