mirror of
https://github.com/github/codeql.git
synced 2026-02-13 05:31:22 +01:00
For now, these have just been made into `private` imports. After doing
this, I went through all of the (now not compiling) files and added in
private imports to the modules that they actually depended on.
I also added an explicit import of `LegacyPointsTo` (even though it may
be unnecessary) in cases where the points-to dependency was somewhat
surprising (and one we want to get rid of). This was primarily inside
the various SSA layers.
For modules inside `semmle.python.{types, objects, pointsto}` I did not
bother, as these are fairly clearly related to points-to.
34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
/**
|
|
* Compute the efficiency of the points-to relation. That is the ratio of
|
|
* "interesting" facts to total facts.
|
|
*/
|
|
|
|
import python
|
|
private import LegacyPointsTo
|
|
|
|
predicate trivial(ControlFlowNode f) {
|
|
f.getNode() instanceof Parameter
|
|
or
|
|
f instanceof NameConstantNode
|
|
or
|
|
f.getNode() instanceof ImmutableLiteral
|
|
}
|
|
|
|
from int interesting_facts, int interesting_facts_in_source, int total_size, float efficiency
|
|
where
|
|
interesting_facts =
|
|
strictcount(ControlFlowNodeWithPointsTo f, Object value, ClassObject cls |
|
|
f.refersTo(value, cls, _) and not trivial(f)
|
|
) and
|
|
interesting_facts_in_source =
|
|
strictcount(ControlFlowNodeWithPointsTo f, Object value, ClassObject cls |
|
|
f.refersTo(value, cls, _) and
|
|
not trivial(f) and
|
|
exists(f.getScope().getEnclosingModule().getFile().getRelativePath())
|
|
) and
|
|
total_size =
|
|
strictcount(ControlFlowNode f, PointsToContext ctx, Object value, ClassObject cls,
|
|
ControlFlowNode orig | PointsTo::points_to(f, ctx, value, cls, orig)) and
|
|
efficiency = 100.0 * interesting_facts_in_source / total_size
|
|
select interesting_facts, interesting_facts_in_source, total_size, efficiency
|