-
Notifications
You must be signed in to change notification settings - Fork 45
Introduce utbot taint analysis #1966
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3c32bef
Add taint analysis
mmvpm 9efeaa0
Add taint analysis unit tests
mmvpm e8ed0cb
Fix after review
mmvpm 9f2d100
Fix after review (2)
mmvpm b65e3d0
Change setting name
mmvpm 1dd1547
Fix a bug with throwTaintErrorForEachMarkSeparately setting
mmvpm a142d8d
Add a new unit test for throwTaintErrorForEachMarkSeparately setting
mmvpm cef82a2
Merge branch 'main' into ideaseeker/uta_draft
mmvpm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintBranchingTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.utbot.examples.taint | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.utbot.framework.plugin.api.TaintAnalysisError | ||
import org.utbot.taint.TaintConfigurationProviderResources | ||
import org.utbot.testcheckers.eq | ||
import org.utbot.testing.UtValueTestCaseCheckerForTaint | ||
import org.utbot.testing.isException | ||
|
||
internal class TaintBranchingTest : UtValueTestCaseCheckerForTaint( | ||
testClass = TaintBranching::class, | ||
taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintBranchingConfig.yaml") | ||
) { | ||
@Test | ||
fun testTaintBad() { | ||
checkWithException( | ||
TaintBranching::bad, | ||
eq(3), // success (x2) & taint error | ||
{ cond, r -> cond == r.isException<TaintAnalysisError>() }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGood() { | ||
checkWithException( | ||
TaintBranching::good, | ||
eq(2), // success in both cases | ||
{ _, r -> r.isSuccess }, | ||
) | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintCleanerConditionsTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.utbot.examples.taint | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.utbot.framework.plugin.api.TaintAnalysisError | ||
import org.utbot.taint.TaintConfigurationProviderResources | ||
import org.utbot.testcheckers.eq | ||
import org.utbot.testing.UtValueTestCaseCheckerForTaint | ||
import org.utbot.testing.isException | ||
|
||
internal class TaintCleanerConditionsTest : UtValueTestCaseCheckerForTaint( | ||
testClass = TaintCleanerConditions::class, | ||
taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintCleanerConditionsConfig.yaml") | ||
) { | ||
@Test | ||
fun testTaintBadArg() { | ||
checkWithException( | ||
TaintCleanerConditions::badArg, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintBadReturn() { | ||
checkWithException( | ||
TaintCleanerConditions::badReturn, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintBadThis() { | ||
checkWithException( | ||
TaintCleanerConditions::badThis, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGoodArg() { | ||
checkWithException( | ||
TaintCleanerConditions::goodArg, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGoodReturn() { | ||
checkWithException( | ||
TaintCleanerConditions::goodReturn, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGoodThis() { | ||
checkWithException( | ||
TaintCleanerConditions::goodThis, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintCleanerSimpleTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.utbot.examples.taint | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.utbot.framework.plugin.api.TaintAnalysisError | ||
import org.utbot.taint.TaintConfigurationProviderResources | ||
import org.utbot.testcheckers.eq | ||
import org.utbot.testing.UtValueTestCaseCheckerForTaint | ||
import org.utbot.testing.isException | ||
|
||
internal class TaintCleanerSimpleTest : UtValueTestCaseCheckerForTaint( | ||
testClass = TaintCleanerSimple::class, | ||
taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintCleanerSimpleConfig.yaml") | ||
) { | ||
@Test | ||
fun testTaintBad() { | ||
checkWithException( | ||
TaintCleanerSimple::bad, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGood() { | ||
checkWithException( | ||
TaintCleanerSimple::good, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintLongPathTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.utbot.examples.taint | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.utbot.framework.plugin.api.TaintAnalysisError | ||
import org.utbot.taint.TaintConfigurationProviderResources | ||
import org.utbot.testcheckers.eq | ||
import org.utbot.testing.UtValueTestCaseCheckerForTaint | ||
import org.utbot.testing.isException | ||
|
||
internal class TaintLongPathTest : UtValueTestCaseCheckerForTaint( | ||
testClass = TaintLongPath::class, | ||
taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintLongPathConfig.yaml") | ||
) { | ||
@Test | ||
fun testTaintBad() { | ||
checkWithException( | ||
TaintLongPath::bad, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGood() { | ||
checkWithException( | ||
TaintLongPath::good, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
utbot-framework-test/src/test/kotlin/org/utbot/examples/taint/TaintOtherClassTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.utbot.examples.taint | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.utbot.framework.plugin.api.TaintAnalysisError | ||
import org.utbot.taint.TaintConfigurationProviderResources | ||
import org.utbot.testcheckers.eq | ||
import org.utbot.testing.UtValueTestCaseCheckerForTaint | ||
import org.utbot.testing.isException | ||
|
||
internal class TaintOtherClassTest : UtValueTestCaseCheckerForTaint( | ||
testClass = TaintOtherClass::class, | ||
taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintOtherClassConfig.yaml") | ||
) { | ||
@Test | ||
fun testTaintBad() { | ||
checkWithException( | ||
TaintOtherClass::bad, | ||
eq(2), // success & taint error | ||
{ r -> r.isException<TaintAnalysisError>() }, | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
|
||
@Test | ||
fun testTaintGood() { | ||
checkWithException( | ||
TaintOtherClass::good, | ||
eq(1), // only success | ||
{ r -> r.isSuccess }, | ||
) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.