Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
file-type-stream
Advanced tools
Wrapper over file-type that makes using it with streams easier.
npm install --save file-type-stream
Requires Node v6+
fileTypeStream(callback)
See ./test directory for usage examples.
import fileTypeStream from 'file-type-stream'
import { PassThrough } from 'stream'
// ...
// s3Client = ....
// ...
const through = new PassThrough()
readStream.pipe(fileTypeStream((type) => {
// since transform streams buffer up to 16kb which
// is enough to detect the file type, we get
// the file type even through through hasn't been piped
// anywhere yet.
console.log('ext', type.ext)
console.log('mime', type.mime)
// E.g.:
// We can use that info to open a write stream on aws s3
// with the correct content type
client.upload({
ContentType: type.mime,
Bucket: 'some-bucket',
Key: 'some-key',
Body: through,
}, null, (err) => {
// Upload completed!
})
})).pipe(through)
The code above can be written a bit more intuitively with async/await:
import fileTypeStream from 'file-type-stream'
import { PassThrough } from 'stream'
// ...
// s3Client = ....
// ...
const upload = async (rs) => {
const Body = new PassThrough()
const { mime } = await new Promise(resolve => {
rs.pipe(fileTypeStream(resolve)).pipe(Body)
})
const response = client.upload({
Body,
ContentType: mime,
Bucket: 'some-bucket',
Key: 'some-key',
}).toPromise()
console.log(response)
}
FAQs
Wrapper over file-type that makes using it with streams easier.
The npm package file-type-stream receives a total of 104 weekly downloads. As such, file-type-stream popularity was classified as not popular.
We found that file-type-stream 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.