timonel 2.10.1 → 2.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [2.10.2](https://github.com/KenkoGeek/timonel/compare/v2.10.1...v2.10.2) (2025-09-20)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **cli:** consolidate path validation and improve error handling ([239a50f](https://github.com/KenkoGeek/timonel/commit/239a50fb30be451301d2af6a586b77748a3db6ec))
6
+
1
7
  ## [2.10.1](https://github.com/KenkoGeek/timonel/compare/v2.10.0...v2.10.1) (2025-09-20)
2
8
 
3
9
  ### Bug Fixes
package/dist/cli.js CHANGED
@@ -9,23 +9,6 @@ const __dirname = path.dirname(__filename);
9
9
  const UMBRELLA_CONFIG_FILE = 'umbrella.config.json';
10
10
  const UMBRELLA_FILE_NAME = 'umbrella.ts';
11
11
  const PACKAGE_JSON_FILE = 'package.json';
12
- function isValidPath(filePath, expectedFileName) {
13
- try {
14
- const resolvedPath = path.resolve(filePath);
15
- const normalizedPath = path.normalize(resolvedPath);
16
- if (normalizedPath.includes('..') || normalizedPath.includes('~')) {
17
- return false;
18
- }
19
- if (!normalizedPath.endsWith(expectedFileName)) {
20
- return false;
21
- }
22
- const suspiciousPatterns = ['\\', '..', '~', '$', '`', '|', '&', ';', '(', ')'];
23
- return !suspiciousPatterns.some((pattern) => normalizedPath.includes(pattern));
24
- }
25
- catch {
26
- return false;
27
- }
28
- }
29
12
  function getVersion() {
30
13
  try {
31
14
  const possiblePaths = [
@@ -35,18 +18,21 @@ function getVersion() {
35
18
  path.resolve(__dirname, PACKAGE_JSON_FILE),
36
19
  ];
37
20
  for (const packagePath of possiblePaths) {
38
- if (!isValidPath(packagePath, PACKAGE_JSON_FILE)) {
39
- continue;
40
- }
41
- if (fs.existsSync(packagePath)) {
42
- try {
43
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
44
- return packageJson.version || 'unknown';
45
- }
46
- catch {
47
- continue;
21
+ try {
22
+ const validatedPath = SecurityUtils.validatePath(packagePath, process.cwd());
23
+ if (fs.existsSync(validatedPath)) {
24
+ try {
25
+ const packageJson = JSON.parse(fs.readFileSync(validatedPath, 'utf8'));
26
+ return packageJson.version || 'unknown';
27
+ }
28
+ catch {
29
+ continue;
30
+ }
48
31
  }
49
32
  }
33
+ catch {
34
+ continue;
35
+ }
50
36
  }
51
37
  if (process.env.npm_package_version) {
52
38
  return process.env.npm_package_version;
@@ -64,7 +50,7 @@ function log(msg, silent = false) {
64
50
  }
65
51
  function logError(msg, silent = false) {
66
52
  if (!silent) {
67
- console.error(msg);
53
+ console.error(SecurityUtils.sanitizeLogMessage(msg));
68
54
  }
69
55
  }
70
56
  function usageAndExit(msg, silent = false) {
@@ -508,7 +494,7 @@ async function main() {
508
494
  main().catch((error) => {
509
495
  const flags = parseFlags(process.argv.slice(2));
510
496
  if (!flags.silent) {
511
- console.error('Error:', error.message);
497
+ console.error('Error:', SecurityUtils.sanitizeLogMessage(error.message));
512
498
  }
513
499
  process.exit(1);
514
500
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "timonel",
3
3
  "type": "module",
4
- "version": "2.10.1",
4
+ "version": "2.10.2",
5
5
  "description": "Timonel: programmatic Helm chart generator using cdk8s (TypeScript)",
6
6
  "bin": {
7
7
  "timonel": "dist/cli.js",
@@ -37,7 +37,9 @@
37
37
  "deps:update": "pnpm update --latest",
38
38
  "md:lint": "markdownlint \"**/*.md\"",
39
39
  "md:fix": "markdownlint --fix \"**/*.md\"",
40
- "test:integration": "vitest run --config vitest.config.ts",
40
+ "test": "vitest run --config vitest.config.ts",
41
+ "test:unit": "vitest run --config vitest.config.ts",
42
+ "test:integration": "vitest run --config vitest.integration.config.ts",
41
43
  "test:watch": "vitest",
42
44
  "test:coverage": "vitest run --coverage",
43
45
  "ci:check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm build",