Merge pull request #20421 from asgerf/js/compile-for-overlay-eval

JS: Add compileForOverlayEval: true
This commit is contained in:
Asger F
2025-10-31 09:21:16 +01:00
committed by GitHub
4 changed files with 13 additions and 8 deletions

View File

@@ -498,12 +498,9 @@ public class AutoBuild {
// ensuring that the finalize steps detects that no code was seen.
Path srcFolder = Paths.get(EnvironmentVariables.getWipDatabase(), "src");
try {
// Non-recursive delete because "src/" should be empty.
FileUtil8.delete(srcFolder);
FileUtil8.recursiveDelete(srcFolder);
} catch (NoSuchFileException e) {
Exceptions.ignore(e, "the directory did not exist");
} catch (DirectoryNotEmptyException e) {
Exceptions.ignore(e, "just leave the directory if it is not empty");
}
return 0;
}

View File

@@ -0,0 +1,2 @@
// Ensure at least one file without errors is included, as extraction fails otherwise.
console.log("Hello")

View File

@@ -23,3 +23,4 @@ dataExtensions:
- semmle/javascript/security/domains/**/*.model.yml
- ext/*.model.yml
warnOnImplicitThis: true
compileForOverlayEval: true

View File

@@ -4,6 +4,14 @@
import javascript
pragma[nomagic]
private predicate adjacentTokens(Token token1, Token token2) {
exists(TopLevel top, int index |
tokeninfo(token1, _, top, index, _) and
tokeninfo(token2, _, top, index + 1, _)
)
}
/**
* A token occurring in a piece of JavaScript source code.
*
@@ -27,10 +35,7 @@ class Token extends Locatable, @token {
string getValue() { tokeninfo(this, _, _, _, result) }
/** Gets the token following this token inside the same toplevel structure, if any. */
Token getNextToken() {
this.getTopLevel() = result.getTopLevel() and
this.getIndex() + 1 = result.getIndex()
}
Token getNextToken() { adjacentTokens(this, result) }
/** Gets the token preceding this token inside the same toplevel structure, if any. */
Token getPreviousToken() { result.getNextToken() = this }