mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[java-inspections] IDEA-318681, IDEA-318678, IDEA-318677, IDEA-318676 Improve previews, get rid of external annotations
GitOrigin-RevId: 57d45849299ce12c5ec19d84dcabdaaee00c3831
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bdfa6f8ccb
commit
5032fa91dd
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'id'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'id'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,9 +1,8 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
|
||||
@Untainted String field = baz();
|
||||
@Untainted String field = "";
|
||||
|
||||
void test(boolean b) {
|
||||
String s = b ? foo() : field;
|
||||
@@ -11,16 +10,9 @@ class Simple {
|
||||
}
|
||||
|
||||
@Untainted String foo() {
|
||||
return bar();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Untainted String bar() {
|
||||
return baz();
|
||||
}
|
||||
|
||||
@Untainted String baz() {
|
||||
return foo();
|
||||
}
|
||||
|
||||
void sink(@Untainted String s) {}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
|
||||
String field = baz();
|
||||
String field = "";
|
||||
|
||||
void test(boolean b) {
|
||||
String s = b ? foo() : field;
|
||||
@@ -11,16 +10,9 @@ class Simple {
|
||||
}
|
||||
|
||||
String foo() {
|
||||
return bar();
|
||||
return "";
|
||||
}
|
||||
|
||||
String bar() {
|
||||
return baz();
|
||||
}
|
||||
|
||||
String baz() {
|
||||
return foo();
|
||||
}
|
||||
|
||||
void sink(@Untainted String s) {}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "false"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'a'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'a'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'a'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 'a'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,4 +1,3 @@
|
||||
// "Propagate safe annotation from 's'" "false"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
@@ -1,20 +0,0 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
|
||||
void test() {
|
||||
String s = foo();
|
||||
sink(s);
|
||||
}
|
||||
|
||||
@Untainted String foo() {
|
||||
return bar();
|
||||
}
|
||||
|
||||
@Untainted String bar() {
|
||||
return "safe";
|
||||
}
|
||||
|
||||
void sink(@Untainted String s) {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
|
||||
String field = source();
|
||||
|
||||
void test() {
|
||||
String s = field;
|
||||
sink(<caret>s);
|
||||
}
|
||||
|
||||
void sink(@Untainted String s) {}
|
||||
|
||||
@Tainted String source() {
|
||||
return "unsafe";
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// "Propagate safe annotation from 's'" "true"
|
||||
import org.checkerframework.checker.tainting.qual.*;
|
||||
|
||||
class Simple {
|
||||
|
||||
void test() {
|
||||
String s = foo();
|
||||
sink(<caret>s);
|
||||
}
|
||||
|
||||
String foo() {
|
||||
return bar();
|
||||
}
|
||||
|
||||
String bar() {
|
||||
return "safe";
|
||||
}
|
||||
|
||||
void sink(@Untainted String s) {}
|
||||
}
|
||||
@@ -74,4 +74,28 @@ class JavaMarkAsSafeFixSourceToSinkFlowInspectionTest : SourceToSinkFlowInspecti
|
||||
prepareJsr()
|
||||
myFixture.testQuickFix("CommonCasesJsr.java", "Mark 's1' as requiring validation", true)
|
||||
}
|
||||
|
||||
fun `test unknown field`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("UnknownField.java", "Mark 's' as requiring validation", true)
|
||||
}
|
||||
|
||||
fun `test unknown method`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("UnknownMethod.java", "Mark 's' as requiring validation", true)
|
||||
}
|
||||
|
||||
fun `test tainted method`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFixUnavailable("TaintedMethod.java", "Mark 's' as requiring validation")
|
||||
}
|
||||
|
||||
fun `test recursive 2 path`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("RecursiveTwoPaths.java", "Mark 's' as requiring validation", true)
|
||||
}
|
||||
fun `test recursive`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("Recursive.java", "Mark 'id' as requiring validation", true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.intellij.codeInspection.tests.java.sourceToSink
|
||||
|
||||
import com.intellij.codeInspection.tests.sourceToSink.SourceToSinkFlowInspectionTestBase
|
||||
import com.intellij.jvm.analysis.JavaJvmAnalysisTestUtil
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
|
||||
private const val inspectionPath = "/codeInspection/sourceToSinkFlow/propagateSafe"
|
||||
|
||||
@TestDataPath("\$CONTENT_ROOT/testData$inspectionPath")
|
||||
class JavaPropagateFixSourceToSinkFlowInspectionTest : SourceToSinkFlowInspectionTestBase() {
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
return JAVA_17
|
||||
}
|
||||
|
||||
override fun getBasePath(): String {
|
||||
return JavaJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + inspectionPath
|
||||
}
|
||||
|
||||
fun `test ParameterMethodUntainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterMethodUntainted.java", "Show propagation tree from 'a'")
|
||||
}
|
||||
|
||||
fun `test tainted field`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFixUnavailable("TaintedField.java", "Show propagation tree from 'a'")
|
||||
}
|
||||
|
||||
fun `test ParameterParameterUntainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterParameterUntainted.java", "Show propagation tree from 'a'")
|
||||
}
|
||||
|
||||
fun `test ParameterMethodUnknown`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterMethodUnknown.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test ParameterMethodTainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterMethodTainted.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test ParameterFieldUnknown`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterFieldUnknown.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test ParameterFieldTainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("ParameterFieldTainted.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test Parameter`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("Parameter.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodMethodUnknown`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodMethodUnknown.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodMethodTainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodMethodTainted.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodFieldUnknown`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodFieldUnknown.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodFieldTainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodFieldTainted.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodFieldMethodUnknown`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodFieldMethodUnknown.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test MethodFieldMethodTainted`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("MethodFieldMethodTainted.java", "Show propagation tree from 's'")
|
||||
}
|
||||
|
||||
fun `test AnotherClassMethodCall`() {
|
||||
prepareCheckFramework()
|
||||
myFixture.testQuickFix("AnotherClassMethodCall.java", "Show propagation tree from 's'")
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.intellij.codeInspection.tests.java.sourceToSink;
|
||||
|
||||
public class PropagateFixTest extends SourceToSinkFixBaseTest {
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInspection/sourceToSinkFlow/propagateSafe";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldBeAvailableAfterExecution() {
|
||||
return getTestName(true).contains("Tainted");
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.intellij.codeInspection.tests.java.sourceToSink;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.sourceToSink.SourceToSinkFlowInspection;
|
||||
import com.intellij.jvm.analysis.JavaJvmAnalysisTestUtil;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.MavenDependencyUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
abstract class SourceToSinkFixBaseTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool @NotNull [] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new SourceToSinkFlowInspection()};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module,
|
||||
@NotNull ModifiableRootModel model,
|
||||
@NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
MavenDependencyUtil.addFromMaven(model, "org.checkerframework:checker-qual:3.18.0");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull String getTestDataPath() {
|
||||
return PathManager.getCommunityHomePath() + JavaJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user