Giter VIP home page Giter VIP logo

es6-crawler-detect's Introduction

Hi ๐Ÿ‘‹, I'm Jaafari El Housseine

A passionate software engineer from Morocco

  • ๐Ÿ”ญ Iโ€™m currently working at Caurus

  • ๐ŸŒฑ Iโ€™m currently learning Zig, Godot (GDScript)

  • ๐Ÿ’ฌ Ask me about What you like

  • ๐Ÿ“ซ How to reach me *https://jefferyhus.com

es6-crawler-detect's People

Contributors

abhirup-99 avatar dependabot[bot] avatar exx8 avatar gptt916 avatar itsjw avatar jefferyhus avatar joneslloyd avatar melbarch avatar mrschneepflug avatar swizec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

es6-crawler-detect's Issues

ReferenceError: Crawler is not defined

I have a project build with create-react-app and there's a SSR with express to identify crawlers and render the React site

evalmachine.<anonymous>:1
new Crawler(req)
^

ReferenceError: Crawler is not defined
    at evalmachine.<anonymous>:1:1
    at Script.runInThisContext (node:vm:129:12)
    at middleware (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\es6-crawler-detect\src\index.js:8:37)
    at Layer.handle [as handle_request] (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\express\lib\router\index.js:317:13)
    at C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\express\lib\router\index.js:275:10)
    at cors (C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\cors\lib\index.js:188:7)
    at C:\Users\Vinicius Tonelli\Documents\GitHub\nwsite\node_modules\cors\lib\index.js:224:17

This issue occurs on version 3.1.3

Currently I've downgrade to version 3.1.2

Versions

Node: 15.8.0 and 16.3.0 (both same results)
express: 4.17.1
es6-crawler-detect: 3.1.3
react: 16.14.0

Incorrect Crawler.getMatches

Screenshot from 2019-08-22 20 13 44

Bot agent is Facebot, but the output is acebot

I just run code like this in middleware

const agent = req.headers['user-agent'];

req.Crawler.isCrawler(agent);
const output = req.Crawler.getMatches();

console.log('userAgent: ', agent);
console.log('getMatches: ', output);

Edit:
Im using es6-crawler-detect@^3.0.0

Potential DDOS vulnerability?

Describe the bug
I see no code in the package that limits the user agent string length.
And I see you use regex massively, in a way that might be vulnerable to ReDos:
https://en.wikipedia.org/wiki/ReDoS
Please consider adding length limitation.
To Reproduce
One might send a 2mb of characters.

Expected behavior
any user agent above 4k in size should be rejected without regex matching.

Additional context
Some node mechanisms will usually defend against such vulnerability, but for some configuration, the package might still be vulnerable:
https://stackoverflow.com/questions/24167656/nodejs-max-header-size-in-http-request

isCrawler() doesnt detect Crawler

Describe the bug
I use this lib on Google Cloud Functions and somehow it doesn't detect any crawlers when I execute isCrawler().
I am not sure if I am doing something wrong but I followed the code in the docs.

At the end I used this:

if (CrawlerDetector.isCrawler(req.get("User-Agent"))) {
        console.log("Crawler detected!")
}

But without specifying the string, it didn't work.

How to print something on crawler hit with middleware?

I'd rather not manage crawler instances and manually log for all my APIs,

I was wondering if there were a way to do something like

app.use(middleware(req=>console.log("Got crawler request!", req));

Is there a way to do this? Or am I missing something?

I'm not sure what the current middleware does. It seems to just instantiate a Crawler instance: https://github.com/JefferyHus/es6-crawler-detect/blob/b75ebdb6a010d29848b0b7f8b242197a56f37fc2/src/index.js

Breaks if request does not have user agent

Describe the bug
Code Breaks if request does not have user agent

To Reproduce
send empty user agent

/app/joshpwa/node_modules/es6-crawler-detect/src/lib/crawler.js:103
agent = agent.replace(this.compiledExclusions, '');
^

TypeError: Cannot read property 'replace' of undefined
at Crawler.isCrawler (/app/joshpwa/node_modules/es6-crawler-detect/src/lib/crawler.js:103:19)

crawlers not detected when use auto-detect headers in node

Steps to reproduce the behavior:

  1. use example ECMAScript 6 (ES6)
  2. code to check: "check the current visitor's useragent" (CrawlerDetector.isCrawler())
  3. remove code: "check a user agent string"
  4. request example using curl
  5. it will return {}

Expected behavior
should return curl

it will work if
in file crawler.js on line 75 update header to header.toLowerCase() like this:
userAgent += this.httpHeaders[header.toLowerCase()] + ' ';

am i using the library in the wrong way? or this is a bug?

(Browser runtime) `ReferenceError: Buffer is not defined`

Describe the bug
During browser runtime this JavaScript error occurs: ReferenceError: Buffer is not defined

To Reproduce

  1. Import and use Crawler.isCrawler(...).
  2. Build with webpack.
  3. Run in latest Chrome.
    Note that a JavaScript error occurs:
ReferenceError: Buffer is not defined
    at e.exports.isCrawler (891.3bf818.js:1:1061)

Expected behavior
No runtime errors.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser [e.g. chrome, safari]: Chrome
  • Version [e.g. 22]: 108.0.5359.94

Does this support Googlebot?

Hello, does this work with Googlebot? I didn't see that in crawlers.js, also I'm not super familiar with some of this so just curious if it will work with google?

Thanks

Library cannot be imported in Node.js

Describe the bug
package.json has a main property referring to index.js, but there is no such file. This should be pointing to src/index.js or dist/main.bundle.js

To Reproduce
Steps to reproduce the behavior:

  1. npm install es6-crawler-detect
  2. Enter node interpreter
  3. require('es6-crawler-detect')
  4. See error

Expected behavior
Library should be loaded in NodeJS.

Is `projectdiscovery` supposed to be considered as a crawler?

Describe the bug
https://github.com/projectdiscovery/httpx

User agent is: httpx - Open-source project (github.com/projectdiscovery/httpx)

image

To Reproduce
Just pass that string into isCrawler('httpx - Open-source project (github.com/projectdiscovery/httpx)')

Expected behavior
Return true since it's a crawler?

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
Recently discovered this on my app. Skimming around, it seems to be a crawler? Though I might be wrong.

TS Support

I want use this, But I have a ts project, I know we can bypass this by declaring it but that way is not good for autocompletes ๐Ÿ˜…

If you want I can create Ts support for this package

TypeError: Cannot read property 'replace' of undefined at Crawler.isCrawler

Describe the bug
Not work as should with express.

To Reproduce
Steps to reproduce the behavior:

  1. Installed
  2. Set in express by instructions
  3. started server
  4. saw the error

Expected behavior
there no idea why it does not see user-agent from request.

Desktop (please complete the following information):

  • OS: windows 10 pro x64
  • Browser chrome latest (83)

Just FYI. I think its some very tiny bug, but it does not work as should. Check it please

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.