1 Star 0 Fork 0

aparece/codeql

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ConflictingAttributes.ql 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
Max Schaefer 提交于 2020-05-19 18:52 +08:00 . Lower precision for a number of queries.
/**
* @name Conflicting HTML element attributes
* @description If an HTML element has two attributes with the same name
* but different values, its behavior may be browser-dependent.
* @kind problem
* @problem.severity warning
* @id js/conflicting-html-attribute
* @tags maintainability
* correctness
* external/cwe/cwe-758
* @precision low
*/
import javascript
/**
* Holds if `earlier` and `later` are attribute definitions with the same name
* and different values, where `earlier` appears textually before `later`.
*/
predicate conflict(DOM::AttributeDefinition earlier, DOM::AttributeDefinition later) {
exists(DOM::ElementDefinition elt, int i, int j |
earlier = elt.getAttribute(i) and later = elt.getAttribute(j)
|
i < j and
earlier.getName() = later.getName() and
not earlier.getStringValue() = later.getStringValue()
)
}
from DOM::AttributeDefinition earlier, DOM::AttributeDefinition later
where conflict(earlier, later) and not conflict(_, earlier)
select earlier,
"This attribute has the same name as $@ of the same element, " + "but a different value.", later,
"another attribute"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aparece/codeql.git
git@gitee.com:aparece/codeql.git
aparece
codeql
codeql
main

搜索帮助