codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Ruby: generate overlay discard predicates

Open nickrolfe opened this issue 6 months ago • 5 comments

Stacked on top of https://github.com/github/codeql/pull/19684

nickrolfe avatar Jun 10 '25 16:06 nickrolfe

@aibaars if you assume the generated QL is correct, would you be able to review the generator changes?

nickrolfe avatar Jun 12 '25 15:06 nickrolfe

I think @kaspersv determined that pragma[nomagic] isn't needed on any of the predicates. It was only needed in an early compiler prototype. Is that right, Kasper?

Is there any harm in generating these predicates for other tree-sitter based extractors as well?

I don't think there is, but it looks like if overlay_support also guards the addition of the databaseMetadata relation to the dbscheme, so I presume all languages will need a dbscheme upgrade if overlay is universally enabled. That seems like a lot to add to this PR.

jbj avatar Jun 19 '25 11:06 jbj

Is there any harm in generating these predicates for other tree-sitter based extractors as well?

I don't think there is, but it looks like if overlay_support also guards the addition of the databaseMetadata relation to the dbscheme, so I presume all languages will need a dbscheme upgrade if overlay is universally enabled. That seems like a lot to add to this PR.

Right. I don't think we normally bother with upgrade scripts for QL-for-QL, but I would prefer not to deal with updating its dbscheme nonetheless, for now.

nickrolfe avatar Jun 19 '25 11:06 nickrolfe

I think @kaspersv determined that pragma[nomagic] isn't needed on any of the predicates. It was only needed in an early compiler prototype. Is that right, Kasper?

Yes, that is correct. In theory they should no longer affect the semantics of overlay analysis and a DCA experiment for Java showed no impact of removing them on overlay analysis accuracy (without nomagic annotations vs baseline).

Which reminds me, I should update the Incremental CodeQL docs to remove the nomagic pragmas in examples.

kaspersv avatar Jun 19 '25 11:06 kaspersv

I've removed the pragma[nomagic] annotations.

Looks good to me. Is there any harm in generating these predicates for other tree-sitter based extractors as well? if not , we might just as well include them by default.

As discussed in the extractor PR, I can do a quick follow-up PR that adds the databaseMetadata relation to the QL-for-QL dbscheme, and I can make this simplification at the same time.

nickrolfe avatar Jun 19 '25 15:06 nickrolfe