Skip to content

Commit 1189804

Browse files
committed
add mybatis demo
1 parent c9e82e2 commit 1189804

File tree

7 files changed

+81
-2
lines changed

7 files changed

+81
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
desc(
2+
title: 'checking []',
3+
type: audit
4+
)
5+
6+
// write your SyntaxFlow Rule, like:
7+
// DocumentBuilderFactory.newInstance()...parse(* #-> * as $source) as $sink; // find some call chain for parse
8+
// check $sink then 'find sink point' else 'No Found' // if not found sink, the rule will stop here and report error
9+
// alert $source // record $source
10+
11+
12+
// the template is generate by yak.ssa.syntaxflow command line
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.mycompany.myapp;
2+
3+
public interface UserMapper {
4+
User getUser(int id);
5+
int insertUser(User user);
6+
void updateUser(User user);
7+
void deleteUser(int id);
8+
}

java-mybatis-plus-mapper/sample/UserMapperWithAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import org.apache.ibatis.annotations.*;
33
import java.util.List;
44

5-
public interface UserMapper extends BaseMapper<User> {
5+
public interface UserMapperWithAnnotation extends BaseMapper<User> {
66
@Select("SELECT * FROM users WHERE age = #{age} AND name = #{name} AND email = #{email}")
77
List<User> selectUsersByMultipleFields(int age, String name, String email);
88

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE mapper
3+
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4+
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5+
6+
<mapper namespace="com.mycompany.myapp.UserMapper">
7+
<resultMap id="UserResult" type="com.mycompany.myapp.User">
8+
<id property="id" column="id" />
9+
<result property="name" column="name" />
10+
<result property="email" column="email" />
11+
</resultMap>
12+
13+
<select id="getUser" resultMap="UserResult">
14+
SELECT * FROM User WHERE id = #{id}
15+
</select>
16+
17+
<insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
18+
INSERT INTO User (name, email) VALUES (#{name}, #{email})
19+
</insert>
20+
21+
<update id="updateUser">
22+
UPDATE User SET name=#{name}, email=#{email} WHERE id=#{id}
23+
</update>
24+
25+
<delete id="deleteUser">
26+
DELETE FROM User WHERE id=#{id}
27+
</delete>
28+
</mapper>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
3+
"http://mybatis.org/dtd/mybatis-3-config.dtd">
4+
<configuration>
5+
<environments default="development">
6+
<environment id="development">
7+
<transactionManager type="JDBC"/>
8+
<dataSource type="POOLED">
9+
<property name="driver" value="com.mysql.jdbc.Driver"/>
10+
<property name="url" value="jdbc:mysql://localhost:3306/mydatabase"/>
11+
<property name="username" value="root"/>
12+
<property name="password" value="password"/>
13+
</dataSource>
14+
</environment>
15+
</environments>
16+
<mappers>
17+
<mapper resource="com/mycompany/myapp/BaseMapper.xml"/>
18+
</mappers>
19+
</configuration>

java-servlet/java-servlet-finding.sf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
desc(
22
title: 'checking [Servlet Web Parameters Finding]',
33
type: audit,
4-
lib: servlet-params
4+
lib: 'servlet-params'
55
)
66

77
/(do(Get|Post|Delete|Filter|\w+))|(service)/(*?{!have: this && opcode: param } as $req);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
desc(
2+
title: 'checking []',
3+
type: audit
4+
)
5+
6+
// Action.__ref__?{opcode: function}<getObject> as $actions;
7+
.inherits?{have: ActionSupport}<getObject>.set*?{opcode: function} as $setter;
8+
$setter<name><regexp("^set(\\w+)$", group=1)><strlower> as $name;
9+
$setter<getObject><name>?{!have: ':' && !have: " " && !have: '='} as $class;
10+
11+
12+
<fuzztag("{{class}}./(?i){{name}}/ as $entry")><eval>;

0 commit comments

Comments
 (0)