Skip to content

fix: address validation length mismatch and directory verification #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

haasonsaas
Copy link
Owner

Summary

  • Fix validation length mismatch where SafeString schema max was 1000 but usage was 2000
  • Add proper file type verification in SecureCodeReader.findRelatedFiles using fs.lstat

Changes Made

1. InputValidator String Length Fix

  • Updated SafeString schema max length from 1000 to 2000
  • Updated validateString default maxLength parameter to 2000
  • This ensures valid inputs between 1000-2000 characters are no longer rejected

2. SecureCodeReader Directory Verification

  • Added fs.lstat check in findRelatedFiles to verify entries are actual files
  • Skips directories and symlinks before processing
  • Prevents attempting to read directories as files

3. Code Quality Improvements

  • Fixed all ESLint errors (126 problems reduced to 12 warnings)
  • Removed unused imports
  • Fixed trailing spaces and missing commas
  • Properly escaped regex patterns

Testing

  • TypeScript build passes successfully
  • ESLint now shows only type warnings (no errors)
  • All security features remain intact

🤖 Generated with Claude Code

- Update SafeString schema max length from 1000 to 2000 to match usage
- Add fs.lstat check in findRelatedFiles to skip directories and symlinks
- Ensure only actual files are processed in file discovery
- Fix ESLint errors and warnings

These changes resolve the validation inconsistency and improve security by
properly verifying file types before processing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@haasonsaas haasonsaas requested a review from Copilot June 12, 2025 00:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a validation length mismatch in input validation and improves file type verification by ensuring only files are processed. Key changes include updating the SafeString schema and validateString max length from 1000 to 2000, adding fs.lstat-based file checks in SecureCodeReader, and various ESLint and formatting updates.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/utils/SecureCodeReader.ts Added fs.lstat check to skip directories and symlinks
src/utils/PromptSanitizer.ts Minor lint and formatting improvements
src/utils/InputValidator.ts Updated max length and adjusted regex for safe string and filename schemas
src/utils/ErrorClassifier.ts Added missing commas for consistency
src/utils/CodeReader.ts Minor code formatting fixes
src/services/GeminiService.ts Added missing commas for consistency
src/services/ConversationalGeminiService.ts Removed unused import of SessionError
src/index.ts Removed unused type import from models
src/analyzers/DeepCodeReasonerV2.ts Added missing commas for consistency

@haasonsaas haasonsaas merged commit 33831e1 into main Jun 12, 2025
4 checks passed
@haasonsaas haasonsaas deleted the fix/validation-length-mismatch branch June 12, 2025 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant