Search in sources :

Example 66 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class MySqlWallTest80 method test_true.

public void test_true() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    Assert.assertTrue(//
    provider.checkValid("SELECT * FROM T WHERE FID = ? OR FID LIKE 1"));
    Assert.assertEquals(1, provider.getTableStats().size());
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 67 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class MySqlWallTest82 method test_false.

public void test_false() throws Exception {
    WallProvider provider = new MySqlWallProvider();
    provider.getConfig().setStrictSyntaxCheck(false);
    Assert.assertFalse(//
    provider.checkValid("SELECT * FROM T WHERE FID = '\0a' OR LEAST(2,1,9,8) = 1"));
    Assert.assertEquals(1, provider.getTableStats().size());
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider)

Example 68 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class SQLServerWallTest_0 method initWallProvider.

private WallProvider initWallProvider() {
    WallProvider provider = new SQLServerWallProvider();
    provider.getConfig().setStrictSyntaxCheck(false);
    provider.getConfig().setMultiStatementAllow(true);
    provider.getConfig().setConditionAndAlwayTrueAllow(true);
    provider.getConfig().setNoneBaseStatementAllow(true);
    provider.getConfig().setLimitZeroAllow(true);
    provider.getConfig().setConditionDoubleConstAllow(true);
    provider.getConfig().setCommentAllow(true);
    provider.getConfig().setSelectUnionCheck(false);
    return provider;
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Example 69 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class SQLServerWallTest_10 method test_true.

public void test_true() throws Exception {
    WallProvider provider = new SQLServerWallProvider();
    String sql = "select top 50 * FROM [V_Goods_WithAvailableStockQuantity] where Status='����' and (Code like '%mu%' ESCAPE '\' or Model like '%mu%' ESCAPE '\' or Spec like '%mu%' ESCAPE '\' or BarCode like '%mu%' ESCAPE '\' or ProductName like '%mu%' ESCAPE '\' or dbo.F_GetPY(ProductName) like '%mu%' ESCAPE '\') ";
    Assert.assertTrue(provider.checkValid(sql));
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Example 70 with WallProvider

use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.

the class SQLServerWallTest_11 method test_true.

public void test_true() throws Exception {
    WallProvider provider = new SQLServerWallProvider();
    provider.getConfig().setCommentAllow(true);
    String sql = //
    "SELECT KL_ArticleContent,KL_ArticleTitle " + //
    "FROM dbo.KL_Article " + //
    "WHERE KL_ArticleId =-4731 " + //
    "UNION ALL " + "SELECT (SELECT TOP 1 CHAR(58)+CHAR(108)+CHAR(107)+CHAR(103)+CHAR(58)+ISNULL(CAST(name AS NVARCHAR(4000)),CHAR(32))+CHAR(58)+CHAR(109)+CHAR(122)+CHAR(104)+CHAR(58) FROM sys.sql_logins WHERE ISNULL(name,CHAR(32)) NOT IN (SELECT TOP 0 ISNULL(name,CHAR(32)) FROM sys.sql_logins ORDER BY 1) ORDER BY 1),NULL-- ";
    Assert.assertFalse(provider.checkValid(sql));
}
Also used : WallProvider(com.alibaba.druid.wall.WallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider) SQLServerWallProvider(com.alibaba.druid.wall.spi.SQLServerWallProvider)

Aggregations

WallProvider (com.alibaba.druid.wall.WallProvider)195 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)182 SQLServerWallProvider (com.alibaba.druid.wall.spi.SQLServerWallProvider)47 WallTableStat (com.alibaba.druid.wall.WallTableStat)41 PGWallProvider (com.alibaba.druid.wall.spi.PGWallProvider)36 OracleWallProvider (com.alibaba.druid.wall.spi.OracleWallProvider)34 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)3 Violation (com.alibaba.druid.wall.Violation)2 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 PGSQLStatementParser (com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser)1 PGSchemaStatVisitor (com.alibaba.druid.sql.dialect.postgresql.visitor.PGSchemaStatVisitor)1 WallConfig (com.alibaba.druid.wall.WallConfig)1 WallFunctionStat (com.alibaba.druid.wall.WallFunctionStat)1 Map (java.util.Map)1 Test (org.junit.Test)1