Giter VIP home page Giter VIP logo

express-brute-sequelize's People

Contributors

crisward avatar jaertgeerts avatar maddy2get avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

express-brute-sequelize's Issues

sequelize deprecated Model.find

Hi,
Just a warning with "sequelize deprecated Model.find has been deprecated, please use Model.findOne instead".

In /node_modules/express-brute-sequelize/index.js, line 58 and 93 :
return this._table.find({
Replace by:
return this._table.findOne({

Thanks.

lib uses outdated sequelize version

Project uses sequelize v ~3.0.0 which has an SQL Injection via GeoJSON vulnerability according to nsp check

this issue was patched from sequelize version >=3.23.6

Unnecessary SQLite Dependency

Unused SQLite dependency in source. It is not listed as a dependency in package.json. However when using the module it will throw an error.

Past-expiry records cause runtime errors in express-brute 1.0.1

This is the offending code in this library, comment is mine

  get:(key, callback) ->
    _id = @options.prefix+key
    @_table.find(where:{_id:_id})
    .then (doc) =>
      ###
       `destroy` will return 1 from the promise when the record existed
      ###
      return @_table.destroy({where:{"_id":_id}}) if doc && new Date(doc.expires).getTime() < new Date().getTime()
      return Promise.resolve(count:doc.count,lastRequest:new Date(doc.lastRequest),firstRequest:new Date(doc.firstRequest)) if doc
      Promise.resolve()
    .then (data)->
      data = undefined if !data
      typeof callback == 'function' && callback(null,data)
      return null
    .catch (err) ->
      typeof callback == 'function' && callback(err)
      return null

When doc.expires is earlier than the current time, there's a call to destroy. If the record exists in the database, Sequelize resolved the promise with a 1.

That means the callback is getting called with 1.

In the express-brute library, a truthiness check is run against the return value of get to determine whether or not to update the lastRequest, etc.

This truthiness check assumes it's getting an object with the expected brute-record properties. Line 100 thus calls getTime on undefined and everything freaks out.

This is a one-line fix, I'll open a PR shortly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.