Skip to content

Commit 0c93c65

Browse files
chore: wip
1 parent 19d80b4 commit 0c93c65

File tree

6 files changed

+873
-9
lines changed

6 files changed

+873
-9
lines changed

TODO.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ Based on test fixtures analysis:
642642
643643
## 📦 Package & Distribution
644644
645-
- [ ] **Types path mismatch** - `package.json` has `"types": "./dist/index.d.ts"` but exports point to `./dist/src/index.js`. Verify alignment.
645+
- [x] **Types path mismatch** - ✅ Fixed in `package.json`:
646+
- Added `types` field to exports for proper TypeScript resolution
647+
- Main export: `{ types: "./dist/index.d.ts", import: "./dist/src/index.js" }`
648+
- Subpath exports: `{ types: "./dist/*.d.ts", import: "./dist/*" }`
646649
647650
- [ ] **Peer dependencies** - Consider making `typescript` a peer dependency.
648651
@@ -759,17 +762,37 @@ Based on test fixtures analysis:
759762
760763
---
761764
762-
## 🔐 Security & Robustness
765+
## 🔐 Security & Robustness ✅ RESOLVED
763766
764-
- [ ] **Path traversal protection** - Validate file paths don't escape project root.
767+
- [x] **Path traversal protection** - ✅ Implemented in `src/security.ts`:
768+
- `validatePath()` - Validates paths are within root directory
769+
- `validatePaths()` - Batch path validation
770+
- `sanitizeFilename()` - Removes traversal sequences
771+
- `isSafePath()` - Quick safety check
772+
- `SecurityError` with error codes
765773
766-
- [ ] **Symlink handling** - Decide behavior for symbolic links.
774+
- [x] **Symlink handling** - ✅ Implemented in `src/security.ts`:
775+
- `isSymlink()` - Check if path is symbolic link
776+
- `validateSymlink()` - Follow or reject symlinks based on config
777+
- `followSymlinks` option (default: false)
767778
768-
- [ ] **Large file protection** - Add configurable size limits to prevent OOM.
779+
- [x] **Large file protection** - ✅ Implemented in `src/security.ts`:
780+
- `validateFileSize()` - Check file size against limit
781+
- `maxFileSize` option (default: 10MB)
782+
- `maxTotalSize` option (default: 100MB)
783+
- `maxFiles` option (default: 10000)
769784
770-
- [ ] **Timeout handling** - Add configurable timeout for processing.
785+
- [x] **Timeout handling** - ✅ Implemented in `src/security.ts`:
786+
- `withTimeout()` - Wrap promises with timeout
787+
- `createSecureProcessor()` - Process with all protections
788+
- `timeout` option (default: 30 seconds)
771789
772-
- [x] **Graceful degradation** - Continue processing other files if one fails. ✅ `--continue-on-error` option
790+
- [x] **Blocked patterns** - ✅ Blocks sensitive files by default:
791+
- `.git/**`, `node_modules/**`, `.env*`, `secrets/**`, `*.key`, `*.pem`
792+
- `isBlockedPath()` - Check against patterns
793+
- Custom `blockedPatterns` config
794+
795+
- [x] **Graceful degradation** - ✅ `--continue-on-error` option
773796
774797
---
775798
@@ -1419,7 +1442,23 @@ Based on test fixtures analysis:
14191442
- Verified generator.ts console usage is intentional (JSON output, subprocess communication)
14201443
- Verified parser.ts is deprecated with simple regex patterns
14211444
1422-
**Total tests: 481** (up from 439)
1445+
- **Security Module** - `src/security.ts` (NEW):
1446+
- `SecurityConfig` interface with all security options
1447+
- `SecurityError` class with typed error codes
1448+
- Path traversal protection: `validatePath()`, `validatePaths()`, `sanitizeFilename()`, `isSafePath()`
1449+
- Symlink handling: `isSymlink()`, `validateSymlink()`
1450+
- File size protection: `validateFileSize()`, `validateFileBatch()`
1451+
- Timeout handling: `withTimeout()`, `createSecureProcessor()`, `createSecureBatchProcessor()`
1452+
- Blocked patterns: `isBlockedPath()` with glob pattern matching
1453+
- `createSecurityMiddleware()` - Factory for security checks
1454+
- `DEFAULT_SECURITY_CONFIG` with sensible defaults
1455+
- Added `test/security.test.ts` (39 tests)
1456+
1457+
- **Package.json Fix**:
1458+
- Added `types` field to exports for proper TypeScript module resolution
1459+
- Ensures TypeScript finds declaration files correctly
1460+
1461+
**Total tests: 520** (up from 481)
14231462
14241463
---
14251464

packages/dtsx/.test-cli/docs-test/api-docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# API Documentation
22

3-
> Generated on 2025-11-27T12:48:04.077Z
3+
> Generated on 2025-11-27T13:09:10.736Z
44
55
## Table of Contents
66

packages/dtsx/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
],
2626
"exports": {
2727
".": {
28+
"types": "./dist/index.d.ts",
2829
"import": "./dist/src/index.js"
2930
},
3031
"./*": {
32+
"types": "./dist/*.d.ts",
3133
"import": "./dist/*"
3234
}
3335
},

packages/dtsx/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export * from './lsp'
5252
export * from './optimizer'
5353
export * from './output-normalizer'
5454
export * from './profiling'
55+
export * from './security'
5556
export * from './sourcemap'
5657
export * from './tracking'
5758
export * from './transformers'

0 commit comments

Comments
 (0)