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.
nodejs 下文件相关封装
安装
npm i qiao-file
使用
// cjs
const { isExists } = require('qiao-file');
// mjs
import { isExists } from 'qiao-file';
获取文件的后缀
const res = extname(filePath);
判断文件或者文件夹是否存在
const res = await isExists(fpath);
判断文件路径是否为文件夹
const res = await isDir(fpath);
复制文件或文件夹
const res = await cp(src, dest);
移动文件或文件夹
const res = await mv(src, dest);
删除文件或文件夹
const res = await rm(path);
创建文件夹
const res = await mkdir(dirpath);
读取文件夹内容
['path', ...]
const res = await readdir(dirpath);
列出文件夹下所有的文件和文件夹路径
{
files: [
{
name: 'index.js',
path: '/path/to/index.js',
},
...
],
folders: [
{
name: '1',
path: '/path/to/1',
},
...
],
}
const res = await lsdir(dirpath);
列出文件夹下所有的文件和文件夹信息,以树的方式
dirpath
ignores
return
[
{
children: [],
name: 'filename',
path: '',
},
];
const dirpath = 'xx';
const ignores = ['node_modules', 'is-'];
const res = await lstree(dirpath, ignores);
读取文件内容
const res = await readFile(filePath);
按行读取文件
readFileLineByLine(filePath, onLine, onClose);
写文件
const res = await writeFile(filePath, content);
FAQs
nodejs file tool
The npm package qiao-file receives a total of 58 weekly downloads. As such, qiao-file popularity was classified as not popular.
We found that qiao-file demonstrated a healthy version release cadence and project activity because the last version was released less than 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.