-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: model top 100 JDK APIs #11572
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
Java: model top 100 JDK APIs #11572
Conversation
We shouldn't duplicate rows, and I think these generally make more sense in the |
Would it make sense to store them in a single file if maybe the model generator will be run on a list of top APIs like you suggested in the planning meeting today? Or at least tag the existing models somehow so they can be identified as top APIs by the generator? |
I think this makes sense - it will put the added data where it naturally belongs.
Good point that we want to ideally retain the information about top APIs somewhere.
Perhaps capture the information about the list of top 100 APIs in a test case that checks that a manual model exists for each of the APIs in the list? |
This should be possible to do in a database-independent way. (Unlike running the metric queries or generator queries.) |
Yes, I think that makes the most sense. The top 100 is a moving target (although unlikely to have changes that often), so taking a snapshot a wrapping that up as a test seems fine.
Unfortunately, not quite. As an example we have |
d21c6de
to
f1ddbbb
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
…ted by String.length
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
Review Consideration for commit bf6148c onwards:
|
I think what you did is pretty similar to what @aschackmull meant, with the addition that you could have /** Holds if `c` has the MaD-formatted name `apiName`. */
predicate hasApiName(Callable c, string apiName) {
apiName =
c.getDeclaringType().getPackage() + "." + c.getDeclaringType().getSourceDeclaration() + "#" +
c.getName() + paramsString(c)
} Which would still remove the code duplication, since the uses would look like: class TopJdkApi extends SummarizedCallableBase {
TopJdkApi() {
exists(string apiName |
hasApiName(this.asCallable(), apiName) and
topJdkApiName(apiName)
)
}
} and // top jdk api names for which there isn't a manual model
exists(TopJdkApi topApi |
not topApi.hasManualMadModel() and
hasApiName(topApi.asCallable(), apiName) and
message = "no manual model"
)
Those changes only add new edges and nodes, but the select results are the same. I'm not an expert, but AFAIK that has to do with how MaD rows are represented in the dataflow graph compared to regular CodeQL steps. So nothing you should worry about as long as the results don't change.
Given that it seems that the model generator will still be generally interested in parameterless static methods (just not as sinks nor summaries), I think it's a good idea to leave them as neutral models for the moment. If an hypothetical exclusion for summary models happens, those can be removed.
I think it looks right. As an optional nitpick, I'm not sure if specifying the kind of models (summary and neutral) is of general interest, so maybe a simpler I felt tempted to categorize this as a |
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
Thanks @atorralba! I've added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a few more minor suggestions after taking a closer look.
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to proxy @aschackmull almost-complete review (I didn't re-review in full) and get this merged if DCA is happy 😃.
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
Thanks @atorralba! DCA looks good now I think (the only failures are the typical |
Co-authored-by: yo-h <55373593+yo-h@users.noreply.github.com>
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,591,130,28,,,7,,,10
+ Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
- Totals,,217,8438,1563,129,6,10,107,33,1,86
+ Totals,,217,8449,1563,129,6,10,107,33,1,86
- java.lang,13,,66,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,54,12
+ java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,,
+ java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1, |
Description
This PR adds MaD models for top 100 JDK APIs which were not previously modeled. It also adds a test case that checks that a manual model exists for each of the top 100 APIs.
Consideration
Models:
java.lang.String#valueOf(Object)
andjava.lang.Throwable#printStackTrace()
.java.lang.String#charAt(int)
as a positive model based on the comment here, let me know if I should remove the model instead.Test Case: