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.
file-lane模块用于文件转换,可实现文件1对1的转换,也可实现1对多、多对1的文件转换。
安装
npm i file-lane
快速上手
const { FileLane } = require('file-lane')
const { UxLoader } = require('aiot-toolkit/aiotpack')
const Path = require('path')
const projectPath = Path.join(__dirname, '../testProject')
// 定义项目转换的配置参数,output和module为必要配置内容
const projectConfig = {
// output指定转换后项目的存储位置
get output() {
const name = Path.basename(projectPath)
const result = `../.temp_${name}`
return result
},
// 转换过程中使用的转换模块配置
module: {
rules: [
{
test: [/.+\.ux$/],
exclude: [/app\.ux/],
loader: [UxLoader]
}
]
}
}
// 开始执行文件转换
new FileLane(projectConfig).start()
// 开启watch模式
// new FileLane(projectConfig).start({ watch: true })
描述: 输出目录
参数类型: string
示例:
'temp_project'
描述: 文件转换规则集
参数类型: { rules: IRule[] } // IRule:转换规则
interface IRule {
// 配置文件
test: MatchType
// 文件的 Loader,从前向后依次执行,前一个 loader 结果做为后一个 loader 的入参
loader: ILoaderClass[]
exclude?: MatchType
include?: MatchType
}
示例:
{
rules: [
{
test: [/.+\.ux$/],
exclude: [/app\.ux/],
loader: [UxLoader]
}
]
}
描述: 文件收集器,输入文件路径,返回待合并的文件路径,常用于多转1,默认值为直接使用源文件
参数类型:
(file: string) => string[]
示例:
// src/a.hml -->[src/a.hml, src/a.js, src/a.css]
(file: string) => {
const fileList = [file]
const { dir, name, ext } = path.parse(file)
if (ext === '.hml') {
['.js', '.css'].map((item) => {
const collectFile = path.join(dir, `${name}${item}`)
// 若路径真实存在,则push到文件列表中
if (fs.existsSync(collectFile)) {
fileList.push(collectFile)
}
})
return fileList
}
}
描述: 指定文件范围
参数类型:
OneMatchType | OneMatchType[]
示例:
// 匹配包含有src字符串的文件
include = ['src']
描述: 需排除的文件范围
参数类型:
OneMatchType | OneMatchType[]
示例:
// 排除路径中包含有node_modules字符串的文件
exclude = [/node_modules/]
描述: 插件,在每个文件转换完成前后,所有文件转换完成前后,在打包完成前后会触发
参数类型:
IPlugin[]
示例:
描述: 前置工作,所有文件转换前的工作
参数类型:
PreWork[]
示例:
preWorks = [validateManifest]
const validateManifest: PreWork<IJavascriptCompileOption> = async (context) => {
// 校验manifest.json文件的内容
}
描述: 后续工作,所有文件转换后的工作
参数类型:
FollowWoker<O>[]
示例:
followWorks = [
{
worker: toRpk,
workerDescribe: 'follow work'
}
]
const toRpk: FollowWork<IJavascriptCompileOption> = async (context, config, compilerOption) => {
// 生成rpk逻辑
}
描述: 配置watch时忽略的文件或者文件夹
参数类型:
MatchType
示例:
watchIgnores = [/node_modules/, '/build/', '/dist/']
FAQs
File conversion tool, can be one-to-one, one to N, N to one
The npm package file-lane receives a total of 55 weekly downloads. As such, file-lane popularity was classified as not popular.
We found that file-lane demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.