Comments (4)
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.
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.
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.
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)
- Bug: "new foo('arg')" matches "new foo()" which results in false positives HOT 1
- Create rule with data type of argument HOT 6
- False positives for literal assignments HOT 2
- Need a better structure for JSON reports in the cmdline version. HOT 2
- JS parsing and AST generation should be easier to switch out. HOT 4
- Support for longer rules (e.g. foo.bar.baz) HOT 1
- split scanjs into separate repos for nodejs, web and just the scanning HOT 3
- Investigate and complete automated deployment gh-page updates through Travis-CI HOT 1
- experiments tab is broken
- show parse errors on experiment tab
- "use strict"; mode wherever possible
- package missing from npm registry HOT 7
- [false-positive] input-manage permission rule HOT 5
- Rule Parser Rewrite (Redux) HOT 1
- Incorrect line number reported in output json file HOT 2
- [Feature Request] Export results to HTML
- checklist: add comment/hide/delete button in output view
- Sources Rules a='b'; HOT 2
- Rule for values inside object? HOT 3
- Wiki changes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scanjs.