Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[javascript]-LGTM.com - ERROR: Could not resolve type @regexp_anchor #2354

Closed
dialectically opened this issue Nov 16, 2019 · 6 comments
Closed
Assignees
Labels

Comments

@dialectically
Copy link

Hello Sir,
I met some compile errors while dealing with javascript. I tried other lanague like java and it performs well. And I use OS x. Here are errors

1. ERROR: Could not resolve type @regexp_anchor ql/javascript/ql/src/semmle/javascript/Regexp.qll:304:40:304:54

2. ERROR: Could not resolve type @regexp_normal_constant
l/javascript/ql/src/semmle/javascript/Regexp.qll:564:52:564:75

3.ERROR: test is always false, as StringLiteral is incompatible with the expression type RegExpParent.
ql/javascript/ql/src/semmle/javascript/Regexp.qll:150:42:150:55

4.ERROR: StringLiteral is incompatible with RegExpParent
ql/javascript/ql/src/semmle/javascript/Expr.qll:419:32:419:33

@dialectically dialectically changed the title [javascript]-LGTM.com - false positive [javascript]-LGTM.com - ERROR: Could not resolve type @regexp_anchor - false positive Nov 16, 2019
@dialectically dialectically changed the title [javascript]-LGTM.com - ERROR: Could not resolve type @regexp_anchor - false positive [javascript]-LGTM.com - ERROR: Could not resolve type @regexp_anchor Nov 16, 2019
@max-schaefer
Copy link
Collaborator

Thanks for your report! Could you clarify where you get these errors? Is it inside the editor in the VSCode extension, or is it when trying to run the query on the command line? And are you using the starter workspace (https://github.com/github/vscode-codeql-starter), or did you clone the query repository yourself? If it is the latter, are you up-to-date with latest master?

@boy-hack
Copy link

I ran into the same problem in the OS x, vscode editor. I have implemented git pull, but the problem still exists.

 - - - COMPILATION DONE - - - 
Failed to compile query programs/ql/javascript/ql/src/test.ql against database scheme study/dom-xss/测试程序/测试样本/jstest/db-javascript/semmlecode.javascript.dbscheme:
ERROR: Could not resolve type @regexp_anchor (programs/ql/javascript/ql/src/semmle/javascript/Regexp.qll:304:40:304:54)
ERROR: Could not resolve type @regexp_normal_constant (programs/ql/javascript/ql/src/semmle/javascript/Regexp.qll:564:52:564:75)
ERROR: test is always false, as StringLiteral is incompatible with the expression type RegExpParent. (programs/ql/javascript/ql/src/semmle/javascript/Regexp.qll:150:42:150:55)
ERROR: StringLiteral is incompatible with RegExpParent (programs/ql/javascript/ql/src/semmle/javascript/Expr.qll:419:32:419:33)
ERROR: The cast type StringLiteral is incompatible with the expression type RegExpParent. (programs/ql/javascript/ql/src/semmle/javascript/Regexp.qll:173:15:173:28)

@dialectically
Copy link
Author

dialectically commented Nov 17, 2019

Yes, I use editor in VS Code. And I think there is something wrong with javascript. cause I can run query with java code base.

@dialectically
Copy link
Author

dialectically commented Nov 17, 2019

Hello Sir, I reset the project's semmlecode.javascript.dbscheme with ql/src/semmlecode.javascript.dbscheme and I can run queries successfully. But when I made a test with alert.ql in example to the javascript code:

var a = location.hash;
alert(a);

I did't receive any alert.

Do I operate wrong? Thanks your time~

@max-schaefer
Copy link
Collaborator

OK, I have now managed to reproduce the problem. The issue is that the database you are trying to run your query on was created with a slightly older version of CodeQL. Normally the extension should realise this and ask you whether you want to upgrade the database before running the query, but for some reason in this case it fails to do so. This is a bug in the extension which I have reported as github/vscode-codeql#168.

In the meantime, you can fix the problem by explicitly upgrading the database: in the "CodeQL" view, right-click on the database, then choose "Upgrade database". Afterwards you should be able to run your query without errors.

I reset the project's semmlecode.javascript.dbscheme with ql/src/semmlecode.javascript.dbscheme

This is a very bad idea and I would advise strongly against doing this in future, since it may leave you with an unusable database. Use the "Upgrade database" menu mentioned above instead.

But when I made a test (...) I didn't receive any alert.

What alert were you expecting?

@max-schaefer
Copy link
Collaborator

github/vscode-codeql#168 has been merged. Could you check whether this fixes the problem by upgrading to the latest version of the extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants