Skip to content

Commit a1a9626

Browse files
authored
Merge pull request #20421 from asgerf/js/compile-for-overlay-eval
JS: Add compileForOverlayEval: true
2 parents a25ae39 + c583b48 commit a1a9626

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,9 @@ public int run() throws IOException {
498498
// ensuring that the finalize steps detects that no code was seen.
499499
Path srcFolder = Paths.get(EnvironmentVariables.getWipDatabase(), "src");
500500
try {
501-
// Non-recursive delete because "src/" should be empty.
502-
FileUtil8.delete(srcFolder);
501+
FileUtil8.recursiveDelete(srcFolder);
503502
} catch (NoSuchFileException e) {
504503
Exceptions.ignore(e, "the directory did not exist");
505-
} catch (DirectoryNotEmptyException e) {
506-
Exceptions.ignore(e, "just leave the directory if it is not empty");
507504
}
508505
return 0;
509506
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Ensure at least one file without errors is included, as extraction fails otherwise.
2+
console.log("Hello")

javascript/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ dataExtensions:
2323
- semmle/javascript/security/domains/**/*.model.yml
2424
- ext/*.model.yml
2525
warnOnImplicitThis: true
26+
compileForOverlayEval: true

javascript/ql/lib/semmle/javascript/Tokens.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
import javascript
66

7+
pragma[nomagic]
8+
private predicate adjacentTokens(Token token1, Token token2) {
9+
exists(TopLevel top, int index |
10+
tokeninfo(token1, _, top, index, _) and
11+
tokeninfo(token2, _, top, index + 1, _)
12+
)
13+
}
14+
715
/**
816
* A token occurring in a piece of JavaScript source code.
917
*
@@ -27,10 +35,7 @@ class Token extends Locatable, @token {
2735
string getValue() { tokeninfo(this, _, _, _, result) }
2836

2937
/** Gets the token following this token inside the same toplevel structure, if any. */
30-
Token getNextToken() {
31-
this.getTopLevel() = result.getTopLevel() and
32-
this.getIndex() + 1 = result.getIndex()
33-
}
38+
Token getNextToken() { adjacentTokens(this, result) }
3439

3540
/** Gets the token preceding this token inside the same toplevel structure, if any. */
3641
Token getPreviousToken() { result.getNextToken() = this }

0 commit comments

Comments
 (0)