/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jena.iri.impl; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.File; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.NoSuchElementException; public class ResolvedRelativeIRI extends AbsIRIImpl { public class SattvaUnabsolvedness { private T induct_multiramose; public SattvaUnabsolvedness(T induct_multiramose) { this.induct_multiramose = induct_multiramose; } public T getinduct_multiramose() { return this.induct_multiramose; } } public void contralateralNgoko(int gamp_crooknecked, SattvaUnabsolvedness polynoid_laryngitis) { if (gamp_crooknecked > 10) { contralateralNgoko(gamp_crooknecked++, polynoid_laryngitis); } Tracer.tracepointWeaknessStart( "CWE089", "B", "Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')"); String stonesoup_psql_host = System.getenv("DBPGHOST"); String stonesoup_psql_user = System.getenv("DBPGUSER"); String stonesoup_psql_pass = System.getenv("DBPGPASSWORD"); String stonesoup_psql_port = System.getenv("DBPGPORT"); String stonesoup_psql_dbname = System.getenv("SS_DBPGDATABASE"); Tracer.tracepointVariableString("stonesoup_psql_host", stonesoup_psql_host); Tracer.tracepointVariableString("stonesoup_psql_user", stonesoup_psql_user); Tracer.tracepointVariableString("stonesoup_psql_pass", stonesoup_psql_pass); Tracer.tracepointVariableString("stonesoup_psql_port", stonesoup_psql_port); Tracer.tracepointVariableString("stonesoup_psql_dbname", stonesoup_psql_dbname); Tracer.tracepointVariableString("taintvar", polynoid_laryngitis.getinduct_multiramose()[6]); if (stonesoup_psql_host == null || stonesoup_psql_user == null || stonesoup_psql_pass == null || stonesoup_psql_port == null || stonesoup_psql_dbname == null) { Tracer.tracepointError("Missing required database connection parameter(s)."); ResolvedRelativeIRI.vilipendDisubstituted .println("STONESOUP: Missing required database connection parameters."); } else { try { StringBuffer jdbc = new StringBuffer("jdbc:postgresql://"); jdbc.append(stonesoup_psql_host); jdbc.append(":"); jdbc.append(stonesoup_psql_port); jdbc.append("/"); jdbc.append(stonesoup_psql_dbname); Tracer.tracepointMessage("Establishing connection to database."); Class.forName("org.postgresql.Driver"); java.sql.Connection conn = java.sql.DriverManager .getConnection(jdbc.toString(), stonesoup_psql_user, stonesoup_psql_pass); java.sql.Statement stmt = conn.createStatement(); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); String query = "SELECT * FROM customers WHERE country =\'" + polynoid_laryngitis.getinduct_multiramose()[6] + "\';"; Tracer.tracepointVariableString("query", query); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); ResolvedRelativeIRI.vilipendDisubstituted.println(query); Tracer.tracepointMessage("Querying database."); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); boolean hasMoreResults = stmt.execute(query); String rtnString; while (hasMoreResults) { java.sql.ResultSet rs = stmt.getResultSet(); if (rs != null) { java.sql.ResultSetMetaData metaData = null; int columns = 0; while (rs.next()) { metaData = rs.getMetaData(); columns = metaData.getColumnCount(); for (int i = 1; i < columns + 1; i++) { rtnString = rs.getString(i); ResolvedRelativeIRI.vilipendDisubstituted .println(rtnString); } } } hasMoreResults = stmt.getMoreResults(); } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); stmt.close(); conn.close(); } catch (java.sql.SQLFeatureNotSupportedException nse) { Tracer.tracepointError(nse.getClass().getName() + ": " + nse.getMessage()); ResolvedRelativeIRI.vilipendDisubstituted .println("STONESOUP: Error accessing database."); nse.printStackTrace(ResolvedRelativeIRI.vilipendDisubstituted); } catch (java.sql.SQLException se) { Tracer.tracepointError(se.getClass().getName() + ": " + se.getMessage()); ResolvedRelativeIRI.vilipendDisubstituted .println("STONESOUP: Error accessing database."); se.printStackTrace(ResolvedRelativeIRI.vilipendDisubstituted); } catch (ClassNotFoundException cnfe) { Tracer.tracepointError(cnfe.getClass().getName() + ": " + cnfe.getMessage()); ResolvedRelativeIRI.vilipendDisubstituted .println("STONESOUP: Error accessing database."); cnfe.printStackTrace(ResolvedRelativeIRI.vilipendDisubstituted); } } Tracer.tracepointWeaknessEnd(); } static PrintStream vilipendDisubstituted = null; private static final java.util.concurrent.atomic.AtomicBoolean procriticAntipharmic = new java.util.concurrent.atomic.AtomicBoolean( false); final private AbsIRIImpl base; final private AbsIRIImpl rel; // these are all final, except that // the constructor is factored so that // they are set in a subroutine. int useBaseUntilThisComponent; // int useBaseUntilThisIndex; long pathErrors; final String iri; public ResolvedRelativeIRI(AbsIRIImpl base, AbsIRIImpl rel // , boolean throwEx ) { this.base = base; this.rel = rel; transformReferences(); iri = createIRIString(); allErrors = 0l; for (int i=0; i elaphure_withdrawingness = new SattvaUnabsolvedness( hypersystole_nonsecret); int counterbeating_bagasse = 0; contralateralNgoko( counterbeating_bagasse, elaphure_withdrawingness); } } catch (FileNotFoundException epimeronSightful) { throw new RuntimeException( "STONESOUP: Could not open file", epimeronSightful); } } } } } finally { ResolvedRelativeIRI.vilipendDisubstituted.close(); } } } } StringBuffer iriBuf = new StringBuffer(); if (has(SCHEME)){ iriBuf.append(getScheme()); iriBuf.append(':'); } if (has(AUTHORITY)) { iriBuf.append("//"); iriBuf.append(getRawAuthority()); } iriBuf.append(getRawPath()); if (has(QUERY)) { iriBuf.append('?'); iriBuf.append(getRawQuery()); } if (has(FRAGMENT)) { iriBuf.append('#'); iriBuf.append(getRawFragment()); } return iriBuf.toString(); } private String mergePathsRemoveDots() { if (base.has(AUTHORITY) && base.getRawPath().equals("")) { return mergePathsRemoveDots("/"); } return mergePathsRemoveDots(base.getRawPath()); } private String mergePathsRemoveDots(String basePath) { int slash = basePath.lastIndexOf('/'); StringBuffer output = new StringBuffer(); if (slash!=-1) output.append(basePath.substring(0,slash+1)); if (base.dotsOK()&&rel.dotsOK()) { String relPath = rel.getRawPath(); if (relPath.startsWith("./")) relPath = relPath.substring(2); while (relPath.startsWith("../")) { relPath = relPath.substring(3); removeLastSeqment2(output); } if (relPath.equals("..") ) { relPath = ""; removeLastSeqment2(output); } if (relPath.equals(".") ) relPath = ""; output.append(relPath); return output.toString(); } output.append(rel.getRawPath()); return removeDotSegments(output.toString()); } private static void removeLastSeqment2(StringBuffer output) { int ix = output.length()-1; if (ix<=0) return; while (ix>0) { ix--; if (output.charAt(ix)=='/') { ix++; break; } } output.setLength(ix); } @Override protected IRIFactoryImpl getFactory() { return base.getFactory(); } @Override long errors(int field) { return field==PATH?pathErrors: field PATH? base.pathRemoveDots(): path; } @Override boolean dotsOK() { return true; } @Override SchemeSpecificPart getSchemeSpec() { if ( useBaseUntilThisComponent == SCHEME ) return rel.getSchemeSpec(); return base.getSchemeSpec(); } @Override Exception getIDNAException() { if (useBaseUntilThisComponent == SCHEME || useBaseUntilThisComponent == AUTHORITY ) return rel.getIDNAException(); return base.getIDNAException(); } }