tweet:2017:0206_01
Vulsrepo on nginx with FreeBSD
NGINXは標準ではCGIを動作させることができない。そこで、fcgiwrapを利用して動かしてみる。
http://qiita.com/hmikisato/items/c793ced0ba2695a89de6を参考にした。
pkg install nginx fcgiwrap
pkg install p5-CGI p5-JSON
で、fcgiwrapの設定。rc.confに以下を記載
nginx_enable="YES" fcgiwrap_enable="YES" fcgiwrap_user="monitor" fcgiwrap_socket_owner="monitor" fcgiwrap_socket="unix:/var/run/fcgiwrap/fcgiwrap.socket"
nginx.confを以下のように編集
load_module /usr/local/libexec/nginx/ngx_mail_module.so; load_module /usr/local/libexec/nginx/ngx_stream_module.so; worker_processes 1; user monitor; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /home/monitor/htdocs/vulsrepo; index index.html; } location ~ \.cgi { include fastcgi_params; fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; root /home/monitor/htdocs/vulsrepo; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/www/nginx-dist; } } }
そして、nginxとfcgiwrapを起動
# service fcgiwrap start # service nginx start
次にvulsrepoを導入。
Document rootを/home/monitor/htdocs/vulsrepo
にしてあるので、以下を実行。
mkdir -p ~monitor/htdocs/vulsrepo chown -R monitor:staff ~monitor/htdocs
次に、vulsrepoをgithubから取得
monitor$ cd /home/monitor/htdocs monitor$ git clone https://github.com/usiusi360/vulsrepo.git
vulsの出力を取り込む必要があるので、
monitor$ vuls scan monitor$ vuls report -to-localfile -format-json --cvedb-path=/home/monitor/vuls/cve.sqlite3
を実行した上で、
monitor$ cd /home/monitor/htdocs/vulsrepo monitor$ ln -s /home/monitor/vuls/results .
これで、Browserからアクセスすれば、Vulsrepoの出力が見れるはず。
重要
vulsrepoのcgi script(vulsrepo/dist/cgi/getfilelist.cgi
)は、sh-bang!形式で、先頭行に#!/usr/bin/perl
と記載されている。FreeBSDの場合、perlをpkgで投入すると、#!/usr/local/bin/perl
に修正する必要があるので、注意すること
あとは、毎日の更新問題だけ。 以下のようなscriptをcronでdailyに動かせばOK
#! /bin/sh ##### Main Routine . ~/.goenv.sh DATE=`date "+%Y"` ${HOME}/go/bin/go-cve-dictionary fetchnvd -years ${DATE} ${HOME}/go/bin/go-cve-dictionary fetchjvn -years ${DATE} # Run vuls cd $HOME/vuls ${HOME}/go/bin/vuls scan ${HOME}/go/bin/vuls report -to-localfile -format-json --cvedb-path=${HOME}/vuls/cve.sqlite3
tweet/2017/0206_01.txt · 最終更新: 2018/05/14 13:51 by 127.0.0.1