vulsrepo: minor changes (fix: Vuls is not running)

This commit is contained in:
Yury Martynov 2019-07-05 12:01:42 +03:00
parent 2ac3c03e11
commit 8512099431
No known key found for this signature in database
GPG key ID: EBE62DD0CCEAE19E
4 changed files with 60 additions and 32 deletions

View file

@ -1,12 +1,12 @@
[Server]
rootPath = "/var/lib/vuls/vulsrepo"
resultsPath = "/var/lib/vuls/results"
serverPort = "5111"
# serverIP = "127.0.0.1"
# serverSSL = "yes"
# serverCert = "cert.pem"
# serverKey = "key.pem"
#[Auth]
# authFilePath = "/var/lib/vuls/vulsrepo/.htdigest"
# realm = "vulsrepo_local"
[Server]
rootPath = "/var/lib/vuls/vulsrepo"
resultsPath = "/var/lib/vuls/results"
serverPort = "5111"
# serverIP = "127.0.0.1"
# serverSSL = "yes"
# serverCert = "cert.pem"
# serverKey = "key.pem"
#[Auth]
# authFilePath = "/var/lib/vuls/vulsrepo/.htdigest"
# realm = "vulsrepo_local"

View file

@ -2,7 +2,8 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
VULSREPO_LOGFILE="${VULSREPO_LOGFILE:-/var/log/vulsrepo-server.log}"
VULSREPO_CONFFILE="${VULSREPO_CONFFILE:-/etc/vuls/vulsrepo-config.toml}"
VULSREPO_LOGFILE="${VULSREPO_LOGFILE:-/var/log/vuls/vulsrepo-server.log}"
USER="vuls"
GROUP="vuls"
@ -16,13 +17,18 @@ start_stop_daemon_args="--quiet -1 ${VULSREPO_LOGFILE} -2 ${VULSREPO_LOGFILE}"
retry="TERM/25/KILL/5"
extra_commands="checkconfig"
depend() {
need net
}
checkconfig() {
if ! [ -f "/etc/vuls/vulsrepo-config.toml" ]; then
eerror "You need an \"/etc/vuls/vulsrepo-config.toml\" file to run ${RC_SVCNAME}"
if [ -f "${VULSREPO_CONFFILE}" ]; then
local res_path="$(cat "${VULSREPO_CONFFILE}" \
| tr -d "[:blank:]\"" \
| awk -F'=' '$1~/^resultsPath$/{print$2}')"
if ! [ -d "${res_path}" ]; then
eerror "You need create a reports in \"${res_path}\" before starting ${RC_SVCNAME}"
return 1
fi
else
eerror "You need an \"${VULSREPO_CONFFILE}\" file to run ${RC_SVCNAME}"
return 1
fi

View file

@ -0,0 +1,29 @@
diff -ur a/src/github.com/usiusi360/vulsrepo/dist/js/vulsrepo.js b/src/github.com/usiusi360/vulsrepo/dist/js/vulsrepo.js
--- a/src/github.com/usiusi360/vulsrepo/dist/js/vulsrepo.js 2019-07-05 10:23:17.062879033 +0300
+++ b/src/github.com/usiusi360/vulsrepo/dist/js/vulsrepo.js 2019-07-05 10:24:44.792604267 +0300
@@ -139,12 +139,6 @@
return;
}
- if (resultMap.data.reportedAt === "0001-01-01T00:00:00Z") {
- showAlert("Vuls report is not running ", value.url);
- $.unblockUI(blockUIoption);
- return;
- }
-
resultArray.push(resultMap);
if (kickCount == endCount) {
defer.resolve(resultArray);
diff -ur a/src/github.com/usiusi360/vulsrepo/server/main.go b/src/github.com/usiusi360/vulsrepo/server/main.go
--- a/src/github.com/usiusi360/vulsrepo/server/main.go 2019-07-05 10:24:29.037730563 +0300
+++ b/src/github.com/usiusi360/vulsrepo/server/main.go 2019-07-05 10:30:27.998977457 +0300
@@ -134,8 +134,7 @@
}
func loadConfig() {
- fpath, _ := (os.Executable())
- _, err := toml.DecodeFile(filepath.Dir(fpath)+"/vulsrepo-config.toml", &config)
+ _, err := toml.DecodeFile("/etc/vuls/vulsrepo-config.toml", &config)
if err != nil {
_, err := toml.DecodeFile("./vulsrepo-config.toml", &config)
if err != nil {

View file

@ -1,16 +1,11 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# FIXME:
# https://github.com/usiusi360/vulsrepo/issues/75
# https://github.com/usiusi360/vulsrepo/issues/69
# https://github.com/usiusi360/vulsrepo/issues/64
EAPI=7
EGO_PN="github.com/usiusi360/vulsrepo"
EGO_VENDOR=(
"github.com/BurntSushi/toml v0.3.0"
"github.com/BurntSushi/toml v0.3.0"
"github.com/abbot/go-http-auth v0.4.0"
)
@ -39,17 +34,14 @@ pkg_setup() {
}
src_prepare() {
sed -e "/fpath, _ := (os.Executable())/d" \
-e "s:filepath.Dir(fpath)+\"/vulsrepo-config.toml\":\"/etc/vuls/vulsrepo-config.toml\":" \
-i src/"${EGO_PN}"/server/main.go || die
eapply "${FILESDIR}"/vulsrepo_minor_fixes.patch
default
}
src_compile() {
cd src/"${EGO_PN}"/server || die
GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
GOPATH="${S}:$(get_golibdir_gopath)" \
go build -v -work -x -ldflags="-s -w" -o vulsrepo-server || die
}
@ -62,8 +54,9 @@ src_install() {
insinto "/var/lib/vuls/${PN}"
doins -r plugins dist index.html
fowners -R vuls:vuls "/var/lib/vuls" "/etc/vuls"
fperms 0750 "/var/lib/vuls" "/etc/vuls"
keepdir "/var/log/vuls"
fowners -R vuls:vuls "/var/lib/vuls" "/var/log/vuls" "/etc/vuls"
fperms 0750 "/var/lib/vuls" "/var/log/vuls" "/etc/vuls"
dobin server/vulsrepo-server