Coder Social home page Coder Social logo

Comments (4)

pauljt avatar pauljt commented on August 13, 2024

I implemented this but then commented it out because a) its not super just to have the one line, and b) unless you prettify the source, this causes explosions. I think the solution here, if we actually want to solve it is that we are going to have to have an option in the report format to store the scanned js files in their entirety

from scanjs.

pauljt avatar pauljt commented on August 13, 2024

PS it was a pretty hacky approach:

scanresults[rule.name].push({
rule : rule,
filename : filename,
line : node.loc.start.line,
col : node.loc.start.col,
node : node
//this adds a snippet based on lines. need to prettify first if going to use this.
//snippet:content.split('\n').splice(node.loc.start.line-1,node.loc.start.line+1).join('\n')

I think better would just be to store the whole js file, and the extract the snippets in the report viewer.

from scanjs.

pwnetrationguru avatar pwnetrationguru commented on August 13, 2024

That makes sense about needing the JS file to be prettified otherwise extracting a line number will be useless.

Also, I think that makes sense to store the JS files as part of our scan results. We will need to consider how to deal with users that run Scan.js in the console on a directory and then view the results in the client interface; e.g. do we duplicate all the files in the directory, etc.

from scanjs.

mozfreddyb avatar mozfreddyb commented on August 13, 2024

But if we prettify things before showing, people won't identify the code we show them as theirs. I'd say the snippet shouldn't be a whole line but just the current node (or 2-3 nodes up for context). We could also strip after X characters, to make sure we don't show too much.

If we expose a meaningful snippet, do we still need the full node in the results?

from scanjs.

Related Issues (20)

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.