Skip to content

Commit 813ffa4

Browse files
committed
Java: Consider ai-generated flow summaries to as generated summaries in dataflow.
1 parent 54c0404 commit 813ffa4

File tree

11 files changed

+41
-29
lines changed

11 files changed

+41
-29
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ module Public {
248248
/**
249249
* Holds if all the summaries that apply to `this` are auto generated and not manually created.
250250
*/
251-
final predicate isAutoGenerated() { this.hasProvenance("generated") and not this.isManual() }
251+
final predicate isAutoGenerated() {
252+
this.hasProvenance(["generated", "ai-generated"]) and not this.isManual()
253+
}
252254

253255
/**
254256
* Holds if there exists a manual summary that applies to `this`.
@@ -268,7 +270,7 @@ module Public {
268270
/**
269271
* Holds if the neutral is auto generated.
270272
*/
271-
predicate isAutoGenerated() { neutralElement(this, "generated") }
273+
predicate isAutoGenerated() { neutralElement(this, ["generated", "ai-generated"]) }
272274

273275
/**
274276
* Holds if there exists a manual neutral that applies to `this`.
@@ -1202,11 +1204,11 @@ module Private {
12021204
}
12031205

12041206
private string renderProvenance(SummarizedCallable c) {
1205-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1207+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12061208
}
12071209

12081210
private string renderProvenanceNeutral(NeutralCallable c) {
1209-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1211+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12101212
}
12111213

12121214
/**

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ module Public {
248248
/**
249249
* Holds if all the summaries that apply to `this` are auto generated and not manually created.
250250
*/
251-
final predicate isAutoGenerated() { this.hasProvenance("generated") and not this.isManual() }
251+
final predicate isAutoGenerated() {
252+
this.hasProvenance(["generated", "ai-generated"]) and not this.isManual()
253+
}
252254

253255
/**
254256
* Holds if there exists a manual summary that applies to `this`.
@@ -268,7 +270,7 @@ module Public {
268270
/**
269271
* Holds if the neutral is auto generated.
270272
*/
271-
predicate isAutoGenerated() { neutralElement(this, "generated") }
273+
predicate isAutoGenerated() { neutralElement(this, ["generated", "ai-generated"]) }
272274

273275
/**
274276
* Holds if there exists a manual neutral that applies to `this`.
@@ -1202,11 +1204,11 @@ module Private {
12021204
}
12031205

12041206
private string renderProvenance(SummarizedCallable c) {
1205-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1207+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12061208
}
12071209

12081210
private string renderProvenanceNeutral(NeutralCallable c) {
1209-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1211+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12101212
}
12111213

12121214
/**

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ module Public {
248248
/**
249249
* Holds if all the summaries that apply to `this` are auto generated and not manually created.
250250
*/
251-
final predicate isAutoGenerated() { this.hasProvenance("generated") and not this.isManual() }
251+
final predicate isAutoGenerated() {
252+
this.hasProvenance(["generated", "ai-generated"]) and not this.isManual()
253+
}
252254

253255
/**
254256
* Holds if there exists a manual summary that applies to `this`.
@@ -268,7 +270,7 @@ module Public {
268270
/**
269271
* Holds if the neutral is auto generated.
270272
*/
271-
predicate isAutoGenerated() { neutralElement(this, "generated") }
273+
predicate isAutoGenerated() { neutralElement(this, ["generated", "ai-generated"]) }
272274

273275
/**
274276
* Holds if there exists a manual neutral that applies to `this`.
@@ -1202,11 +1204,11 @@ module Private {
12021204
}
12031205

12041206
private string renderProvenance(SummarizedCallable c) {
1205-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1207+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12061208
}
12071209

12081210
private string renderProvenanceNeutral(NeutralCallable c) {
1209-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1211+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12101212
}
12111213

12121214
/**

java/ql/src/Metrics/Summaries/GeneratedVsManualCoverage.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private int getNumMadModeledApis(string package, string provenance) {
2828
or
2929
sc.isManual() and
3030
(
31-
if sc.hasProvenance("generated")
31+
if sc.hasProvenance(["generated", "ai-generated"])
3232
then
3333
// "both"
3434
provenance = "both"

java/ql/src/utils/modelconverter/ExtractNeutrals.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import semmle.code.java.dataflow.ExternalFlow
1010
from string package, string type, string name, string signature, string provenance
1111
where
1212
neutralModel(package, type, name, signature, provenance) and
13-
provenance != "generated"
13+
provenance != ["generated", "ai-generated"]
1414
select package, type, name, signature, provenance order by package, type, name, signature

java/ql/src/utils/modelconverter/ExtractSinks.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ from
1212
string input, string kind, string provenance
1313
where
1414
sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance) and
15-
provenance != "generated"
15+
provenance != ["generated", "ai-generated"]
1616
select package, type, subtypes, name, signature, ext, input, kind, provenance order by
1717
package, type, name, signature, input, kind

java/ql/src/utils/modelconverter/ExtractSources.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ from
1212
string output, string kind, string provenance
1313
where
1414
sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance) and
15-
provenance != "generated"
15+
provenance != ["generated", "ai-generated"]
1616
select package, type, subtypes, name, signature, ext, output, kind, provenance order by
1717
package, type, name, signature, output, kind

java/ql/src/utils/modelconverter/ExtractSummaries.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ from
1212
string input, string output, string kind, string provenance
1313
where
1414
summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance) and
15-
provenance != "generated"
15+
provenance != ["generated", "ai-generated"]
1616
select package, type, subtypes, name, signature, ext, input, output, kind, provenance order by
1717
package, type, name, signature, input, output, kind

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ module Public {
248248
/**
249249
* Holds if all the summaries that apply to `this` are auto generated and not manually created.
250250
*/
251-
final predicate isAutoGenerated() { this.hasProvenance("generated") and not this.isManual() }
251+
final predicate isAutoGenerated() {
252+
this.hasProvenance(["generated", "ai-generated"]) and not this.isManual()
253+
}
252254

253255
/**
254256
* Holds if there exists a manual summary that applies to `this`.
@@ -268,7 +270,7 @@ module Public {
268270
/**
269271
* Holds if the neutral is auto generated.
270272
*/
271-
predicate isAutoGenerated() { neutralElement(this, "generated") }
273+
predicate isAutoGenerated() { neutralElement(this, ["generated", "ai-generated"]) }
272274

273275
/**
274276
* Holds if there exists a manual neutral that applies to `this`.
@@ -1202,11 +1204,11 @@ module Private {
12021204
}
12031205

12041206
private string renderProvenance(SummarizedCallable c) {
1205-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1207+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12061208
}
12071209

12081210
private string renderProvenanceNeutral(NeutralCallable c) {
1209-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1211+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12101212
}
12111213

12121214
/**

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ module Public {
248248
/**
249249
* Holds if all the summaries that apply to `this` are auto generated and not manually created.
250250
*/
251-
final predicate isAutoGenerated() { this.hasProvenance("generated") and not this.isManual() }
251+
final predicate isAutoGenerated() {
252+
this.hasProvenance(["generated", "ai-generated"]) and not this.isManual()
253+
}
252254

253255
/**
254256
* Holds if there exists a manual summary that applies to `this`.
@@ -268,7 +270,7 @@ module Public {
268270
/**
269271
* Holds if the neutral is auto generated.
270272
*/
271-
predicate isAutoGenerated() { neutralElement(this, "generated") }
273+
predicate isAutoGenerated() { neutralElement(this, ["generated", "ai-generated"]) }
272274

273275
/**
274276
* Holds if there exists a manual neutral that applies to `this`.
@@ -1202,11 +1204,11 @@ module Private {
12021204
}
12031205

12041206
private string renderProvenance(SummarizedCallable c) {
1205-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1207+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12061208
}
12071209

12081210
private string renderProvenanceNeutral(NeutralCallable c) {
1209-
if c.isAutoGenerated() then result = "generated" else result = "manual"
1211+
if c.isManual() then result = "manual" else c.hasProvenance(result)
12101212
}
12111213

12121214
/**

0 commit comments

Comments
 (0)