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.
slice-file
Advanced tools
stream file slices by line number indexes
var sf = require('slice-file');
var words = sf('/usr/share/dict/words');
words.slice(22398,22408).pipe(process.stdout);
beep
beep's
beeped
beeper
beeper's
beepers
beeping
beeps
beer
beer's
var sf = require('slice-file');
var xs = sf('/usr/share/dict/words');
xs.slice(-10).pipe(process.stdout);
élan's
émigré
émigré's
émigrés
épée
épée's
épées
étude
étude's
études
Like tail -f
, slice-file can stream updates after the initial slice.
var sf = require('slice-file');
var xs = sf('/var/mail/' + process.env.USER);
xs.follow(-10).pipe(process.stdout);
at first the previous 10 lines will render:
$ node example/mail.js
id A2181740063; Fri, 12 Apr 2013 03:08:30 -0700 (PDT)
Subject: beep boop
To: <substack@beep>
X-Mailer: mail (GNU Mailutils 2.2)
Message-Id: <20130412100830.A2181740063@beep>
Date: Fri, 12 Apr 2013 03:08:30 -0700 (PDT)
From: substack@beep
oh hello
then if a message is sent:
$ echo ahoy thar | mail -s 'oy' substack
we see more data from the file:
From substack@beep Fri Apr 12 03:09:13 2013
Return-Path: <substack@beep>
X-Original-To: substack@beep
Delivered-To: substack@beep
Received: by beep (Postfix, from userid 1000)
id 5E0C7740063; Fri, 12 Apr 2013 03:09:13 -0700 (PDT)
Subject: oy
To: <substack@beep>
X-Mailer: mail (GNU Mailutils 2.2)
Message-Id: <20130412100913.5E0C7740063@beep>
Date: Fri, 12 Apr 2013 03:09:13 -0700 (PDT)
From: substack@beep
ahoy thar
var sf = require('slice-file')
Create a slice-file instance xs
from a filename
and some options opts
.
These opts
are passed to fs.open()
:
opts.flags
- string flags to open the file with, default "r"
opts.mode
- mask to open the file with, default 0666
If you already have a file descriptor open you can pass opts.fd
to skip
calling fs.open()
.
Use opts.bufsize
to set how much data to read in each chunk. Default 4096.
Return a readable stream that emits each line between line numbers [i,j)
exactly like Array.prototype.slice()
. Each line data buffer includes a
trailing "\n"
except for the last line if there is no trailing newline before
the EOF.
Just like Array.prototype.slice()
, i
and j
may be negative.
If cb(err, lines)
is given, the lines will be buffered into lines
.
Return a readable stream of lines like xs.slice()
, but instead of ending when
the end of the file is reached, watch the file and stream new lines appended to
the end of the file.
This feature takes its name from tail -f
.
Close the underlying file descriptor, stop any streams, and stop any file watchers.
With npm do:
npm install slice-file
MIT
FAQs
stream file slices by line number indexes
The npm package slice-file receives a total of 168 weekly downloads. As such, slice-file popularity was classified as not popular.
We found that slice-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.