Skip to content

Comments

Fix/code quality improvements#3

Open
Jairoy2426 wants to merge 2 commits intoReddyyZ:masterfrom
Jairoy2426:fix/code-quality-improvements
Open

Fix/code quality improvements#3
Jairoy2426 wants to merge 2 commits intoReddyyZ:masterfrom
Jairoy2426:fix/code-quality-improvements

Conversation

@Jairoy2426
Copy link

Summary

Code quality improvements and bug fixes to improve maintainability and reliability.

Changes

Bug Fixes

  • Deprecated API: Replace logging.warn() with logging.warning() (deprecated since Python 3.3)
  • Exception handling: Fix bare except: clauses with specific exceptions (IndexError, ValueError, AttributeError)
  • Service detection: Return None instead of raw exception object for consistent API contract
  • Import fix: Fix time module import (was using time.sleep() but only importing sleep)

Code Quality

  • Remove unused OPEN_PORT = 80 constant
  • Add type hints to Scanner class (__init__, port_scan)
  • Fix hardcoded paths in service_detection.py - now auto-detects path relative to module location
  • Add error logging in service_detection.py for debugging failed scans

OS Detection Enhancement

  • Improved TTL-based OS detection with efficient dict lookup
  • Added TTL range detection to handle hop decrementation (e.g., "Windows (TTL: 120)")

Testing

  • All modules import successfully
  • Syntax compilation passes (python -m py_compile)
  • --help command works correctly

- Replace deprecated logging.warn() with logging.warning()
- Remove unused OPEN_PORT constant
- Fix bare except clauses with specific exceptions
- Fix service_detection hardcoded paths with dynamic resolution
- Improve OS detection with efficient TTL lookup and range detection
- Add type hints to Scanner class
- Fix time module import
- Return None instead of raw exception object for consistent API
- Add logging.error() to record scan failures for debugging
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