forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverlay.qll
More file actions
54 lines (46 loc) · 1.77 KB
/
Overlay.qll
File metadata and controls
54 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
private import OverlayXml
/** 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 |
hasLocation(node, loc)
or
json_locations(node, loc)
or
yaml_locations(node, loc)
|
result = getFileFromLocation(loc)
)
}
/** 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))
}
overlay[local?]
private string getFileFromLocation(@location loc) {
exists(@file file |
locations_default(loc, file, _, _, _, _) and
files(file, result)
)
}
/** Holds if `loc` is in the `file` and is part of the overlay base database. */
overlay[local?]
private predicate discardableLocation(string file, @location node) {
not isOverlay() and file = getFileFromLocation(node)
}
/** Holds if `loc` 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 discardLocation(@location loc) {
exists(string file | discardableLocation(file, loc) and discardFile(file))
}