Skip to content

Java: improve models for some important JDK methods - #15280

Merged
owen-mc merged 6 commits into
github:mainfrom
owen-mc:java/add-manual-models-for-df-generation
Jan 11, 2024
Merged

Java: improve models for some important JDK methods#15280
owen-mc merged 6 commits into
github:mainfrom
owen-mc:java/add-manual-models-for-df-generation

Conversation

@owen-mc

@owen-mc owen-mc commented Jan 10, 2024

Copy link
Copy Markdown
Contributor

While working on dataflow-generated models, I found that these manual models needed to be added/improved to avoid clashes.

Note that I have added a neutral model for String.valueOf(Object). We had already made a conscious choice not to make a summary model for this method (as noted here), and this neutral model is just recording this fact (and stopping any generated models for it from having an effect). I did add a summary model for String.valueOf(charsequence), and we already have one for String.valueOf(char), which I hope will cover many cases where there should be flow.

@owen-mc
owen-mc requested a review from a team as a code owner January 10, 2024 12:05
@github-actions github-actions Bot added the Java label Jan 10, 2024
@owen-mc owen-mc changed the title Java: add manual models for df generation Java: add some models for important JDK methods Jan 10, 2024
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,10,724,231,79,,9,,,19
+    Java Standard Library,``java.*``,10,733,231,79,,9,,,19
-    Totals,,308,18935,2462,331,16,128,33,1,402
+    Totals,,308,18944,2462,331,16,128,33,1,402
  • Changes to framework-coverage-java.csv:
- java.lang,33,3,94,,13,,,,,,1,,,,,,,,,,,,8,,,6,,,4,,,1,,,,,,,,,,,,,,3,,,57,37
+ java.lang,33,3,103,,13,,,,,,1,,,,,,,,,,,,8,,,6,,,4,,,1,,,,,,,,,,,,,,3,,,60,43

@owen-mc owen-mc changed the title Java: add some models for important JDK methods Java: improve models for some important JDK methods Jan 10, 2024
@owen-mc

owen-mc commented Jan 10, 2024

Copy link
Copy Markdown
Contributor Author

Does this PR need a change note?

@atorralba

Copy link
Copy Markdown
Contributor

Does this PR need a change note?

Since there's potential for users to get impacted (i.e changes in alerts), I'd say yes.

@atorralba atorralba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Models LGTM with 1 minor question.

- ["java.lang", "Exception", False, "Exception", "(String,Throwable)", "", "Argument[0]", "Argument[this].SyntheticField[java.lang.Throwable.message]", "value", "manual"]
- ["java.lang", "Exception", False, "Exception", "(String,Throwable)", "", "Argument[1]", "Argument[this].SyntheticField[java.lang.Throwable.cause]", "value", "manual"]
- ["java.lang", "Exception", False, "Exception", "(Throwable)", "", "Argument[0]", "Argument[this].SyntheticField[java.lang.Throwable.cause]", "value", "manual"]
- ["java.lang", "Exception", False, "Exception", "(Throwable)", "", "Argument[0].SyntheticField[java.lang.Throwable.message]", "Argument[this].SyntheticField[java.lang.Throwable.message]", "taint", "manual"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a taint model?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. It's implemented as a call to the equivalent constructor of the base class Throwable, so I guess I was copying the model for that (also in this PR). And that is implemented using toString(), which prepends the class name in front of the message. So I guess it's the prepending the class name which changes the string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair :)

@atorralba atorralba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, a test is failing.

@owen-mc

owen-mc commented Jan 10, 2024

Copy link
Copy Markdown
Contributor Author

Hopefully I've fixed CI now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants