-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: Support for With[out]Element for MaD. #13546
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
Conversation
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,682,184,76,,9,,,17
+ Java Standard Library,``java.*``,3,683,184,76,,9,,,17
- Totals,,283,12766,2040,286,16,122,33,1,390
+ Totals,,283,12767,2040,286,16,122,33,1,390
- java.util,44,,484,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,440
+ java.util,44,,485,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,441 |
e7cf024
to
500480b
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,683,197,76,,9,,,17
+ Java Standard Library,``java.*``,3,684,197,76,,9,,,17
- Totals,,283,13593,2059,286,16,122,33,1,390
+ Totals,,283,13594,2059,286,16,122,33,1,390
- java.util,44,,484,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,440
+ java.util,44,,485,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,441 |
500480b
to
37d7680
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,683,197,76,,9,,,17
+ Java Standard Library,``java.*``,3,684,197,76,,9,,,17
- Totals,,283,13593,2059,286,16,122,33,1,390
+ Totals,,283,13594,2059,286,16,122,33,1,390
- java.util,44,,484,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,440
+ java.util,44,,485,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,441 |
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,683,197,76,,9,,,17
+ Java Standard Library,``java.*``,3,684,197,76,,9,,,17
- Totals,,283,13593,2059,286,16,122,33,1,390
+ Totals,,283,13594,2059,286,16,122,33,1,390
- java.util,44,,484,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,440
+ java.util,44,,485,,,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,44,441 |
…ted in collections/B.java).
c0f7b18
to
ffd1456
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,689,205,80,,9,,,18
+ Java Standard Library,``java.*``,3,690,205,80,,9,,,18
- Totals,,283,18451,2142,290,16,122,33,1,391
+ Totals,,283,18452,2142,290,16,122,33,1,391
- java.util,45,,485,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,440
+ java.util,45,,486,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,441 |
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.
I added a few minor questions, but otherwise looks reasonable to me:
- Should there potentially be a change note for this since data extensions for Java is in beta?
- For my own understanding: What is the benefit of including the
.WithElement
option if.Element -> .Element
is identical?
docs/codeql/codeql-language-guides/customizing-library-models-for-java.rst
Outdated
Show resolved
Hide resolved
java/ql/lib/ext/java.util.model.yml
Outdated
# When `WithoutElement` is implemented, these should be changed to summary models of the form `Argument[this].WithoutElement -> Argument[this]`. | ||
- ["java.util", "Collection", "removeIf", "(Predicate)", "summary", "manual"] | ||
- ["java.util", "Iterator", "remove", "()", "summary", "manual"] | ||
- ["java.util", "List", "clear", "()", "summary", "manual"] | ||
- ["java.util", "List", "remove", "(Object)", "summary", "manual"] | ||
- ["java.util", "Map", "clear", "()", "summary", "manual"] | ||
- ["java.util", "Set", "clear", "()", "summary", "manual"] |
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.
Minor request that you can ignore if you want 🙂: Would it make sense to update the rest of these models to use WithoutElement
on this PR?
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.
With the current implementation we can't use WithoutElement
and WithElement
for anything else than collection content (not array content or dictionary content).
Would it maybe make more sense to include these as well for Java?
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.
WithoutElement should still apply as-is to Set.clear()
, right?
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.
Yes, right - I will introduce that summary and make a test.
A question about remove[If]
neutrals. Since we are not tracking individual elements for collections in Java, we will not be able to re-write these using WithElement
and WithoutElement
. Should we move these neutrals to their proper location in the data extension files or should we have a summary instead (is it a better assumption that there is element flow via eg. List.remove
as it only might remove a single element)?
I don't think that it is strictly needed with a change note as it is a non breaking change and since we are in private beta, but let us add one anyway (it can't hurt to advertise it a bit more). The only "minor" benefit is that it might perform a bit better than |
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,689,205,80,,9,,,18
+ Java Standard Library,``java.*``,3,690,205,80,,9,,,18
- Totals,,283,18451,2142,290,16,122,33,1,391
+ Totals,,283,18452,2142,290,16,122,33,1,391
- java.util,45,,485,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,440
+ java.util,45,,486,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,441 |
That's not entirely correct. The |
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,689,205,80,,9,,,18
+ Java Standard Library,``java.*``,3,691,205,80,,9,,,18
- Totals,,283,18451,2142,290,16,122,33,1,391
+ Totals,,283,18453,2142,290,16,122,33,1,391
- java.util,45,,485,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,440
+ java.util,45,,487,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,442 |
Hah, so what you are saying is that we infact should not use |
…oduce appropriate tests.
823be50
to
0ed724e
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Java Standard Library,``java.*``,3,689,201,76,,9,,,18
+ Java Standard Library,``java.*``,3,691,201,76,,9,,,18
- Totals,,283,18451,2138,286,16,122,33,1,391
+ Totals,,283,18453,2138,286,16,122,33,1,391
- java.util,45,,485,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,440
+ java.util,45,,487,,,1,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,45,442 |
In this PR we introduce
WithoutElement
andWithElement
for Java MaD.Assume that
c
is a callable and assume thatA
andB
are access paths and assume we have a summary that defines that data can flow fromA
toB
viac
:In case
A
andB
targets collections this summary also implies that there is flow from the elements in the source collection to the elements in the target collection.That is
However, in some cases we want to avoid exactly this.
One example could be
List.clear()
.Using
WithoutElement
it is now possible to defineIf the list itself is tainted then the taint is propagated via
clear
, but not the element taint.That is,
The dual
WithElement
is identical to an already existing constructFor completeness also note that