Skip to content

fix: integrate semgrep with tool detection system and fix initializat…#167

Open
suung wants to merge 6 commits into
mainfrom
fix/156-166-semgrep-detection-and-initialization-reload
Open

fix: integrate semgrep with tool detection system and fix initializat…#167
suung wants to merge 6 commits into
mainfrom
fix/156-166-semgrep-detection-and-initialization-reload

Conversation

@suung
Copy link
Copy Markdown
Collaborator

@suung suung commented Nov 28, 2025

…ion reload

  • Fix Semgrep is not bundled #166: Integrate semgrep with existing tool detection/installation system

    • Update tools.json: change semgrep from built-in to pip installation
    • Add Python 3.7+ prerequisite checking
    • Add semgrep installation detection using command-based method
    • Show consistent error messages with installation instructions
    • Support pip installation in tools-tree-provider
  • Fix Data not refreshed after project initialization (needs #156: Fix initialization reload issue

    • Explicitly update context variable before refreshing trees
    • Add small delay to ensure context updates propagate
    • UI now updates immediately without requiring window reload
  • Add test coverage for both fixes

    • Unit tests for Python/semgrep detection
    • Unit tests for pip installation handling
    • E2E tests for initialization reload
    • E2E tests for semgrep error messages
  • Fix execa import issue in prerequisites.js

Pull Request Checklist

Legal Requirements

  • I have read and agree to the Contributor License Agreement
  • I understand that by contributing to this project, I grant the Carbonara team a perpetual, irrevocable license to use my contributions under the BSD license, while the public project remains under AGPL-3.0-or-later

Code Quality

  • My code follows the project's coding style and conventions
  • I have added appropriate tests for my changes
  • All new and existing tests pass
  • I have updated documentation where necessary

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test improvements

Testing

  • Unit tests
  • Integration tests
  • Manual testing
  • E2E tests (if applicable)

Additional Notes

…ion reload

- Fix #166: Integrate semgrep with existing tool detection/installation system
  - Update tools.json: change semgrep from built-in to pip installation
  - Add Python 3.7+ prerequisite checking
  - Add semgrep installation detection using command-based method
  - Show consistent error messages with installation instructions
  - Support pip installation in tools-tree-provider

- Fix #156: Fix initialization reload issue
  - Explicitly update context variable before refreshing trees
  - Add small delay to ensure context updates propagate
  - UI now updates immediately without requiring window reload

- Add test coverage for both fixes
  - Unit tests for Python/semgrep detection
  - Unit tests for pip installation handling
  - E2E tests for initialization reload
  - E2E tests for semgrep error messages

- Fix execa import issue in prerequisites.js
…on-reload

- Bring in prerequisites infrastructure from main
- Resolve conflicts in tools-tree-provider.ts (combine semgrep special handling with comprehensive contextValue logic)
…cs loading

- Add database storage for Semgrep results with one entry per scan per file
- Load diagnostics from database on file open/focus (works even if Semgrep not installed)
- Separate flow for loading diagnostics vs running live analysis
- Add integration tests for database storage and retrieval
- Handle parsing errors as non-fatal warnings when matches exist
- Add DEFAULT_SEMGREP_EXCLUSIONS to skip non-code files
- Improve e2e tests with venv setup and Problems panel verification
- Add unit tests for installation check and database flow
- .test-venv is created dynamically during e2e tests (not a fixture)
- test-results contains Playwright test output
- Both should not be committed
- Fix severity mapping: ERROR -> Error, WARNING -> Warning, INFO -> Information
- Diagnostics now appear in Problems panel with proper red markers for errors
- Enhance e2e tests to verify Problems panel visibility and Semgrep-specific entries
…irement

- Create shared installToolWithLogging() function in packages/cli/src/utils/tool-installer.ts
- Handles installation, logging, and config marking in one place
- Update CLI command to use shared function (DRYed up)
- Update VSCode extension to use shared function directly (no CLI required)
- Eliminates 'CLI not found' error when installing tools from VSCode
- Add comprehensive tests for shared installation function (7 tests)
- Add activation guard to prevent duplicate command registration
- Fix diagnostic collection name test (make test async)
- Skip VSCode installation tests (covered in CLI tests)

All installation-related tests passing:
- CLI tool-installer tests: 7/7 passing
- CLI tools-command tests: 4/4 passing
- Semgrep E2E tests: 4/4 passing
@grrrau
Copy link
Copy Markdown
Collaborator

grrrau commented Dec 14, 2025

Verification
After installation, verify the tool is available:
bash

verification is missing

@suung
Copy link
Copy Markdown
Collaborator Author

suung commented Dec 14, 2025

Verification
After installation, verify the tool is available:
bash

verification is missing

We went over it, on some machine, there are a bunch of problems, it's not pip, it's pip3, and after installation it's not in the path

we need a solution for this

This could be one
python="$(command -v python3 || command -v python)"; "$python" -c 'import sys,sysconfig,subprocess,os; s=sysconfig.get_path("scripts")+"/semgrep"; os.path.exists(s) or sys.exit("semgrep not installed"); sys.exit(subprocess.call([s,*sys.argv[1:]]))' "$@"

And it works when passed as a custom command, but another problem the problem is that if there is still an error, then the custom command cancels the error notification and we also need cross platform installation

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.

Semgrep is not bundled Data not refreshed after project initialization (needs

2 participants