mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
JS: Add discard predicates
This commit is contained in:
@@ -146,3 +146,4 @@ import semmle.javascript.linters.JSLint
|
||||
import semmle.javascript.linters.Linting
|
||||
import semmle.javascript.security.dataflow.RemoteFlowSources
|
||||
import semmle.javascript.frameworks.UnderscoreDotString
|
||||
private import semmle.javascript.internal.Overlay
|
||||
|
||||
30
javascript/ql/lib/semmle/javascript/internal/Overlay.qll
Normal file
30
javascript/ql/lib/semmle/javascript/internal/Overlay.qll
Normal file
@@ -0,0 +1,30 @@
|
||||
private import javascript
|
||||
|
||||
/** Holds if the database is an overlay. */
|
||||
overlay[local]
|
||||
private predicate isOverlay() { databaseMetadata("isOverlay", "true") }
|
||||
|
||||
overlay[local]
|
||||
private string getFileFromEntity(@locatable node) {
|
||||
exists(@location loc, @file file |
|
||||
hasLocation(node, loc) and
|
||||
locations_default(loc, file, _, _, _, _) and
|
||||
files(file, result)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `file` was changed or deleted in the overlay. */
|
||||
overlay[local]
|
||||
private predicate discardFile(string file) { isOverlay() and overlayChangedFiles(file) }
|
||||
|
||||
/** Holds if `node` is in the `file` and is part of the overlay base database. */
|
||||
overlay[local]
|
||||
private predicate discardableEntity(string file, @locatable node) {
|
||||
not isOverlay() and file = getFileFromEntity(node)
|
||||
}
|
||||
|
||||
/** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
|
||||
overlay[discard_entity]
|
||||
private predicate discardEntity(@locatable node) {
|
||||
exists(string file | discardableEntity(file, node) and discardFile(file))
|
||||
}
|
||||
Reference in New Issue
Block a user