Search in sources :

Example 16 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testCompoundAssignmentNegative.

@Test
public void testCompoundAssignmentNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/compound-assignment-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 3);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'secureIn'", 5, 20);
    BAssertUtil.validateError(result, 1, "tainted value passed to sensitive parameter 'secureIn'", 9, 20);
    BAssertUtil.validateError(result, 2, "tainted value passed to sensitive parameter 'secureIn'", 14, 20);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 17 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testIfConditionNegative.

@Test
public void testIfConditionNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/if-condition-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 2);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'secureIn'", 8, 20);
    BAssertUtil.validateError(result, 1, "tainted value passed to sensitive parameter 'secureIn'", 16, 20);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 18 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class TaintedStatusPropagationTest method testCastNegative.

@Test
public void testCastNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/propagation/cast-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 1);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'secureIn'", 4, 20);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 19 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class IOTest method testFileIONegative.

@Test
public void testFileIONegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/connectors/file-read-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 3);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'accessMode'", 6, 17);
    BAssertUtil.validateError(result, 1, "tainted value passed to sensitive parameter 'accessMode'", 8, 50);
    BAssertUtil.validateError(result, 2, "tainted value passed to sensitive parameter 'nBytes'", 11, 36);
// Blocked on return annotation support
// BAssertUtil.validateError(result, 3, "tainted value passed to sensitive parameter 'sensitiveValue'", 16, 18);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 20 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class SQLTest method testSelectWithTaintedQueryNegative.

@Test
public void testSelectWithTaintedQueryNegative() {
    CompileResult result = BCompileUtil.compile("test-src/taintchecking/connectors/sql-select-tainted-query-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length == 1);
    BAssertUtil.validateError(result, 0, "tainted value passed to sensitive parameter 'sqlQuery'", 18, 31);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Aggregations

CompileResult (org.ballerinalang.launcher.util.CompileResult)291 Test (org.testng.annotations.Test)287 BValue (org.ballerinalang.model.values.BValue)60 PackageNode (org.ballerinalang.model.tree.PackageNode)16 BLangDocumentation (org.wso2.ballerinalang.compiler.tree.BLangDocumentation)14 BString (org.ballerinalang.model.values.BString)13 BInteger (org.ballerinalang.model.values.BInteger)12 Path (java.nio.file.Path)5 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)5 File (java.io.File)4 GrpcCmd (org.ballerinalang.protobuf.cmd.GrpcCmd)4 BStringArray (org.ballerinalang.model.values.BStringArray)3 BLangDeprecatedNode (org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 BFloat (org.ballerinalang.model.values.BFloat)2 BIntArray (org.ballerinalang.model.values.BIntArray)2 BMap (org.ballerinalang.model.values.BMap)2 BeforeTest (org.testng.annotations.BeforeTest)2 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)2