зеркало из https://github.com/github/codeql.git
Merge pull request #108 from esben-semmle/js/classify-generated-data-files
Approved by xiemaisi
This commit is contained in:
Коммит
d22a65a66b
|
@ -99,6 +99,21 @@ private predicate hasManyInvocations(TopLevel tl) {
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `f` is side effect free, and full of primitive literals, which is often a sign of generated data code.
|
||||
*/
|
||||
private predicate isData(File f) {
|
||||
// heuristic: `f` has more than 1000 primitive literal expressions ...
|
||||
count(SyntacticConstants::PrimitiveLiteralConstant e | e.getFile() = f) > 1000 and
|
||||
// ... but no expressions with side effects ...
|
||||
not exists (Expr e |
|
||||
e.getFile() = f and
|
||||
e.isImpure() and
|
||||
// ... except for variable initializers
|
||||
not e instanceof VariableDeclarator
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `tl` looks like it contains generated code.
|
||||
*/
|
||||
|
@ -108,7 +123,8 @@ predicate isGenerated(TopLevel tl) {
|
|||
tl instanceof GWTGeneratedTopLevel or
|
||||
tl instanceof DartGeneratedTopLevel or
|
||||
exists (GeneratedCodeMarkerComment gcmc | tl = gcmc.getTopLevel()) or
|
||||
hasManyInvocations(tl)
|
||||
hasManyInvocations(tl) or
|
||||
isData(tl.getFile())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
| ai.1.2.3-build0123.js:0:0:0:0 | ai.1.2.3-build0123.js | library |
|
||||
| bundle-directive.js:0:0:0:0 | bundle-directive.js | generated |
|
||||
| data.js:0:0:0:0 | data.js | generated |
|
||||
| exported-data.js:0:0:0:0 | exported-data.js | generated |
|
||||
| jison-lex.js:0:0:0:0 | jison-lex.js | generated |
|
||||
| jison.js:0:0:0:0 | jison.js | generated |
|
||||
| jquery-datatables.js:0:0:0:0 | jquery-datatables.js | library |
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче