Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.’
我们有一个表A,其中一个字段是search_time,类型为varchar:
表结构类似
CREATE TABLE A (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
search_time varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='测试表';
有一个插入语句,search_time的值为时间1 - 时间2,例如:
insert into A (search_time) values ('2021-08-10~2021-08-10')
What did you expect to see?
这个sql本身跟时间字段没有任何关系,只是value中包含了一个时间范围,理论上不应该被扣分
What did you see instead?
实际会触发规则LIT.002,报告为
诸如“WHERE col <2010-02-12”之类的查询是有效的SQL,但可能是一个错误,因为它将被解释为“WHERE col <1996”; 日期/时间文字应该加引号。
What version of are you using (soar -version)?
当前最新版本的LIT.002规则代码里是这样写的,这是否意味着只要sql的value字段包含了yyyy-MM-dd格式的字符串,就必须在前面加引号?
// 2010-01-01
re := regexp.MustCompile(.\d{4}\s*-\s*\d{1,2}\s*-\s*\d{1,2}\b)
sqls := re.FindAllString(q.Query, -1)
for _, sql := range sqls {
re = regexp.MustCompile(^['"\w-].*)
if re.FindString(sql) == "" {
rule = HeuristicRules["LIT.002"]
}
}
Please answer these questions before submitting your issue. Thanks!
我们有一个表A,其中一个字段是search_time,类型为varchar: 表结构类似 CREATE TABLE
A
(id
bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',search_time
varchar(255) DEFAULT NULL, PRIMARY KEY (id
) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='测试表';有一个插入语句,search_time的值为时间1 - 时间2,例如:
insert into A (search_time) values ('2021-08-10~2021-08-10')
What did you expect to see? 这个sql本身跟时间字段没有任何关系,只是value中包含了一个时间范围,理论上不应该被扣分
What did you see instead? 实际会触发规则LIT.002,报告为 诸如“WHERE col <2010-02-12”之类的查询是有效的SQL,但可能是一个错误,因为它将被解释为“WHERE col <1996”; 日期/时间文字应该加引号。
What version of are you using (
soar -version
)? 当前最新版本的LIT.002规则代码里是这样写的,这是否意味着只要sql的value字段包含了yyyy-MM-dd格式的字符串,就必须在前面加引号? // 2010-01-01 re := regexp.MustCompile(.\d{4}\s*-\s*\d{1,2}\s*-\s*\d{1,2}\b
) sqls := re.FindAllString(q.Query, -1) for _, sql := range sqls { re = regexp.MustCompile(^['"\w-].*
) if re.FindString(sql) == "" { rule = HeuristicRules["LIT.002"] } }