use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestServerReadOnly method update_readonly.
@Test()
public void update_readonly() {
FusekiTest.exec404(() -> {
UpdateRequest update = UpdateFactory.create("INSERT DATA {}");
UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, serviceUpdate());
proc.execute();
});
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_injection_14.
@Test
public void test_param_string_injection_14() {
// This is a variant on placing a variable bound to a literal inside a
// literal resulting in an injection, we now escape ' so prevent this
String str = "PREFIX : <http://example/>\nINSERT DATA { <s> <p> 'some text ?var other text' }";
ParameterizedSparqlString pss = new ParameterizedSparqlString(str);
pss.setLiteral("var", "' . } ; DROP ALL ; INSERT DATA { <s> <p> <o> }#");
UpdateRequest updates = pss.asUpdate();
Assert.assertEquals(1, updates.getOperations().size());
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_injection_08.
@Test(expected = ARQException.class)
public void test_param_string_injection_08() {
// This injection attempt results in an invalid SPARQL update because
// you end up with a double quoted literal inside a single quoted
// literal
String str = "PREFIX : <http://example/>\nINSERT DATA { <s> <p> '?var' }";
ParameterizedSparqlString pss = new ParameterizedSparqlString(str);
pss.setLiteral("var", "' . } ; DROP ALL ; INSERT DATA { <s> <p> <o> }#");
UpdateRequest updates = pss.asUpdate();
Assert.fail("Attempt to do SPARQL injection should result in an exception");
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_injection_03.
@Test
public void test_param_string_injection_03() {
// This injection attempt results in a valid update but a failed
// injection
String str = "PREFIX : <http://example/>\nINSERT DATA { <s> <p> ?var2 . }";
ParameterizedSparqlString pss = new ParameterizedSparqlString(str);
pss.setLiteral("var2", "hello\" } ; DROP ALL ; INSERT DATA { <s> <p> <goodbye>");
UpdateRequest updates = pss.asUpdate();
Assert.assertEquals(1, updates.getOperations().size());
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_injection_13.
@Test
public void test_param_string_injection_13() {
// This is a variant on placing a variable bound to a literal inside a
// literal resulting in an injection, we now escape ' so prevent this
String str = "PREFIX : <http://example/>\nINSERT DATA { <s> <p> ' ?var ' }";
ParameterizedSparqlString pss = new ParameterizedSparqlString(str);
pss.setLiteral("var", "' . } ; DROP ALL ; INSERT DATA { <s> <p> <o> }#");
UpdateRequest updates = pss.asUpdate();
Assert.assertEquals(1, updates.getOperations().size());
}
Aggregations