Sonar 数据库表关系

看完点个赞呗,难道想白嫖不成?更多内容请访问微信公众号 :三国测,扫码关注哟!

 

简介:Sonar平台是目前较为流行的静态代码扫描平台,为了便于使用以及自己二次开发,有必要对它的数据库结构进行学习和理解。

如题,目前网络上搜不到相关内容,只能自己慢慢整理,作为资料,以备查询。

 

=========================================================================================

查询某个月被扫描到的最多的规则:
SELECT i.rule_id,r.name AS rulename,COUNT(*) AS COUNT,FROM_UNIXTIME(i.created_at/1000) AS createtime,
r.Priority,i.severity,r.plugin_name FROM issues i
,rules r WHERE i.rule_id = r.id AND FROM_UNIXTIME(i.created_at/1000) <'2017-09-01' AND FROM_UNIXTIME(i.created_at/1000)> '2017-08-01'
GROUP BY i.rule_id ORDER BY COUNT DESC
=========================================================================================
查询所有项目:
SELECT NAME FROM projects WHERE scope='PRJ'
=========================================================================================
查询当月所有问题以及对应的项目名、作者、rule id、严重级别等信息:
SELECT p.name AS projectname,i.rule_id,i.message,i.author_login,FROM_UNIXTIME(i.created_at/1000) AS createtime,
i.severity FROM issues i,projects p
WHERE p.project_uuid=i.project_uuid AND p.scope='PRJ'
AND FROM_UNIXTIME(i.created_at/1000) <'2017-09-01' AND FROM_UNIXTIME(i.created_at/1000)> '2017-08-01'
ORDER BY rule_id DESC
=========================================================================================
根据profile_id查询当前正在使用的所有rule id(profile_id是当前使用的配置文件id)
SELECT rule_id FROM active_rules WHERE profile_id = '13'
=========================================================================================
查询当前默认使用的java规则的所有rule id:
SELECT rule_id FROM active_rules a, rules_profiles r WHERE a.profile_id = r.id AND r.is_default=1 AND r.LANGUAGE='java'
 
查询当前当前默认使用的java规则的id、name、priority、description:
SELECT a.rule_id ,b.name,b.priority,b.description
FROM active_rules a, rules_profiles r,rules b
WHERE a.profile_id = r.id AND r.is_default=1 AND r.LANGUAGE='java' AND a.rule_id=b.id
 
查询当前当前默认使用的java规则的id、name、type、severity、description:
SELECT a.rule_id ,b.name,
CASE b.rule_type
WHEN '1' THEN 'CODE SMELL' WHEN '2' THEN 'BUG' WHEN '3' THEN 'Vulnerability' ELSE 'Other' END AS TYPE,
CASE a.failure_level
WHEN '0' THEN 'INFO' WHEN '1' THEN 'MINOR' WHEN '2' THEN 'MAJOR' WHEN '3' THEN 'CRITICAL' ELSE 'BLOCKER' END AS severity,
b.description
FROM active_rules a, rules_profiles r,rules b
WHERE a.profile_id = r.id AND r.is_default=1 AND r.LANGUAGE='java' AND a.rule_id=b.id
 
感谢阅读,作者原创技术文章,转载请注明出处
posted @ 2017-09-15 16:49  王子石  阅读(4121)  评论(1编辑  收藏  举报