Advertisement
Guest User

leaky objects Revealing Module Pattern

a guest
Aug 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Probably already exists but I want something that uses revealing Module Pattern javascript convention to find 'leaky' objects which are giving users access to commands that they shouldn't be able to use
  2.  
  3. I dunno but
  4.  
  5. imagine
  6.  
  7. userObject.js
  8. ```
  9. function User(username,password) {
  10.  
  11. this.username:username,
  12. this.password: password
  13. }
  14.  
  15. module.exports = User
  16.  
  17. ```
  18.  
  19. userNicky.js
  20. ```
  21. //let Nick =new User(Nicky,12321332) creates the user
  22.  
  23. let User = require('./userObject.js')
  24.  
  25. Nick = {
  26. username:Nicky
  27. password:12321332
  28. }
  29.  
  30. module.exports=Nick //should only export Nick.username
  31. ```
  32.  
  33. window.js
  34. ```
  35. let nickname = require('./userNicky')
  36.  
  37. console.log(`this user is called ${nickname.username}`)
  38.  
  39. ```
  40.  
  41. but this would still allow you to see the password property of the nickname object
  42.  
  43. so console.log(nickname.password) would let us see the password of username
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement