DASCA/com.logicalhacking.dasca.da.../src/main/java/com/logicalhacking/dasca/dataflow/test/data/Test04.java

67 lines
1.8 KiB
Java
Raw Normal View History

/*
2018-10-30 00:09:20 +00:00
* Copyright (c) 2010-2015 SAP SE.
* 2016-2018 The University of Sheffield.
*
* 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/
*
2018-10-30 00:09:20 +00:00
* SPDX-License-Identifier: EPL-2.0
*/
package com.logicalhacking.dasca.dataflow.test.data;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import com.logicalhacking.dasca.dataflow.test.data.dummy.IO;
// Test Case 04:
//reachability from bad sink to bad source via local boolean variable
public class Test04 {
public void bad() {
String userName;
boolean local_false = false;
if(local_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 = IO.readLine();
boolean local_true = true;
if(local_true) {
userName = "fix";
} 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 static void main(String[] args) {
Test04 test = new Test04();
test.good01();
test.bad();
}
}