
Security News
AI Slop Is Polluting Bug Bounty Platforms with Fake Vulnerability Reports
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
archive-type
Advanced tools
The archive-type npm package is used to detect the type of archive file based on its buffer. It supports various archive formats such as zip, tar, rar, and more.
Detect Archive Type
This feature allows you to detect the type of an archive file by reading its buffer. The code sample reads a file into a buffer and then uses the archiveType function to determine the file type.
const archiveType = require('archive-type');
const fs = require('fs');
const buffer = fs.readFileSync('example.zip');
const type = archiveType(buffer);
console.log(type); // { ext: 'zip', mime: 'application/zip' }
The file-type package is used to detect the file type of a Buffer/Uint8Array/ArrayBuffer. It supports a wide range of file types, including archives, images, videos, and more. Compared to archive-type, file-type offers broader file type detection capabilities.
The detect-file-type package is another library for detecting file types from a buffer. It supports various file formats, including archives. While similar to archive-type, it also provides additional functionalities for detecting other file types.
Detect the archive type of a Buffer/Uint8Array
$ npm install --save archive-type
const archiveType = require('archive-type');
const readChunk = require('read-chunk');
const buffer = readChunk.sync('unicorn.zip', 0, 262);
archiveType(buffer);
//=> {ext: 'zip', mime: 'application/zip'}
Returns an Object
with:
ext
- One of the supported file typesmime
- The MIME typeOr null
when no match.
Type: Buffer
Uint8Array
It only needs the first 262 bytes.
7z
bz2
gz
rar
tar
zip
xz
gz
MIT © Kevin Mårtensson
FAQs
Detect the archive type of a Buffer/Uint8Array
The npm package archive-type receives a total of 1,604,838 weekly downloads. As such, archive-type popularity was classified as popular.
We found that archive-type 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.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.
Research
Security News
The Socket Research team investigates a malicious Python package disguised as a Discord error logger that executes remote commands and exfiltrates data via a covert C2 channel.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.