Fix inconsistent port type in scan event records [ Fixes #1649] - #1652
Fix inconsistent port type in scan event records [ Fixes #1649]#1652Aarush289 wants to merge 6 commits into
Conversation
Summary by CodeRabbit
Walkthrough
ChangesPort normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nettacker/core/lib/base.py`:
- Around line 136-140: Replace the duplicated URL port extraction expressions in
both log branches with one shared helper using urllib.parse.urlsplit(...).port;
have it accept the URL string, catch ValueError, and return an empty string when
no valid port is present. Update both event-processing locations to reuse this
helper instead of split-based parsing.
- Around line 133-135: Normalize the selected port value in process_conditions
before constructing the database record: after choosing event.get("ports"),
event.get("port"), or the fallback, convert string ports such as "443" to the
expected numeric representation. Apply the same normalization to the
corresponding port-selection logic referenced around the second location, while
preserving existing precedence and fallback behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0d33ef86-3575-40fd-9f6a-b52175ea3bb7
📒 Files selected for processing (1)
nettacker/core/lib/base.py
|
@codex review this PR using skill: https://github.com/nettacker-codex-ai/skills/blob/main/pr-review-recommender/SKILL.md |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9278cdf4fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nettacker/core/lib/base.py`:
- Around line 136-138: Replace the isdigit()-based conversion in
nettacker/core/lib/base.py lines 136-138 with a guarded direct int() attempt,
preserving the original string when conversion raises ValueError before storing
the port. Apply the same normalization change in nettacker/core/graph.py lines
352-353 before creating compare tuples, so Unicode digit strings that int()
rejects remain unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1c95ff59-895c-4702-b2a8-8033bef7ceb4
📒 Files selected for processing (2)
nettacker/core/graph.pynettacker/core/lib/base.py
Proposed change
This PR fixes #1649

The following picture shows that before fix the port as stored as string while after the fix it was stored as int.
Type of change
Checklist
make pre-commitand confirm it didn't generate any warnings/changesmake testand I confirm all tests passed locallydocs/folder