diff --git a/java/ql/lib/semmle/code/java/frameworks/Jdbc.qll b/java/ql/lib/semmle/code/java/frameworks/Jdbc.qll index 2723f3f05f59..37be7dcf09a7 100644 --- a/java/ql/lib/semmle/code/java/frameworks/Jdbc.qll +++ b/java/ql/lib/semmle/code/java/frameworks/Jdbc.qll @@ -34,3 +34,19 @@ class ResultSetGetStringMethod extends Method { this.getReturnType() instanceof TypeString } } + +/** A method with the name `executeUpdate` declared in `java.sql.PreparedStatement`. */ +class PreparedStatementExecuteUpdateMethod extends Method { + PreparedStatementExecuteUpdateMethod() { + this.getDeclaringType() instanceof TypePreparedStatement and + this.hasName("executeUpdate") + } +} + +/** A method with the name `executeLargeUpdate` declared in `java.sql.PreparedStatement`. */ +class PreparedStatementExecuteLargeUpdateMethod extends Method { + PreparedStatementExecuteLargeUpdateMethod() { + this.getDeclaringType() instanceof TypePreparedStatement and + this.hasName("executeLargeUpdate") + } +} diff --git a/java/ql/lib/semmle/code/java/frameworks/MyBatis.qll b/java/ql/lib/semmle/code/java/frameworks/MyBatis.qll index 01c8b829de6b..c7fc09a33b4d 100644 --- a/java/ql/lib/semmle/code/java/frameworks/MyBatis.qll +++ b/java/ql/lib/semmle/code/java/frameworks/MyBatis.qll @@ -128,3 +128,114 @@ private class MyBatisProviderStep extends TaintTracking::AdditionalValueStep { ) } } + +/** + * A MyBatis Mapper XML file. + */ +class MyBatisMapperXmlFile extends XmlFile { + MyBatisMapperXmlFile() { + count(XmlElement e | e = this.getAChild()) = 1 and + this.getAChild().getName() = "mapper" + } +} + +/** + * An XML element in a `MyBatisMapperXMLFile`. + */ +class MyBatisMapperXmlElement extends XmlElement { + MyBatisMapperXmlElement() { this.getFile() instanceof MyBatisMapperXmlFile } + + /** + * Gets the value for this element, with leading and trailing whitespace trimmed. + */ + string getValue() { result = this.allCharactersString().trim() } + + /** + * Gets the reference type bound to MyBatis Mapper XML File. + */ + RefType getNamespaceRefType() { + result.getQualifiedName() = this.getAttribute("namespace").getValue() + } +} + +/** + * An MyBatis Mapper sql operation element. + */ +abstract class MyBatisMapperSqlOperation extends MyBatisMapperXmlElement { + /** + * Gets the value of the `id` attribute of MyBatis Mapper sql operation element. + */ + string getId() { result = this.getAttribute("id").getValue() } + + /** + * Gets the `` element in a `MyBatisMapperSqlOperation`. + */ + MyBatisMapperInclude getInclude() { result = this.getAChild*() } + + /** + * Gets the method bound to MyBatis Mapper XML File. + */ + Method getMapperMethod() { + result.getName() = this.getId() and + result.getDeclaringType() = this.getParent().(MyBatisMapperXmlElement).getNamespaceRefType() + } +} + +/** + * A `` element in a `MyBatisMapperSqlOperation`. + */ +class MyBatisMapperInsert extends MyBatisMapperSqlOperation { + MyBatisMapperInsert() { this.getName() = "insert" } +} + +/** + * A `` element in a `MyBatisMapperSqlOperation`. + */ +class MyBatisMapperUpdate extends MyBatisMapperSqlOperation { + MyBatisMapperUpdate() { this.getName() = "update" } +} + +/** + * A `` element in a `MyBatisMapperSqlOperation`. + */ +class MyBatisMapperDelete extends MyBatisMapperSqlOperation { + MyBatisMapperDelete() { this.getName() = "delete" } +} + +/** + * A `