Visitar URL original
Ruby: Do not expose AST layer through `ruby.qll` by hvitved · Pull Request #10376 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20220922043933/https://github.com/github/codeql/pull/10376
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

Ruby: Do not expose AST layer through ruby.qll #10376

Merged
merged 6 commits into from Sep 21, 2022

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 12, 2022 •

Since writing data-flow queries is much more common than writing syntactic queries, it makes little sense to have the AST layer exposed by default in ruby.qll.

This PR therefore removes that AST libraries from ruby.qll (instead, one should import codeql.ruby.AST). In fact, ruby.qll is now completely empty, and is only kept for backwards compatibility with quick queries.

@github-actions github-actions bot added the Ruby label Sep 12, 2022
@aibaars
Copy link
Contributor

aibaars commented Sep 12, 2022 •

Shall we remove all import ruby statements, and replace them with (private) import codeql.Locations wherever we actually need that import?

@hvitved hvitved force-pushed the ruby/no-ast-by-default branch 2 times, most recently from d7785ab to ea10698 Compare Sep 12, 2022
@hvitved
Copy link
Contributor Author

hvitved commented Sep 13, 2022

Shall we remove all import ruby statements, and replace them with (private) import codeql.Locations wherever we actually need that import?

Or perhaps we should just let codeql.ruby.AST reexport codeql.Locations?

@aibaars
Copy link
Contributor

aibaars commented Sep 13, 2022

Shall we remove all import ruby statements, and replace them with (private) import codeql.Locations wherever we actually need that import?

Or perhaps we should just let codeql.ruby.AST reexport codeql.Locations?

Fine with me too, the most important thing to me is removing all import ruby statements. I'm not really convinced that the AST module should expose Locations though. It's a bit arbitrary, why would AST do that, but CFG or dataflow not.

@hvitved
Copy link
Contributor Author

hvitved commented Sep 13, 2022

It's a bit arbitrary, why would AST do that, but CFG or dataflow not.

I think I would let those libraries expose locations as well, since it is such a core concept.

@aibaars
Copy link
Contributor

aibaars commented Sep 13, 2022

I think I would let those libraries expose locations as well, since it is such a core concept.

Having all of them export locations is good; definitely better than having one (or some of them) do it.

@hvitved hvitved force-pushed the ruby/no-ast-by-default branch 4 times, most recently from bc3691d to 42f1256 Compare Sep 13, 2022
@hvitved hvitved marked this pull request as ready for review Sep 14, 2022
@hvitved hvitved requested a review from a team as a code owner Sep 14, 2022
@asgerf
Copy link
Contributor

asgerf commented Sep 14, 2022

Wouldn't it make sense to make the three layers available as named modules?

So after import ruby you can use the prefixes AST::, CFG:: and DataFlow::.

@hvitved
Copy link
Contributor Author

hvitved commented Sep 14, 2022

Wouldn't it make sense to make the three layers available as named modules?

So after import ruby you can use the prefixes AST::, CFG:: and DataFlow::.

Fine by me.

@@ -2,5 +2,6 @@
* Provides classes for working with Ruby programs.
*/

private import Customizations
import codeql.ruby.AST
import codeql.ruby.AST as Ast

Check warning

Code scanning / CodeQL

Names only differing by case Warning

Ast is only different by casing from AST that is used elsewhere for modules.
private import Customizations
import codeql.ruby.AST
import codeql.ruby.AST as Ast
import codeql.ruby.CFG as Cfg

Check warning

Code scanning / CodeQL

Names only differing by case Warning

Cfg is only different by casing from CFG that is used elsewhere for modules.
Co-authored-by: Nick Rolfe <nickrolfe@github.com>
Copy link
Contributor

@nickrolfe nickrolfe left a comment

LGTM, and we agreed in the team meeting to go with this approach, so feel free to merge.

As a follow-up, we could perhaps fix some of those QL-for-QL alerts by changing the casing on some of the existing imports that are as AST or as CFG.

@hvitved hvitved merged commit a9f2e52 into github:main Sep 21, 2022
24 checks passed
@hvitved hvitved deleted the ruby/no-ast-by-default branch Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants