Semmle公司获得2100美元的B轮融资,领投方为Accel Partners,这是后者第二次投资这家公司。其他投资者包括Work-Bench、Capital One、Credit Suisse、谷歌、微软、NASA和Nasdaq Trust。本轮融资后,Semmle的融资总额将达到3100万美元。那么被业界追捧的Semmle有什么产品呢?
Semmle公司声称以一种独特的方法寻找代码中的漏洞。技术核心是把代码当成数据,将分析问题变成对数据库的请求。Semmle QL是一个声明式的面向对象的查询语言。它是现代数据记录的变体,对于那些想有无限的能力去询问他们代码的问题的人是理想的,并通过询问QL将开发团队信息和他们想要的数据库方式联系起来。
Semmle QL的功能主要包括:
- 寻找安全漏洞的所有实例。
- 检查API是否使用正确。
- 搜索指定库的使用——它在哪里被谁使用。
- 报告标准,例如代码行或测试方法的数量等。
- 完成任何其他搜索或你能想象到的分析。
其公司提供了一个免费的检测平台,lgtm.com,提供广大的安全团队和开发人员使用。平台地址是https://lgtm.com/。下面通过试用这个平台,初步认识一下这个工具。
打开网站注册后,要使用平台,需要与github进行关联,可以对github中的项目进行检测。如果我们想使用这个平台,首先是要把自己的代码上传到github,且不能设置为私有。直接分析master上的项目,子分支项目好像不能关联。
在“My Projects”中与github进行关联后,创建一个新项目,输入github上项目url后,即可进行检测,根据项目大小检测时间不等,时间感觉还是比较长。
等检测完成后,发现的缺陷统计如下图:
打开某个errors后,看到如下界面:
其中红色条表示对其上面语句的检测出的缺陷的描述。
上述检测是平台后台对程序代码进行了检测分析。
在上述检测完成后,也可以在“Query console”中可以,选择语言和项目后,可以通过交互式查询进行错误检测,按照介绍这种检测可以挖掘新的缺陷。
QL查询语言支持COBOL、C/C++、C#、Java、Javascript和python。项目只支持Github或者Bitbucket上的项目。可能是master,且公开的项目才能测试。
当然下面也有样例参考,里面有很多QL查询例子,下面是其中一个例子:
Read more 更多的详细描述:
https://lgtm.com/rules/2159000700/
Open in query console 对没有返回值的错误查询语句举例:
/**
* @name Missing return statement
* @description All functions that are not void should return a value on every exit path.
* @kind problem
* @problem.severity error
* @precision high
* @id cpp/missing-return
* @tags reliability
* readability
* language-features
* external/jsf
*/
import cpp
/* This is slightly subtle: The extractor adds a dummy 'return;' statement for control paths
that fall off the end of a function. So we can simply look for non-void functions containing
a non-value carrying return. If the predecessor is a return statement it means that
the return did not return a value. (If that return was not added by the extractor but by the
programmer, we can flag it anyway, since this is arguably a bug.) */
predicate functionsMissingReturnStmt(Function f, ControlFlowNode blame) {
f.fromSource() and
exists(Type returnType |
returnType = f.getType().getUnderlyingType().getUnspecifiedType() and
not returnType instanceof VoidType and
not returnType instanceof TemplateParameter
) and
exists(ReturnStmt s |
f.getAPredecessor() = s and
blame = s.getAPredecessor()
)
}
/* If a function has a value-carrying return statement, but the extractor hit a snag
whilst parsing the value, then the control flow graph will not include the value.
As such, to avoid embarrassing false positives, we exclude any function which
wasn't perfectly extracted. */
predicate functionImperfectlyExtracted(Function f) {
exists(CompilerError e | f.getBlock().getLocation().subsumes(e.getLocation()))
or
exists(ErrorExpr ee | ee.getEnclosingFunction() = f)
or
count(f.getType()) > 1
}
from Stmt stmt, string msg, Function f, ControlFlowNode blame
where
functionsMissingReturnStmt(f, blame) and
reachable(blame) and
not functionImperfectlyExtracted(f) and
(blame = stmt or blame.(Expr).getEnclosingStmt() = stmt) and
msg = "Function " + f.getName() + " should return a value of type " + f.getType().getName() + " but does not return a value here"
select stmt, msg
Semmle 也支持程序引用组件依赖关系,见下图。该功能列出了当前项目所引用的其它组件。通过引用组件分析,可以查看引用组件的版本、代码行和以及其中包含的缺陷。
结束