2015-06-08 18:29:37 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010-2015 SAP SE.
|
|
|
|
*
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-05-21 14:58:16 +00:00
|
|
|
package com.logicalhacking.dasca.dataflow.test.data;
|
2015-06-08 18:29:37 +00:00
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.Statement;
|
|
|
|
|
2017-05-21 14:58:16 +00:00
|
|
|
import com.logicalhacking.dasca.dataflow.test.data.dummy.IO;
|
2015-06-08 18:29:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Test Case 07:
|
|
|
|
//reachability from bad sink to bad source via multiple if-statements
|
|
|
|
public class Test07 {
|
2015-06-08 19:43:23 +00:00
|
|
|
|
2015-06-08 18:29:37 +00:00
|
|
|
|
|
|
|
public void bad() {
|
|
|
|
String userName = null;
|
|
|
|
boolean local_true = true;
|
|
|
|
if(local_true) {
|
2015-06-08 19:43:23 +00:00
|
|
|
userName = IO.readLine();
|
2015-06-08 18:29:37 +00:00
|
|
|
}
|
2015-06-08 19:43:23 +00:00
|
|
|
|
|
|
|
if(!local_true) {
|
2015-06-08 18:29:37 +00:00
|
|
|
userName = IO.readLineGood();
|
|
|
|
}
|
|
|
|
Connection conn = IO.getDBConnection();
|
|
|
|
try {
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
stmt.execute("SELECT * FROM user WHERE name='" + userName + "';");
|
|
|
|
} catch(SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2015-06-08 19:43:23 +00:00
|
|
|
|
2015-06-08 18:29:37 +00:00
|
|
|
public void good01() {
|
|
|
|
String userName = null;
|
|
|
|
boolean local_true = true;
|
|
|
|
if(!local_true) {
|
2015-06-08 19:43:23 +00:00
|
|
|
userName = IO.readLine();
|
2015-06-08 18:29:37 +00:00
|
|
|
}
|
2015-06-08 19:43:23 +00:00
|
|
|
|
|
|
|
if(local_true) {
|
2015-06-08 18:29:37 +00:00
|
|
|
userName = IO.readLineGood();
|
|
|
|
}
|
|
|
|
Connection conn = IO.getDBConnection();
|
|
|
|
try {
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
stmt.execute("SELECT * FROM user WHERE name='" + userName + "';");
|
|
|
|
} catch(SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2015-06-08 19:43:23 +00:00
|
|
|
|
2015-06-08 18:29:37 +00:00
|
|
|
public static void main(String[] args) {
|
2015-06-08 19:43:23 +00:00
|
|
|
Test07 test = new Test07();
|
|
|
|
test.good01();
|
|
|
|
test.bad();
|
|
|
|
}
|
2015-06-08 18:29:37 +00:00
|
|
|
}
|