如果大家做软件缺陷和漏洞一类的研究,免不了要和SZZ算法打交道,遗憾的是目前还没有一个完全靠谱的SZZ算法open source project。这里我想利用一下RA-SZZ作者提供的几个实现:
https://github.com/danielcalencar/ma-szz
https://github.com/danielcalencar/raszzprime
我这里以MA-SZZ为例。打开项目主页后发现需要安装Postgre,呵呵呵。Ubuntu装postgre很方便,参考这里的文章:https://www.cnblogs.com/keewit/p/11969677.html
首先运行:
sudo apt-get install postgresql
就可以安装postgre了,按照上面这位网友的介绍:
安装完成后,默认会:
(1)创建名为"postgres"的Linux用户
(2)创建名为"postgres"、不带密码的默认数据库账号作为数据库管理员
(3)创建名为"postgres"的表
运行:
sudo -u postgres psql
进入到psql,我们需要简单做下面几件事:
1. 按照我以往的经验,即便是用自带的postgre账号,也最好给其设置一个密码。注意到这个文件里:
https://github.com/danielcalencar/ma-szz/blob/master/hibernate1.cfg.xml
他们用的密码是root,保持统一即可:
alter user postgres with password 'root';
注意上面这些语句类似于SQL,所以需要带分号。
2. 创建完用户密码,当然应该创建一个库了:
create database szz owner postgres;
grant all privileges on database szz to postgres;
第二条语句是将库的权限赋给用户postgres。
3. 应该是从这个库中恢复MA-SZZ项目中的表了,注意到
https://github.com/danielcalencar/ma-szz/tree/master/sqls
这里的压缩包解压之后即有几个SQL文件,如果顺利的话,我们运行这几个SQL文件就可以得到作者原来的表了。
从psql中推出后,参考这里的介绍:https://blog.csdn.net/lewky_liu/article/details/85085229
我运行了类似这样的命令:
psql -d szz -U postgres -f /home/yu/Projects/ma-szz-master/sqls/tables_that_are_automatically_populated.sql
结果却报错:
psql: error: could not connect to server: FATAL: Peer authentication failed for user "postgres"
呵呵呵呵,实在无语啊,参考这里网友的介绍:https://www.cnblogs.com/terrysun/archive/2012/11/30/2796479.html
运行:
sudo gedit /etc/postgresql/12/main/pg_hba.conf
注意这里的12这个数字会根据版本不同而不同。打开这个文件后将:
# Database administrative login by Unix domain socket
local all postgres peer
修改为:
# Database administrative login by Unix domain socket
local all postgres trust
原因顾名思义就可以看出来,然后再重新加载配置文件:
sudo /etc/init.d/postgresql reload
然后再运行上面的SQL语句,就可以成功创建表了:
psql -d szz -U postgres -f /home/yu/Projects/ma-szz-master/sqls/tables_that_are_automatically_populated.sql
CREATE TABLE
CREATE TABLE
我们可以注意到创建了两张表(通过:sudo -u postgres psql——\c szz——\d可以看到两张表分别为:bugintroducingcode,szz_project_lastrevisionprocessed,第二张表是什么鬼?)
可是按照这里的README:https://github.com/danielcalencar/ma-szz
1. This SZZ implementation consumes the data from the 'linkedissuessvn' table and
output the generated data into the 'bugintroducingcode' table.
感觉这两张表肯定不够啊,所以就继续运行其他sql语句即可(不过看情况运行其他SQL语句会倒入作者原来的数据,呵呵呵,这个package也太不贴心了)。后面就进入到数据库具体操作了,我今天就先总结这么多。