2015-06-08 18:29:37 +00:00
|
|
|
/*
|
2018-10-30 00:09:20 +00:00
|
|
|
* Copyright (c) 2010-2015 SAP SE.
|
|
|
|
* 2016-2018 The University of Sheffield.
|
|
|
|
*
|
2015-06-08 18:29:37 +00:00
|
|
|
* All rights reserved. This program and the accompanying materials
|
2018-10-30 00:09:20 +00:00
|
|
|
* This program and the accompanying materials are made
|
|
|
|
* available under the terms of the Eclipse Public License 2.0
|
|
|
|
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
2015-06-08 18:29:37 +00:00
|
|
|
*
|
2018-10-30 00:09:20 +00:00
|
|
|
* SPDX-License-Identifier: EPL-2.0
|
2015-06-08 18:29:37 +00:00
|
|
|
*/
|
|
|
|
|
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 02:
|
|
|
|
// reachability from bad sink to bad source via global boolean constant
|
|
|
|
public class Test02 {
|
2015-06-08 19:43:23 +00:00
|
|
|
|
|
|
|
private final boolean final_false = false;
|
2015-06-08 18:29:37 +00:00
|
|
|
|
|
|
|
public void bad() {
|
|
|
|
String userName;
|
|
|
|
if(final_false) {
|
|
|
|
userName = "fix";
|
|
|
|
} else {
|
|
|
|
userName = IO.readLine();
|
|
|
|
}
|
|
|
|
Connection conn = IO.getDBConnection();
|
|
|
|
try {
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
stmt.execute("SELECT * FROM user WHERE name='" + userName + "';");
|
|
|
|
} catch(SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void good01() {
|
|
|
|
String userName;
|
|
|
|
if(final_false) {
|
|
|
|
userName = IO.readLine();
|
|
|
|
} else {
|
|
|
|
userName = "fix";
|
|
|
|
}
|
|
|
|
Connection conn = IO.getDBConnection();
|
|
|
|
try {
|
|
|
|
Statement stmt = conn.createStatement();
|
|
|
|
stmt.execute("SELECT * FROM user WHERE name='" + userName + "';");
|
|
|
|
} catch(SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void good02() {
|
|
|
|
String userName = IO.readLine();
|
|
|
|
|
|
|
|
if(final_false) {
|
2015-06-08 19:43:23 +00:00
|
|
|
Connection conn = IO.getDBConnection();
|
2015-06-08 18:29:37 +00:00
|
|
|
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
|
|
|
Test02 test = new Test02();
|
|
|
|
test.good01();
|
|
|
|
test.good02();
|
|
|
|
test.bad();
|
|
|
|
}
|
2015-06-08 18:29:37 +00:00
|
|
|
}
|