May 18, 2021 WeChat Mini Program Development Document
Interface forensics refers to the background interface (including self-built background interface and cloud functions) when called, the interface call needs to be permission verification, otherwise it is easy to oversances behavior. For example, if the product deletes the interface, the background should verify the caller's identity information (such as openid, ip address, developer-customized login information, etc.) when receiving the request, and only the specified user can delete it by verifying.
Overseering is usually divided into parallel and vertical overspending:
Development recommendations:
function actionDelete(){
$item_id = $_POST["item_id"];
$openid = $_POST["openid"];
$ip = $_SERVER['REMOTE_ADDR'];
$user_role = $_SESSION["user_role"];
if ($openid === "xxx" &&
$ip === "192.168.0.101" &&
$user_role === "admin") {
// 进行删除操作
// ...
return 0;
} else {
// 记录非法请求
// ...
return -1;
}
}
Cloud function interface authentication
exports.main = async (event, context) => {
const { OPENID, APPID, UNIONID } = cloud.getWXContext();
if (OPENID === "xxx") {
// 进行删除操作
// ...
} else {
// 记录非法请求
// ...
}
}
Development recommendations:
Sensitive information refers to data that, in the event of disclosure, may be detrimental to the developer's business, partners, and users, including, but not limited to, account appsecret, privileged account information, background encryption keys, login account passwords, user ID numbers, mobile phone numbers, bank card numbers, etc.
Development recommendations:
Sensitive information type | Show samples |
---|---|
Name | The name has only two words, code the first word, such as: three. More than two words, only retain the first and last, the rest are coded, such as: Wang, four, Europe, five |
Id | Only the first and last places are displayed, such as: 3 |
Mobile phone number | After removing the international code of the mobile phone, when the number of mobile phone numbers is not less than 10 digits, only the first three and last two digits are displayed, such as: 156, 77. W hen the number of phone numbers is less than 10 digits, only the first two and the last two are displayed, such as: 12 x 89. The country code can be fully displayed. |
Bank card | Only the last 4 bits are displayed, e.g. 1234 |