Skip to content

Commit

Permalink
Increase IAST propagation to StringBuffer append (#8082)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariovido authored Dec 16, 2024
1 parent 0196f1e commit 52aeeec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static CharSequence afterInit(
@CallSite.After("java.lang.StringBuilder java.lang.StringBuilder.append(java.lang.StringBuffer)")
@CallSite.After("java.lang.StringBuffer java.lang.StringBuffer.append(java.lang.String)")
@CallSite.After("java.lang.StringBuffer java.lang.StringBuffer.append(java.lang.CharSequence)")
@CallSite.After("java.lang.StringBuffer java.lang.StringBuffer.append(java.lang.StringBuffer)")
@Nonnull
public static CharSequence afterAppend(
@CallSite.This @Nonnull final CharSequence self,
Expand All @@ -59,6 +60,8 @@ public static CharSequence afterAppend(

@CallSite.After(
"java.lang.StringBuilder java.lang.StringBuilder.append(java.lang.CharSequence, int, int)")
@CallSite.After(
"java.lang.StringBuffer java.lang.StringBuffer.append(java.lang.CharSequence, int, int)")
@Nonnull
public static CharSequence afterAppendWithSubstring(
@CallSite.This @Nonnull final CharSequence self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class StringBuilderCallSiteTest extends AgentTestRunner {
0 * _

where:
suite | target | param | expected
new TestStringBuilderSuite() | new StringBuilder('Hello ') | 23.5F | 'Hello 23.5'
new TestStringBuilderSuite() | new StringBuilder('Hello ') | new StringBuffer('World!') | 'Hello World!'
new TestStringBuilderSuite() | new StringBuilder('Hello ') | 'World!' | 'Hello World!'
new TestStringBufferSuite() | new StringBuffer('Hello ') | 23.5F | 'Hello 23.5'
new TestStringBufferSuite() | new StringBuffer('Hello ') | new StringBuilder('World!') | 'Hello World!'
new TestStringBufferSuite() | new StringBuffer('Hello ') | 'World!' | 'Hello World!'
suite | target | param | expected
new TestStringBuilderSuite() | sb('Hello ') | 23.5F | 'Hello 23.5'
new TestStringBuilderSuite() | sb('Hello ') | sbf('World!') | 'Hello World!'
new TestStringBuilderSuite() | sb('Hello ') | 'World!' | 'Hello World!'
new TestStringBufferSuite() | sbf('Hello ') | 23.5F | 'Hello 23.5'
new TestStringBufferSuite() | sbf('Hello ') | sbf('World!') | 'Hello World!'
new TestStringBufferSuite() | sbf('Hello ') | 'World!' | 'Hello World!'
}

void 'test string builder append object throwing exceptions'() {
Expand Down Expand Up @@ -104,8 +104,9 @@ class StringBuilderCallSiteTest extends AgentTestRunner {
0 * _

where:
suite | target | param | start | end | expected
new TestStringBuilderSuite() | new StringBuilder('Hello ') | 'World!' | 0 | 5 | 'Hello World'
suite | target | param | start | end | expected
new TestStringBuilderSuite() | sb('Hello ') | 'World!' | 0 | 5 | 'Hello World'
new TestStringBufferSuite() | sbf('Hello ') | 'World!' | 0 | 5 | 'Hello World'
}

void 'test string builder toString call site'() {
Expand Down

0 comments on commit 52aeeec

Please sign in to comment.