|
| 1 | +// mock 接口数据 |
| 2 | +export const mockService = { |
| 3 | + // 代码扫描结果 |
| 4 | + getScaningProblem() { |
| 5 | + return [ |
| 6 | + { |
| 7 | + annotation: {}, |
| 8 | + checkSuite: { |
| 9 | + checkRuns: [ |
| 10 | + { |
| 11 | + annotations: [ |
| 12 | + { |
| 13 | + bugId: '172261039', |
| 14 | + bugType: 'BE8034', |
| 15 | + bugTypeName: 'Hard code access key', |
| 16 | + checkRunId: 32814683, |
| 17 | + details: |
| 18 | + '源文件发现硬编码明文账密: "ACCESSSECRET" : "XuixzcoxU56iSrNbhm8Wz2WH1DkjmO"', |
| 19 | + endCol: 0, |
| 20 | + endLine: 22, |
| 21 | + feedBackStatus: 'Init', |
| 22 | + feedBackUser: { |
| 23 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/249871.80x80.jpg', |
| 24 | + email: 'yongda.cyd@antgroup.com', |
| 25 | + externUid: '249871', |
| 26 | + id: 48448, |
| 27 | + name: '鲁猫', |
| 28 | + state: 'active', |
| 29 | + username: 'yongda.cyd', |
| 30 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/249871', |
| 31 | + }, |
| 32 | + feedBackUserId: 48448, |
| 33 | + id: 18402298, |
| 34 | + level: 'Failure', |
| 35 | + message: |
| 36 | + '源文件发现硬编码明文账密: "<span style="color:red">ACCESSSECRET</span>" : "<span style="color:red">XuixzcoxU56iSrNbhm8Wz2WH1DkjmO</span>"<br/>不符合《[蚂蚁金服密钥口令安全管理规范](https://developer.alipay.com/processfile/devKb/sggf2g)》', |
| 37 | + path: 'aaa/package.json', |
| 38 | + startCol: 0, |
| 39 | + startLine: 22, |
| 40 | + title: '硬编码Access Key', |
| 41 | + }, |
| 42 | + { |
| 43 | + bugId: '172261040', |
| 44 | + bugType: 'BE8034', |
| 45 | + bugTypeName: 'Hard code access key', |
| 46 | + checkRunId: 32814683, |
| 47 | + details: |
| 48 | + '源文件发现硬编码明文账密: "ACCESSSECRET" : "XuixzcoxU56iSrNbhm8Wz2WH1DkjmO"', |
| 49 | + endCol: 0, |
| 50 | + endLine: 26, |
| 51 | + feedBackStatus: 'Init', |
| 52 | + feedBackUser: { |
| 53 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/249871.80x80.jpg', |
| 54 | + email: 'yongda.cyd@antgroup.com', |
| 55 | + externUid: '249871', |
| 56 | + id: 48448, |
| 57 | + name: '鲁猫', |
| 58 | + state: 'active', |
| 59 | + username: 'yongda.cyd', |
| 60 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/249871', |
| 61 | + }, |
| 62 | + feedBackUserId: 48448, |
| 63 | + id: 18402299, |
| 64 | + level: 'Failure', |
| 65 | + message: |
| 66 | + '源文件发现硬编码明文账密: "<span style="color:red">ACCESSSECRET</span>" : "<span style="color:red">XuixzcoxU56iSrNbhm8Wz2WH1DkjmO</span>"<br/>不符合《[蚂蚁金服密钥口令安全管理规范](https://developer.alipay.com/processfile/devKb/sggf2g)》', |
| 67 | + path: 'src/config/passport.ts', |
| 68 | + startCol: 0, |
| 69 | + startLine: 26, |
| 70 | + title: '硬编码Access Key', |
| 71 | + }, |
| 72 | + { |
| 73 | + bugId: '172261041', |
| 74 | + bugType: 'BE8034', |
| 75 | + bugTypeName: 'Hard code access key', |
| 76 | + checkRunId: 32814683, |
| 77 | + details: |
| 78 | + '源文件发现硬编码明文账密: "ACCESSSECRET" : "XuixzcoxU56iSrNbhm8Wz2WH1DkjmO"', |
| 79 | + endCol: 0, |
| 80 | + endLine: 22, |
| 81 | + feedBackStatus: 'Init', |
| 82 | + feedBackUser: { |
| 83 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/249871.80x80.jpg', |
| 84 | + email: 'yongda.cyd@antgroup.com', |
| 85 | + externUid: '249871', |
| 86 | + id: 48448, |
| 87 | + name: '鲁猫', |
| 88 | + state: 'active', |
| 89 | + username: 'yongda.cyd', |
| 90 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/249871', |
| 91 | + }, |
| 92 | + feedBackUserId: 48448, |
| 93 | + id: 18402300, |
| 94 | + level: 'Failure', |
| 95 | + message: |
| 96 | + '源文件发现硬编码明文账密: "<span style="color:red">ACCESSSECRET</span>" : "<span style="color:red">XuixzcoxU56iSrNbhm8Wz2WH1DkjmO</span>"<br/>不符合《[蚂蚁金服密钥口令安全管理规范](https://developer.alipay.com/processfile/devKb/sggf2g)》', |
| 97 | + path: 'test0315.java', |
| 98 | + startCol: 0, |
| 99 | + startLine: 22, |
| 100 | + title: '硬编码Access Key', |
| 101 | + }, |
| 102 | + { |
| 103 | + bugId: '172261042', |
| 104 | + bugType: 'BE8034', |
| 105 | + bugTypeName: 'Hard code access key', |
| 106 | + checkRunId: 32814683, |
| 107 | + details: |
| 108 | + '源文件发现硬编码明文账密: "ACCESSSECRET" : "fFc3rGhaDMgbHtN6EGLirC4DRWWmhg"', |
| 109 | + endCol: 0, |
| 110 | + endLine: 21, |
| 111 | + feedBackStatus: 'Init', |
| 112 | + feedBackUser: { |
| 113 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/249871.80x80.jpg', |
| 114 | + email: 'yongda.cyd@antgroup.com', |
| 115 | + externUid: '249871', |
| 116 | + id: 48448, |
| 117 | + name: '鲁猫', |
| 118 | + state: 'active', |
| 119 | + username: 'yongda.cyd', |
| 120 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/249871', |
| 121 | + }, |
| 122 | + feedBackUserId: 48448, |
| 123 | + id: 18402301, |
| 124 | + level: 'Failure', |
| 125 | + message: |
| 126 | + '源文件发现硬编码明文账密: "<span style="color:red">ACCESSSECRET</span>" : "<span style="color:red">fFc3rGhaDMgbHtN6EGLirC4DRWWmhg</span>"<br/>不符合《[蚂蚁金服密钥口令安全管理规范](https://developer.alipay.com/processfile/devKb/sggf2g)》', |
| 127 | + path: 'test0317.java', |
| 128 | + startCol: 0, |
| 129 | + startLine: 21, |
| 130 | + title: '硬编码Access Key', |
| 131 | + }, |
| 132 | + { |
| 133 | + bugId: '172261044', |
| 134 | + bugType: 'BE8034', |
| 135 | + bugTypeName: 'Hard code access key', |
| 136 | + checkRunId: 32814683, |
| 137 | + details: |
| 138 | + '源文件发现硬编码明文账密: "ACCESSSECRET" : "XuixzcoxU56iSrNbhm8Wz2WH1DkjmO"', |
| 139 | + endCol: 0, |
| 140 | + endLine: 19, |
| 141 | + feedBackStatus: 'Init', |
| 142 | + feedBackUser: { |
| 143 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/249871.80x80.jpg', |
| 144 | + email: 'yongda.cyd@antgroup.com', |
| 145 | + externUid: '249871', |
| 146 | + id: 48448, |
| 147 | + name: '鲁猫', |
| 148 | + state: 'active', |
| 149 | + username: 'yongda.cyd', |
| 150 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/249871', |
| 151 | + }, |
| 152 | + feedBackUserId: 48448, |
| 153 | + id: 18402302, |
| 154 | + level: 'Failure', |
| 155 | + message: |
| 156 | + '源文件发现硬编码明文账密: "<span style="color:red">ACCESSSECRET</span>" : "<span style="color:red">XuixzcoxU56iSrNbhm8Wz2WH1DkjmO</span>"<br/>不符合《[蚂蚁金服密钥口令安全管理规范](https://developer.alipay.com/processfile/devKb/sggf2g)》', |
| 157 | + path: 'bugs.java', |
| 158 | + startCol: 0, |
| 159 | + startLine: 19, |
| 160 | + title: '硬编码Access Key', |
| 161 | + }, |
| 162 | + ], |
| 163 | + completedAt: '2021-09-14T18:03:39+0800', |
| 164 | + context: |
| 165 | + '\n<span style="color: rgb(251, 103, 58);">🔴 失败</span>: 5 <span style="color: rgb(250, 140, 22);"> 🟠️ 警告</span>: 0 <span style="color: rgb(250, 173, 20);"> ⚪ 通知</span>: 0\n\n已扫描项:\n- 硬编码Access Key <span style="color: green;">完成</span>, 发现5个失败级别风险 \n\n', |
| 166 | + createdAt: '2021-09-14T18:02:51+0800', |
| 167 | + detailUrl: '', |
| 168 | + externalId: '186602538', |
| 169 | + id: 32814683, |
| 170 | + startedAt: '2021-09-14T18:02:51+0800', |
| 171 | + status: 'fail', |
| 172 | + suiteId: 32348046, |
| 173 | + summary: '扫描任务执行完成,发现 5 个结果', |
| 174 | + title: 'AntCode CR 增量扫描', |
| 175 | + updatedAt: '2021-09-14T18:03:40+0800', |
| 176 | + conclusion: '', |
| 177 | + }, |
| 178 | + ], |
| 179 | + service: { |
| 180 | + accessLevel: 20, |
| 181 | + active: true, |
| 182 | + avatarUrl: '/uploads/service/avatar/5/27973167.jpg', |
| 183 | + checks: true, |
| 184 | + checksDependOn: null, |
| 185 | + description: |
| 186 | + '提供自动化代码扫描检测方案,比如蚂蚁军规、代码明文账密等,并支持用户自定义等。', |
| 187 | + helpUrl: null, |
| 188 | + homepage: 'https://codeinsightapi.alipay.com', |
| 189 | + id: 5, |
| 190 | + name: 'CodeInsight', |
| 191 | + nameShow: '代码规范扫描', |
| 192 | + rerunForRun: false, |
| 193 | + rerunForSuite: true, |
| 194 | + serviceType: 'BASICQUALITY', |
| 195 | + stuck: false, |
| 196 | + }, |
| 197 | + }, |
| 198 | + }, |
| 199 | + ]; |
| 200 | + }, |
| 201 | + getOneComment() { |
| 202 | + return { |
| 203 | + author: { |
| 204 | + avatarUrl: 'https://work.antfinancial-corp.com/photo/80222.80x80.jpg', |
| 205 | + email: 'xinglong.wangwxl@antgroup.com', |
| 206 | + externUid: '80222', |
| 207 | + id: 15168, |
| 208 | + name: '蛋总', |
| 209 | + state: 'active', |
| 210 | + username: 'xinglong.wangwxl', |
| 211 | + webUrl: 'https://work.antfinancial-corp.com/nwpipe/u/80222', |
| 212 | + }, |
| 213 | + commitId: null, |
| 214 | + createdAt: '2021-11-04T15:08:12+0800', |
| 215 | + discussionId: null, |
| 216 | + id: 400003, |
| 217 | + isAward: false, |
| 218 | + labels: [], |
| 219 | + lineCode: 'c17950853d6b9677e9822cf07f2616db7ca02797_388_384', |
| 220 | + lineType: 'old', |
| 221 | + note: '111 \n\n\n\n', |
| 222 | + noteableId: 4200244, |
| 223 | + noteableType: 'ReviewComment', |
| 224 | + outdated: false, |
| 225 | + path: 'src/controllers/user.ts', |
| 226 | + resolvedAt: null, |
| 227 | + resolvedBy: null, |
| 228 | + stDiff: { |
| 229 | + aMode: '100644', |
| 230 | + addLineNum: 265, |
| 231 | + bMode: '100644', |
| 232 | + binaryFile: false, |
| 233 | + charsetName: 'UTF-8', |
| 234 | + commitSha: 'ab32441adfd6c3c381457717a42f19a7fdd6d59b', |
| 235 | + compareDiffId: 31918, |
| 236 | + delLineNum: 265, |
| 237 | + deletedFile: false, |
| 238 | + diff: '@@ -327,62 +327,62 @@ export const getForgot = (req: Request, res: Response) => {\n * Create a random token, then the send user an email with a reset link.\n */\n export const postForgot = async (req: Request, res: Response, next: NextFunction) => {\n- await check("email", "Please enter a valid email address.").isEmail().run(req);\n- // eslint-disable-next-line @typescript-eslint/camelcase\n- await sanitize("email").normalizeEmail({ gmail_remove_dots: false }).run(req);\n-\n- const errors = validationResult(req);\n-\n- if (!errors.isEmpty()) {\n- req.flash("errors", errors.array());\n- return res.redirect("/forgot");\n- }\n-\n- async.waterfall([\n- function createRandomToken(done: Function) {\n- crypto.randomBytes(16, (err, buf) => {\n- const token = buf.toString("hex");\n- done(err, token);\n- });\n- },\n- function setRandomToken(token: AuthToken, done: Function) {\n- User.findOne({ email: req.body.email }, (err, user: any) => {\n- if (err) { return done(err); }\n- if (!user) {\n- req.flash("errors", { msg: "Account with that email address does not exist." });\n- return res.redirect("/forgot");\n- }\n- user.passwordResetToken = token;\n- user.passwordResetExpires = Date.now() + 3600000; // 1 hour\n- user.save((err: WriteError) => {\n- done(err, token, user);\n- });\n- });\n- },\n- function sendForgotPasswordEmail(token: AuthToken, user: UserDocument, done: Function) {\n- const transporter = nodemailer.createTransport({\n- service: "SendGrid",\n- auth: {\n- user: process.env.SENDGRID_USER,\n- pass: process.env.SENDGRID_PASSWORD\n- }\n- });\n- const mailOptions = {\n- to: user.email,\n- from: "hackathon@starter.com",\n- subject: "Reset your password on Hackathon Starter",\n- text: `You are receiving this email because you (or someone else) have requested the reset of the password for your account.\\n\\n\n+ await check("email", "Please enter a valid email address.").isEmail().run(req);\n+ // eslint-disable-next-line @typescript-eslint/camelcase\n+ await sanitize("email").normalizeEmail({ gmail_remove_dots: false }).run(req);\n+\n+ const errors = validationResult(req);\n+\n+ if (!errors.isEmpty()) {\n+ req.flash("errors", errors.array());\n+ return res.redirect("/forgot");\n+ }\n+\n+ async.waterfall([\n+ function createRandomToken(done: Function) {\n+ crypto.randomBytes(16, (err, buf) => {\n+ const token = buf.toString("hex");\n+ done(err, token);\n+ });\n+ },\n+ function setRandomToken(token: AuthToken, done: Function) {\n+ User.findOne({ email: req.body.email }, (err, user: any) => {\n+ if (err) { return done(err); }\n+ if (!user) {\n+ req.flash("errors", { msg: "Account with that email address does not exist." });\n+ return res.redirect("/forgot");\n+ }\n+ user.passwordResetToken = token;\n+ user.passwordResetExpires = Date.now() + 3600000; // 1 hour\n+ user.save((err: WriteError) => {\n+ done(err, token, user);\n+ });\n+ });\n+ },\n+ function sendForgotPasswordEmail(token: AuthToken, user: UserDocument, done: Function) {\n+ const transporter = nodemailer.createTransport({\n+ service: "SendGrid",\n+ auth: {\n+ user: process.env.SENDGRID_USER,\n+ pass: process.env.SENDGRID_PASSWORD\n+ }\n+ });\n+ const mailOptions = {\n+ to: user.email,\n+ from: "hackathon@starter.com",\n+ subject: "Reset your password on Hackathon Starter",\n+ text: `You are receiving this email because you (or someone else) have requested the reset of the password for your account.\\n\\n\n Please click on the following link, or paste this into your browser to complete the process:\\n\\n\n http://${req.headers.host}/reset/${token}\\n\\n\n If you did not request this, please ignore this email and your password will remain unchanged.\\n`\n- };\n- transporter.sendMail(mailOptions, (err) => {\n- req.flash("info", { msg: `An e-mail has been sent to ${user.email} with further instructions.` });\n- done(err);\n- });\n- }\n- ], (err) => {\n- if (err) { return next(err); }\n- res.redirect("/forgot");\n- });\n+ };\n+ transporter.sendMail(mailOptions, (err) => {\n+ req.flash("info", { msg: `An e-mail has been sent to ${user.email} with further instructions.` });\n+ done(err);\n+ });\n+ }\n+ ], (err) => {\n+ if (err) { return next(err); }\n+ res.redirect("/forgot");\n+ });\n };\n', |
| 239 | + id: 1088, |
| 240 | + newFile: false, |
| 241 | + newPath: 'src/controllers/user.ts', |
| 242 | + oldPath: 'src/controllers/user.ts', |
| 243 | + renamedFile: false, |
| 244 | + tooLarge: false, |
| 245 | + }, |
| 246 | + state: 'opened', |
| 247 | + system: false, |
| 248 | + type: 'Problem', |
| 249 | + updatedAt: '2021-11-04T15:08:12+0800', |
| 250 | + noteId: 400003, |
| 251 | + }; |
| 252 | + }, |
| 253 | +}; |
0 commit comments