Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
get-source
Advanced tools
Platform-agnostic source code inspection, with sourcemaps support.
npm install get-source
getSource = require ('get-source')
file = getSource ('./scripts/index.min.js')
Will read the file synchronously (either via XHR or by filesystem API, depending on the environment) and return it's cached representation. Result will contain the following fields:
file.path // normalized file path
file.text // text contents
file.lines // array of lines
And the resolve
method:
file.resolve ({ line: 1, column: 8 }) // indexes here start from 1 (by widely accepted convention). Zero indexes are invalid.
It will look through the sourcemap chain, returning following:
{
line: <original line number>,
column: <original column number>,
sourceFile: <original source file object>,
sourceLine: <original source line text>
}
In that returned object, sourceFile
is the same kind of object that getSource
returns. So you can access its text
, lines
and path
fields to obtain the full information. And the sourceLine
is returned just for the convenience, as a shortcut.
nonsense = getSource ('/some/nonexistent/file')
nonsense.text // should be '' (so it's safe to access without checking)
nonsense.error // should be an Error object, representing an actual error thrown during reading/parsing
resolved = nonsense.resolve ({ line: 5, column: 0 })
resolved.error // should be an Error object, representing an actual error thrown during reading/parsing
resolved.sourceLine // empty string (so it's safe to access without checking)
FAQs
Fetch source-mapped sources. Peek by file, line, column. Node & browsers. Sync & async.
The npm package get-source receives a total of 1,160,684 weekly downloads. As such, get-source popularity was classified as popular.
We found that get-source demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.