Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@lazy-node/windows-unsafe-filename

Latest version: v1.0.17

Overview

Last scanned
27 Nov 2026
Published
27 Nov 2026
npm package Publisher: bluelovers
2 Stars
0 Forks
1 Versions
2.2K Downloads
TypeScript Repo language

Scan summary

@lazy-node/windows-unsafe-filename was last scanned on 27 Nov 2026 at version 1.0.17. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: First and only release on 27 Nov 2026.
  • Findings: No rules fired in version 1.0.17.
  • Downloads: 2,248 downloads.

Versions

1 version published
Versions and the rules that fired in each
VersionPublishedStatus
1.0.17 LATEST 27 Nov 2026 No rules fired

No rules fired in 1.0.17

Findings

Findings for v1.0.17. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.0.17; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@lazy-node/windows-unsafe-filename - Windows 不安全檔案名稱檢測模組

這個模組提供了檢測和處理 Windows 系統中不安全檔案名稱的功能。Windows 系統有特定的保留字元和裝置名稱,不能用作檔案名稱。

主要功能

  • 檢測 Windows 保留的裝置名稱
  • 支援標準模式和擴展模式
  • 提供正規表示式建立功能
  • 支援字串替換功能
  • 跨平台相容性

安裝

yarn add @lazy-node/windows-unsafe-filename
yarn-tool add @lazy-node/windows-unsafe-filename
yt add @lazy-node/windows-unsafe-filename

快速開始

import { hasWindowsUnsafeName, replaceWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 檢測不安全名稱
const isUnsafe = hasWindowsUnsafeName('con.txt');
console.log(isUnsafe); // 匹配結果陣列

// 替換不安全名稱
const safeName = replaceWindowsUnsafeName('con.txt', 'safe_name');
console.log(safeName); // 'safe_name.txt'

API 文件

主要函數
newRegExpWindowsUnsafeName(mode?: boolean): RegExp

建立 Windows 不安全名稱的正規表示式。

參數:

  • mode (boolean): 是否使用擴展模式(支援 com00-lpt99)

返回值:

  • RegExp: 檢測 Windows 不安全名稱的正規表示式

模式說明:

  • false (預設): 標準模式,支援 com0-lpt9
  • true: 擴展模式,支援 com00-lpt99
hasWindowsUnsafeName(name: string, mode?: boolean): RegExpMatchArray | null

檢測字串是否包含 Windows 不安全名稱。

參數:

  • name (string): 要檢測的字串
  • mode (boolean): 是否使用擴展模式

返回值:

  • RegExpMatchArray | null: 匹配結果,null 表示安全
replaceWindowsUnsafeName(name: string, replaceValue: string | ((substring: string, ...args: (string | undefined)[]) => string), mode?: boolean): string

替換 Windows 不安全名稱。

參數:

  • name (string): 要處理的字串
  • replaceValue (string | function): 替換值或回呼函數
  • mode (boolean): 是否使用擴展模式

返回值:

  • string: 處理後的字串

使用範例

基本檢測
import { hasWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 檢測常見的 Windows 保留名稱
const testNames = [
  'con.txt',
  'prn.doc',
  'aux.exe',
  'nul.bat',
  'com1.log',
  'lpt1.dat',
  'normal.txt'
];

testNames.forEach(name => {
  const result = hasWindowsUnsafeName(name);
  console.log(`${name}: ${result ? '不安全' : '安全'}`);
});

// 輸出:
// con.txt: 不安全
// prn.doc: 不安全
// aux.exe: 不安全
// nul.bat: 不安全
// com1.log: 不安全
// lpt1.dat: 不安全
// normal.txt: 安全
使用替換功能
import { replaceWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 使用字串替換
const unsafeName = 'con.txt';
const safeName = replaceWindowsUnsafeName(unsafeName, 'safe_name');
console.log(safeName); // 'safe_name.txt'

// 使用回呼函數替換
const unsafeName2 = 'com1.log';
const safeName2 = replaceWindowsUnsafeName(unsafeName2, (match, name, ext) => {
  return `device_${name}${ext || ''}`;
});
console.log(safeName2); // 'device_com1.log'
擴展模式使用
import { hasWindowsUnsafeName, replaceWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 標準模式(預設)
console.log(hasWindowsUnsafeName('com10.txt')); // null (安全)
console.log(hasWindowsUnsafeName('lpt20.txt')); // null (安全)

// 擴展模式
console.log(hasWindowsUnsafeName('com10.txt', true)); // 匹配結果 (不安全)
console.log(hasWindowsUnsafeName('lpt20.txt', true)); // 匹配結果 (不安全)

// 擴展模式替換
const result = replaceWindowsUnsafeName('com10.txt', 'safe', true);
console.log(result); // 'safe.txt'
實際應用場景
import { hasWindowsUnsafeName, replaceWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 安全的檔案名稱處理
function createSafeFilename(filename: string): string {
  if (hasWindowsUnsafeName(filename)) {
    return replaceWindowsUnsafeName(filename, (match, name, ext) => {
      return `safe_${name}${ext || ''}`;
    });
  }
  return filename;
}

// 批量處理檔案名稱
function processFilenames(filenames: string[]): string[] {
  return filenames.map(name => createSafeFilename(name));
}

// 使用範例
const unsafeFilenames = [
  'con.txt',
  'prn.doc',
  'com1.log',
  'normal.txt'
];

const safeFilenames = processFilenames(unsafeFilenames);
console.log(safeFilenames);
// ['safe_con.txt', 'safe_prn.doc', 'safe_com1.log', 'normal.txt']
與其他模組整合
import { sanitizeFilename } from '@lazy-node/sanitize-filename';
import { replaceWindowsUnsafeName } from '@lazy-node/windows-unsafe-filename';

// 綜合檔案名稱安全化
function comprehensiveSanitize(filename: string): string {
  // 先處理 Windows 不安全名稱
  let safeName = replaceWindowsUnsafeName(filename, 'safe_device');

  // 再進行完整的檔案名稱安全化
  safeName = sanitizeFilename(safeName, {
    trim: true,
    replaceToFullWidth: true
  });

  return safeName;
}

// 使用範例
const unsafeInput = 'con?.txt';
const safeOutput = comprehensiveSanitize(unsafeInput);
console.log(safeOutput); // 'safe_device!.txt'

Windows 保留名稱列表

標準模式支援的名稱
  • con - 控制台
  • prn - 印表機
  • aux - 輔助設備
  • nul - 空設備
  • com0 到 com9 - 通訊埠
  • lpt0 到 lpt9 - 並列埠
擴展模式額外支援的名稱
  • com00 到 com99 - 擴展通訊埠
  • lpt00 到 lpt99 - 擴展並列埠

注意事項

  • 模組會自動忽略大小寫
  • 支援帶有副檔名的檔案名稱
  • 擴展模式提供更嚴格的檢查
  • 可以與其他檔案名稱處理模組配合使用

貢獻

歡迎提交問題和拉取請求!

授權

ISC

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @lazy-node/windows-unsafe-filename

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Frame 2085668439 (1)
Group 1261154229