diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28a9b79..a8265ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,9 @@ jobs: - name: Install modules run: npm install + - name: Audit production dependencies + run: npm audit --omit=dev --audit-level=moderate + - name: Run lint run: npm run lint diff --git a/__tests__/symlink-security.spec.ts b/__tests__/symlink-security.spec.ts index 1204d83..d77e4e7 100644 --- a/__tests__/symlink-security.spec.ts +++ b/__tests__/symlink-security.spec.ts @@ -63,6 +63,18 @@ describe("symlink security", () => { // This test documents the current loadMdFiles behavior. }); + test("loadMdFiles does not recurse through symlinked directories", async () => { + const realDir = path.join(tmpDir, "real"); + const nestedDir = path.join(realDir, "nested"); + fs.mkdirSync(nestedDir, { recursive: true }); + fs.writeFileSync(path.join(nestedDir, "a.md"), "# a"); + fs.symlinkSync(realDir, path.join(tmpDir, "link"), "dir"); + + const result = await loadMdFiles([path.join(tmpDir, "**", "*.md")], []); + + expect(result).toEqual([path.join(nestedDir, "a.md")]); + }); + test("loadMdFiles deduplicates overlapping patterns", async () => { const filePath = path.join(tmpDir, "dup.md"); fs.writeFileSync(filePath, "# dup"); @@ -119,6 +131,19 @@ describe("symlink security", () => { expect(result).not.toContain(path.join(tmpDir, "b.txt")); }); + test("loadMdFiles excludes directories and ignored files", async () => { + const includedFile = path.join(tmpDir, "included.md"); + const ignoredFile = path.join(tmpDir, "ignored.md"); + const directory = path.join(tmpDir, "directory.md"); + fs.writeFileSync(includedFile, "# included"); + fs.writeFileSync(ignoredFile, "# ignored"); + fs.mkdirSync(directory); + + const result = await loadMdFiles([path.join(tmpDir, "*")], [ignoredFile]); + + expect(result).toEqual([includedFile]); + }); + test("safeWriteFile rejects symlink", async () => { const target = path.join(tmpDir, "target.md"); const symlink = path.join(tmpDir, "link.md"); diff --git a/package.json b/package.json index 5de0a89..8eb1755 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "@lint-md/cli", "version": "2.5.0", + "engines": { + "node": ">=20" + }, "description": "CLI tool to lint your markdown file for Chinese.", "bin": { "lint-md": "lib/src/lint-md.js" @@ -57,7 +60,7 @@ "@lint-md/core": "^2.6.0", "chalk": "^4", "commander": "^9.4.1", - "glob": "^13.0.6", + "glob": "^14.0.3", "piscina": "^5.1.4", "strip-ansi": "^6.0.1", "text-table": "^0.2.0"