Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Doug/fix windows support #123

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
dacoburn merged 5 commits into main from doug/fix-windows-support
Oct 24, 2025
Merged

Doug/fix windows support #123

dacoburn merged 5 commits into main from doug/fix-windows-support
Oct 24, 2025

Conversation

@dacoburn
Copy link
Collaborator

@dacoburn dacoburn commented Oct 24, 2025

The CLI was broken on Windows due to usage of the Unix-only resource module, and multiple API clients were using hardcoded, inconsistent User-Agent strings. This caused:

  • Complete failure to run on Windows systems (ImportError on resource module)
  • Inaccurate telemetry and API request tracking
  • Difficulty debugging version-specific issues
  • Inconsistent identification across different API endpoints

Root Cause

  1. Windows Compatibility: The resource_utils.py module unconditionally imported the resource module, which is only available on Unix-like systems (Linux, macOS). This caused an ImportError on Windows, preventing the CLI from running.

  2. User-Agent Inconsistency: User-Agent strings were hardcoded in multiple locations (GitLab, GitHub, and CLI clients) rather than being derived from the package version defined in socketsecurity/__init__.py. Each client independently defined its User-Agent, leading to version drift and inconsistency.

Fix

Windows Compatibility Fix:

  • Added platform detection to conditionally import the resource module only on Unix systems
  • Wrapped all resource module usage in availability checks
  • Modified get_file_descriptor_limit() to return (None, None) on Windows
  • Updated check_file_count_against_ulimit() to gracefully handle Windows by returning can_check: False and safe_to_process: True
  • The CLI now runs successfully on Windows while maintaining full functionality on Unix systems

User-Agent Centralization:

  • Added a centralized USER_AGENT constant to socketsecurity/__init__.py that uses the actual package version: f'SocketPythonCLI/{__version__}'
  • Updated all API clients to import and use the centralized USER_AGENT:
    • socketsecurity/core/cli_client.py
    • socketsecurity/core/scm/client.py (GitHub and GitLab clients)
    • socketsecurity/core/scm/github.py
    • socketsecurity/core/scm/gitlab.py
  • Updated unit tests to reference the centralized constant

Additional Improvements:

  • Fixed minor GitLab client bugs discovered during refactoring:
    • Fixed return type in fallback headers method (None → {})
    • Added 'pipeline' to supported pipeline sources
  • Pinned GitHub Actions to commit SHAs for improved security and reproducibility
  • Bumped version to 2.2.12

Public Changelog

  • Fixed Windows compatibility issue where CLI would crash on import due to Unix-only resource module
  • Fixed User-Agent header to correctly report the CLI version in all API requests

- Add USER_AGENT constant to socketsecurity/__init__.py
- Replace hardcoded 'SocketPythonScript/0.0.1' and 'SocketPythonCLI/0.0.1' with centralized USER_AGENT
- Update all SCM clients (GitHub, GitLab) and CLI client to use USER_AGENT
- Update unit tests to reference centralized constant
- Pin GitHub Actions to commit SHAs for improved security and reproducibility
- Fix minor GitLab client bugs (return type, pipeline source support)
@dacoburn dacoburn requested a review from a team as a code owner October 24, 2025 01:22
@dacoburn dacoburn requested review from kapravel and reberhardt7 and removed request for a team October 24, 2025 01:22
Copy link

github-actions bot commented Oct 24, 2025
edited
Loading

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.2.15.dev1

Docker image: socketdev/cli:pr-123

@dacoburn dacoburn added the Product Changelog New features for the public changelog label Oct 24, 2025
@dacoburn dacoburn merged commit cc45ff4 into main Oct 24, 2025
6 checks passed
@dacoburn dacoburn deleted the doug/fix-windows-support branch October 24, 2025 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tmpvar tmpvar tmpvar approved these changes

@kapravel kapravel Awaiting requested review from kapravel kapravel is a code owner automatically assigned from SocketDev/eng

@reberhardt7 reberhardt7 Awaiting requested review from reberhardt7 reberhardt7 is a code owner automatically assigned from SocketDev/eng

Assignees

No one assigned

Labels

Product Changelog New features for the public changelog

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /