我遇到一个问题,如果通过ejs将数据发送到函数,则很容易在页面源代码中看到它。这会导致安全风险吗?
例如。代码
<a onclick="editDetail('<%=JSON.stringify(data[i])%>')">Edit</a>
页面来源:
<a href="#" data-toggle="modal" data-target="#exampleModalLong" onclick="editUser('{"type":"customer","notification_status":"1","wallet_balance":"500","block_status":"0","_id":"5b1fc76bf04810496b7cf149","name":"Omeesh","email":"omeesh@relinns.com","contact":78371724568,"password":"$2a$10$afc1Ei.z0PZ2sWsX7Mbwd.EYliwVa48cIFuLqwcupnIdvEfhy79AS","device_token":"cmtl5S48n6w:APA91bFlX71jrg2xKcZym3upHIvY8uGraTbXI9clBKh_Cu2LydPodY2TuPfVaFXMNiWF5ZeDF7TfgV6Svyz6BY5xDJ7iWXgwWOT7aHZe6NwutKsdOJJZO1WGSKC7y5V0UGTiLFp-kIPX","platform":"1","__v":0,"socket":"Zh3Vb46deerhDGu4AAAn","notification_id":"cmtl5S48n6w:APA91bFlX71jrg2xKcZym3upHIvY8uGraTbXI9clBKh_Cu2LydPodY2TuPfVaFXMNiWF5ZeDF7TfgV6Svyz6BY5xDJ7iWXgwWOT7aHZe6NwutKsdOJJZO1WGSKC7y5V0UGTiLFp-kIPX"}');">Edit</a>
我在这里可以做什么,以便所有这些数据都不可见。还是可以,它只能像这样吗?
答案 0 :(得分:0)
为什么要渲染完整的对象而不是所需的值。假设如果您只需要ID,则应该使用
显示ID<%=JSON.stringify(data[i].id)%>
或
<%=JSON.stringify(data[i].customer)%>