Hide pagination controls when no results exist in Crawler page
Proposed change
The Crawler page in the Nettacker web UI incorrectly displays pagination buttons (Previous, Next, and numbered page buttons) even when there are no scan results. This fix hides pagination controls when the result set is empty and only shows them when actual data exists.
Problems
-
Incorrect totalPages calculation
- Response length was being calculated on the raw JSON string instead of the parsed array
- This caused totalPages to always be a large number regardless of actual results
- Pagination buttons were always rendered even with zero results
-
Poor empty state UX
- Users saw 5 page buttons and a Next button on an empty Crawler page
- This was confusing and suggested data existed when it did not
- No visual feedback that the page was actually empty
Proposed solution
Frontend (main.js)
Parse the JSON response before calculating total pages:
- Use
JSON.parse(res)beforeMath.ceil(parsedRes.length / 10) - Check
parsedRes.length === 0before rendering pagination - Hide all pagination controls when result set is empty
- Only call
updatePaginationControls()when results exist
This keeps the fix minimal and non-breaking. Existing pagination logic for non-empty results is completely unchanged.
Scope
This change only affects the Crawler page pagination logic in main.js. No changes to backend, scan engine, or any other UI component.
Summary by CodeRabbit
-
Chores
- Reformatted HTML and JavaScript for consistent spacing, indentation, and inline script clarity.
-
Bug Fixes
- Improved crawler pagination and navigation to properly handle empty results and update controls.
-
New
- Added a CSV scan-results report containing sample scan entries with structured event data.
Walkthrough
Formatting-only HTML/inline-script whitespace changes, minor JS callback/bracing fixes, a modified crawler-list pagination flow in frontend JS, and addition of a CSV scan report file.
Changes
| Cohort / File(s) | Summary |
|---|---|
HTML formatting & inline script nettacker/web/static/index.html |
Whitespace and indentation reflow across markup and an inline JS block (renderjson iteration and clipboard handlers). No identifier/name changes; control flow preserved. |
JS logic, handlers & pagination nettacker/web/static/js/main.js |
Whitespace/reformatting and callback/bracing fixes (compare flow). In get_crawler_list the response is parsed (JSON.parse(res)), show_crawler(res) is called earlier, previous totalPages/math and crawler_page boundary logic removed; empty/"No more search results" now hides prev/next and clears pagination, otherwise shows next/prev UI. Helper functions re-indented. |
New scan report (CSV) report-2026_03_19_17_17_43jgvcdenicq |
Added CSV with scan results for scanme.nmap.org (ports 22, 80, 31337, 9929) including scan_id, target, port, event, and json_event payloads. |
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
Suggested reviewers
- arkid15r
๐ฅ Pre-merge checks | โ 2 | โ 1
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title clearly summarizes the main change: hiding pagination controls when no results exist in the Crawler page, which aligns with the core objective of the PR. |
| Description check | โ Passed | The description is directly related to the changeset, explaining the problem with pagination display on empty results and the proposed frontend solution in main.js, which matches the actual changes made. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
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 @coderabbitai help to get the list of available commands and usage tips.
@coderabbitai could confirm if this pr conflicts with others prs like #1294 , #1420 .
[!TIP] For best results, initiate chat on the files or code changes.
๐งฉ Analysis chain
๐ Script executed:
#!/bin/bash
# Fetch PR `#1294` details and files changed
echo "=== PR `#1294` ==="
gh pr view 1294 --repo OWASP/Nettacker --json title,state,author,files,headRefName,baseRefName 2>/dev/null || echo "PR not accessible"
echo ""
echo "=== PR `#1420` ==="
gh pr view 1420 --repo OWASP/Nettacker --json title,state,author,files,headRefName,baseRefName 2>/dev/null || echo "PR not accessible"
echo ""
echo "=== PR `#1426` ==="
gh pr view 1426 --repo OWASP/Nettacker --json title,state,author,files,headRefName,baseRefName 2>/dev/null || echo "PR not accessible"
Length of output: 1515
๐ Script executed:
#!/bin/bash
# Get the diff for main.js in PR `#1294`
echo "=== PR `#1294` diff for main.js ==="
gh api repos/OWASP/Nettacker/pulls/1294/files --jq '.[] | select(.filename == "nettacker/web/static/js/main.js") | .patch' 2>/dev/null | head -100
echo ""
echo "=== PR `#1426` diff for main.js ==="
gh api repos/OWASP/Nettacker/pulls/1426/files --jq '.[] | select(.filename == "nettacker/web/static/js/main.js") | .patch' 2>/dev/null | head -100
echo ""
echo "=== PR `#1426` accidental file ==="
gh api repos/OWASP/Nettacker/pulls/1426/files --jq '.[] | select(.filename | startswith("report-")) | {filename, additions, changeType}' 2>/dev/null
Length of output: 5583
@Gauravsharma2040 Yes, confirmed โ PR #1426 has direct conflicts with both #1294 and #1420. Here's the breakdown:
โ๏ธ PR #1426 vs PR #1294 โ Direct Code Conflict
Both PRs target the exact same lines in nettacker/web/static/js/main.js:
| Area | PR #1294 approach |
PR #1426 approach |
|---|---|---|
get_crawler_list .done() handler |
Removes const totalPages = Math.ceil(res.length / 10), adds robust JSON parsing with try/catch, uses data.slice(0, 10), retains updatePaginationControls() |
Removes the same line, does const parsedRes = JSON.parse(res), removes updatePaginationControls(), calls clearPaginationButtons() on empty |
show_crawler() |
Adds typeof res === "string" guard before parsing |
Also modifies this function |
nettacker/web/static/index.html |
+1 line change | +292/-289 lines โ large reformat |
These changes will produce a hard merge conflict on overlapping lines.
There's also a semantic conflict: PR #1294 fixes the root cause (backend offset bug in db.py + engine.py + proper frontend pagination), while PR #1426 only addresses the symptom from the frontend side. If #1294 merges first, #1426's approach may be partially redundant or incompatible.
โ๏ธ PR #1426 vs PR #1420 โ High Conflict Risk
PR #1420 is a massive refactor of main.js (+166/-409 lines, removing ~60% of the file). PR #1426 makes targeted edits to sections that PR #1420 likely restructures or removes entirely. If #1420 merges first, PR #1426 will need a full rebase.
โ ๏ธ Additional Issue in PR #1426 โ Accidental File Committed
PR #1426 accidentally includes a CSV scan report file:
report-2026_03_19_17_17_43jgvcdenicq (+7 lines, ADDED)
This appears to be a local scan artifact and should be removed from the PR before any merge is considered.
Summary
| Conflict | Type | Severity |
|---|---|---|
#1426 vs #1294 |
Direct merge conflict + semantic overlap in main.js and index.html |
๐ด High |
#1426 vs #1420 |
Likely merge conflict due to large main.js restructure | ๐ด High |
#1426 accidental file |
Stray CSV report committed | ๐ก Must fix |
Recommendation: The author of PR #1426 should coordinate with the authors of #1294 and #1420, remove the accidentally committed report file, and rebase after the other PRs are resolved or merged.
๐ง Learnings used
Learnt from: securestep9
Repo: OWASP/Nettacker PR: 0
File: :0-0
Timestamp: 2026-01-10T14:58:54.638Z
Learning: When reviewing a pull request, always analyze other open PRs in the repository to identify potential conflicts, such as duplicate changes to the same files, overlapping features, or merge conflicts. Use GitHub CLI to search for related PRs by file changes, keywords, or linked issues.
Learnt from: Gauravsharma2040
Repo: OWASP/Nettacker PR: 0
File: :0-0
Timestamp: 2026-03-18T18:37:47.395Z
Learning: In PR `#1420` (OWASP/Nettacker, by Gauravsharma2040, branch fix-main.js), the crawler results pagination fix was intentionally excluded from scope. The decision was documented by the author: full rectification requires backend changes in nettacker/database/db.py and nettacker/api/engine.py (0-based vs 1-based offset, also addressed in PR `#1294` by kwei-zhang). PR `#1420` only fixes/cleans bugs within nettacker/web/static/js/main.js itself.
@coderabbitai full review
Full review triggered.โ
Actions performed