diff --git a/javascript/extractor/src/com/semmle/js/extractor/RegExpExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/RegExpExtractor.java index 59fa6095953..f60970c6011 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/RegExpExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/RegExpExtractor.java @@ -363,7 +363,7 @@ public class RegExpExtractor { for (Error err : res.getErrors()) { Label lbl = this.trapwriter.freshLabel(); String msg = errmsgs[err.getCode()]; - this.trapwriter.addTuple("regexpParseErrors", lbl, rootLbl, msg); + this.trapwriter.addTuple("regexp_parse_errors", lbl, rootLbl, msg); this.emitLocation(err, lbl); } } diff --git a/javascript/extractor/tests/exprs/output/trap/regexp.js.trap b/javascript/extractor/tests/exprs/output/trap/regexp.js.trap index 3bf5849d42e..1c1b719e6b7 100644 --- a/javascript/extractor/tests/exprs/output/trap/regexp.js.trap +++ b/javascript/extractor/tests/exprs/output/trap/regexp.js.trap @@ -1319,7 +1319,7 @@ locations_default(#20436,#10000,26,2,26,4) hasLocation(#20435,#20436) backref(#20435,10) #20437=* -regexpParseErrors(#20437,#20435,"invalid back reference") +regexp_parse_errors(#20437,#20435,"invalid back reference") hasLocation(#20437,#20436) #20438=* stmts(#20438,2,#20001,26,"/\t\n\r\f\v/;") @@ -1680,12 +1680,12 @@ locations_default(#20545,#10000,37,2,37,2) hasLocation(#20544,#20545) regexpConstValue(#20544,"a") #20546=* -regexpParseErrors(#20546,#20542,"expected digit") +regexp_parse_errors(#20546,#20542,"expected digit") #20547=@"loc,{#10000},37,4,37,4" locations_default(#20547,#10000,37,4,37,4) hasLocation(#20546,#20547) #20548=* -regexpParseErrors(#20548,#20542,"expected '}'") +regexp_parse_errors(#20548,#20542,"expected '}'") #20549=@"loc,{#10000},37,3,37,3" locations_default(#20549,#10000,37,3,37,3) hasLocation(#20548,#20549) @@ -1731,15 +1731,15 @@ locations_default(#20561,#10000,38,5,38,5) hasLocation(#20560,#20561) regexpConstValue(#20560,"}") #20562=* -regexpParseErrors(#20562,#20552,"expected digit") +regexp_parse_errors(#20562,#20552,"expected digit") hasLocation(#20562,#20559) #20563=* -regexpParseErrors(#20563,#20552,"expected '}'") +regexp_parse_errors(#20563,#20552,"expected '}'") #20564=@"loc,{#10000},38,3,38,3" locations_default(#20564,#10000,38,3,38,3) hasLocation(#20563,#20564) #20565=* -regexpParseErrors(#20565,#20552,"unexpected character") +regexp_parse_errors(#20565,#20552,"unexpected character") hasLocation(#20565,#20561) #20566=* stmts(#20566,2,#20001,38,"/a{2/;") @@ -1766,7 +1766,7 @@ locations_default(#20571,#10000,39,2,39,2) hasLocation(#20570,#20571) regexpConstValue(#20570,"a") #20572=* -regexpParseErrors(#20572,#20568,"expected '}'") +regexp_parse_errors(#20572,#20568,"expected '}'") #20573=@"loc,{#10000},39,4,39,4" locations_default(#20573,#10000,39,4,39,4) hasLocation(#20572,#20573) @@ -1788,7 +1788,7 @@ hasLocation(#20576,#20577) regexpConstValue(#20576," ") #20578=* -regexpParseErrors(#20578,#20576,"unexpected end of regular expression") +regexp_parse_errors(#20578,#20576,"unexpected end of regular expression") #20579=@"loc,{#10000},40,5,40,5" locations_default(#20579,#10000,40,5,40,5) hasLocation(#20578,#20579) @@ -1809,7 +1809,7 @@ locations_default(#20583,#10000,41,2,41,4) hasLocation(#20582,#20583) regexpConstValue(#20582,"") #20584=* -regexpParseErrors(#20584,#20582,"expected control letter") +regexp_parse_errors(#20584,#20582,"expected control letter") #20585=@"loc,{#10000},41,4,41,4" locations_default(#20585,#10000,41,4,41,4) hasLocation(#20584,#20585) diff --git a/javascript/extractor/tests/regexp/output/trap/es2018.js.trap b/javascript/extractor/tests/regexp/output/trap/es2018.js.trap index f8f4ac80338..ef94f865179 100644 --- a/javascript/extractor/tests/regexp/output/trap/es2018.js.trap +++ b/javascript/extractor/tests/regexp/output/trap/es2018.js.trap @@ -267,12 +267,12 @@ locations_default(#20084,#10000,6,2,6,4) hasLocation(#20083,#20084) namedBackref(#20083,"") #20085=* -regexpParseErrors(#20085,#20083,"expected identifier") +regexp_parse_errors(#20085,#20083,"expected identifier") #20086=@"loc,{#10000},6,5,6,5" locations_default(#20086,#10000,6,5,6,5) hasLocation(#20085,#20086) #20087=* -regexpParseErrors(#20087,#20083,"expected '>'") +regexp_parse_errors(#20087,#20083,"expected '>'") #20088=@"loc,{#10000},6,4,6,4" locations_default(#20088,#10000,6,4,6,4) hasLocation(#20087,#20088) diff --git a/javascript/extractor/tests/regexp/output/trap/odasa-1934.js.trap b/javascript/extractor/tests/regexp/output/trap/odasa-1934.js.trap index f2a5e85add0..aa79e044524 100644 --- a/javascript/extractor/tests/regexp/output/trap/odasa-1934.js.trap +++ b/javascript/extractor/tests/regexp/output/trap/odasa-1934.js.trap @@ -311,12 +311,12 @@ locations_default(#20101,#10000,5,10,5,11) hasLocation(#20100,#20101) regexpConstValue(#20100,"") #20102=* -regexpParseErrors(#20102,#20096,"expected hexadecimal digit") +regexp_parse_errors(#20102,#20096,"expected hexadecimal digit") #20103=@"loc,{#10000},5,12,5,12" locations_default(#20103,#10000,5,12,5,12) hasLocation(#20102,#20103) #20104=* -regexpParseErrors(#20104,#20096,"expected hexadecimal digit") +regexp_parse_errors(#20104,#20096,"expected hexadecimal digit") hasLocation(#20104,#20103) #20105=* exprs(#20105,0,#20093,1,"exec") diff --git a/javascript/extractor/tests/regexp/output/trap/tst.js.trap b/javascript/extractor/tests/regexp/output/trap/tst.js.trap index 4ed0b07f348..5bd6b0c8ca9 100644 Binary files a/javascript/extractor/tests/regexp/output/trap/tst.js.trap and b/javascript/extractor/tests/regexp/output/trap/tst.js.trap differ diff --git a/javascript/ql/src/semmle/javascript/Aliases.qll b/javascript/ql/src/semmle/javascript/Aliases.qll index a4169824362..4d6f26a59f9 100644 --- a/javascript/ql/src/semmle/javascript/Aliases.qll +++ b/javascript/ql/src/semmle/javascript/Aliases.qll @@ -220,3 +220,8 @@ deprecated predicate hasAssertsKeyword(PredicateTypeExpr node) { has_asserts_key * Use the `JSParseError` class instead. */ deprecated predicate jsParseErrors(JSParseError id, TopLevel toplevel, string message, string line) { js_parse_errors(id, toplevel, message, line) } +/** + * Alias for the predicate `regexp_parse_errors` defined in the .dbscheme. + * Use the `RegExpParseError` class instead. + */ +deprecated predicate regexpParseErrors(RegExpParseError id, RegExpTerm regexp, string message) { regexp_parse_errors(id, regexp, message) } diff --git a/javascript/ql/src/semmle/javascript/Regexp.qll b/javascript/ql/src/semmle/javascript/Regexp.qll index e4fdef07783..44355a04678 100644 --- a/javascript/ql/src/semmle/javascript/Regexp.qll +++ b/javascript/ql/src/semmle/javascript/Regexp.qll @@ -819,12 +819,12 @@ class RegExpCharacterRange extends RegExpTerm, @regexp_char_range { /** A parse error encountered while processing a regular expression literal. */ class RegExpParseError extends Error, @regexp_parse_error { /** Gets the regular expression term that triggered the parse error. */ - RegExpTerm getTerm() { regexpParseErrors(this, result, _) } + RegExpTerm getTerm() { regexp_parse_errors(this, result, _) } /** Gets the regular expression literal in which the parse error occurred. */ RegExpLiteral getLiteral() { result = getTerm().getLiteral() } - override string getMessage() { regexpParseErrors(this, _, result) } + override string getMessage() { regexp_parse_errors(this, _, result) } override string toString() { result = getMessage() } } diff --git a/javascript/ql/src/semmlecode.javascript.dbscheme b/javascript/ql/src/semmlecode.javascript.dbscheme index c983a5b93e0..5692d29e393 100644 --- a/javascript/ql/src/semmlecode.javascript.dbscheme +++ b/javascript/ql/src/semmlecode.javascript.dbscheme @@ -864,7 +864,7 @@ case @regexpterm.kind of | 26 = @regexp_negative_lookbehind | 27 = @regexp_unicode_property_escape; -regexpParseErrors (unique int id: @regexp_parse_error, +regexp_parse_errors (unique int id: @regexp_parse_error, int regexp: @regexpterm ref, varchar(900) message: string ref); diff --git a/javascript/ql/src/semmlecode.javascript.dbscheme.stats b/javascript/ql/src/semmlecode.javascript.dbscheme.stats index 4a6ef88cd3d..22a7095e5c6 100644 --- a/javascript/ql/src/semmlecode.javascript.dbscheme.stats +++ b/javascript/ql/src/semmlecode.javascript.dbscheme.stats @@ -19869,7 +19869,7 @@ -regexpParseErrors +regexp_parse_errors id 122 diff --git a/javascript/upgrades/c73fbfca57f3d593b9ff50c6aa3a886d6888efec/upgrade.properties b/javascript/upgrades/c73fbfca57f3d593b9ff50c6aa3a886d6888efec/upgrade.properties index 39fab3ddf15..4cabb80a560 100644 --- a/javascript/upgrades/c73fbfca57f3d593b9ff50c6aa3a886d6888efec/upgrade.properties +++ b/javascript/upgrades/c73fbfca57f3d593b9ff50c6aa3a886d6888efec/upgrade.properties @@ -62,3 +62,5 @@ has_asserts_keyword.rel: reorder hasAssertsKeyword.rel(int node) node hasAssertsKeyword.rel: delete js_parse_errors.rel: reorder jsParseErrors.rel(int id, int toplevel, string message, string line) id toplevel message line jsParseErrors.rel: delete +regexp_parse_errors.rel: reorder regexpParseErrors.rel(int id, int regexp, string message) id regexp message +regexpParseErrors.rel: delete