Skip to content

test(ci): add unit tests for documentation link validation (#2186) - #2349

Closed
Sneha-Anand1910 wants to merge 951 commits into
utksh1:mainfrom
Sneha-Anand1910:sneha/validate-doc-links-2186
Closed

test(ci): add unit tests for documentation link validation (#2186)#2349
Sneha-Anand1910 wants to merge 951 commits into
utksh1:mainfrom
Sneha-Anand1910:sneha/validate-doc-links-2186

Conversation

@Sneha-Anand1910

Copy link
Copy Markdown

Description

This PR adds unit tests for the documentation link validator (scripts/validate_doc_links.py). The script had no tests, so this adds coverage to make sure it reliably catches broken documentation links before they reach CI.

Related Issues

Fixes #2186

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

How Has This Been Tested?

Added a new test file testing/backend/unit/test_validate_doc_links.py with 5 tests covering:

  • a valid relative link with a valid anchor (passes cleanly)
  • a link to a missing file (reports a broken link target)
  • a link with a broken #anchor (reports the anchor as not found)
  • external / in-page / mailto links (correctly skipped)
  • slugify producing GitHub-style anchors

Run locally with:
python -m pytest testing/backend/unit/test_validate_doc_links.py -v

Result: all 5 tests pass.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

HitanshiThakar and others added 30 commits June 30, 2026 20:19
- New reportTemplates.ts service with ReportTemplate type, three built-in
  templates (executive, technical, compliance), and render/preview/export.
- ReportTemplatePicker.tsx slide-over component with type filtering, inline
  preview, and .md export.
- Integrate Templates button into Reports.tsx report cards.
- 21 unit tests covering template lifecycle, edge cases, and output.
…odule (utksh1#1524)

The extract_target helper in executor.py is a pure function but lives in
a heavy import chain (FastAPI, cache, config). Per the maintainer's
approved extraction pattern (used for routes_json_helpers), this extracts
extract_target into a small import-safe executor_target_helpers module
and re-exports it from executor.py so existing call sites keep working.

Closes utksh1#1389.

Co-authored-by: tmdeveloper007 <[email protected]>
S0412-2007 and others added 9 commits July 20, 2026 18:30
Add shared time_utils helpers and use timezone-aware UTC with an
explicit offset for generated_at and discovered_at across reports,
findings API responses, and report generation.

Closes utksh1#1882
Default to_utc_iso to timespec=auto so finding intelligence tests can
compare against datetime.now(UTC). Update TLS verification mocks for
crawler client.stream() and stub crawl_target in API scanner tests.
…idable

_init_default_policies() built the entire network denylist from the
single Pydantic field settings.network_denylist. Pydantic replaces
(rather than merges) a list field's default when SECUSCAN_NETWORK_DENYLIST
is set via env var, so any operator adding even one custom denylist
entry silently dropped the built-in protection for cloud metadata
(169.254.169.254), loopback, RFC1918/CGNAT ranges, and IPv6
link-local/ULA space -- reopening SSRF to the metadata endpoint despite
the code comment claiming the denylist was 'always enforced'.

Fix: move those ranges into a new MANDATORY_DENYLIST module constant
that is not read from settings and is applied unconditionally in
_init_default_policies before any operator-configured entries. The
operator-facing network_denylist setting is now purely additive.

Also updates the existing default-denylist test and adds a regression
test reproducing the exact scenario from utksh1#1748.
…ne-standardize-9bb6

fix(backend): standardize timezone handling to UTC ISO-8601
…t-metadata-ssrf

Fix utksh1#1748: make cloud-metadata/private-range denylist non-overridable
Fix: add auth and owner isolation to saved views API (closes utksh1#1743)
Cover the scapy_recon plugin parser.py with targeted behavioural tests:

- Metadata contract: file existence, valid JSON, required fields, engine
  binary, target/type field declarations
- ARP output: host count, IP+MAC extraction, finding keys, category,
  severity, description content, metadata consistency, remediation
- ICMP output: host count, IP extraction, Unknown-MAC default
- Single-host edge case: IP+MAC in result and description
- Malformed/empty input: empty string, whitespace-only, no UP: lines,
  mixed noise lines, malformed UP: lines, missing MAC separator

No changes to backend source; test file only.
* fix: stop dashboard polling after health failure and add manual retry

* fix: skip pre-existing upstream auth tests that cannot pass with mocked auth

* fix: update postcss to resolve GHSA-r28c-9q8g-f849 high severity vulnerability

* fix: document localhost-only Docker binding, add opt-in network override
@Sneha-Anand1910

Copy link
Copy Markdown
Author

Hi @utksh1 , I've addressed the requested changes and pushed the latest updates. Please let me know if there's anything else I should modify. Thank you!

@utksh1 utksh1 added area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label labels Aug 4, 2026
AnzalKhan16 and others added 8 commits August 4, 2026 15:22
* Fix risk scoring defaults

* Update risk scoring tests
…low runs (utksh1#2396)

POST /workflows/{id}/run and WorkflowScheduler._run_workflow now apply the
same exploit-validation gate as start_task: exploit-level plugins and
validation_mode=CONTROLLED_EXTRACT steps require a target policy with
allow_exploit_validation=True, otherwise the step is skipped with a warning.

Fixes utksh1#2395
…h1#2367)

Closes utksh1#1845

Escape was a no-op outside text fields. useShortcuts had:

    if (e.key === 'Escape') {
        // Could emit global event to close modals
        return
    }

so nothing was ever emitted and no popover had anything to listen for.

useShortcuts now broadcasts a CustomEvent, and useEscapeToClose is the
subscriber side. Keeping the single window-level keydown listener in
useShortcuts and fanning out via one event means the listener count does
not grow with the number of overlays on a page, and every overlay closes
the same way.

Wired into both affected surfaces. The Saved Views panel is the one named
in the issue; the bulk-export dropdown on the Findings page had the same
problem and is fixed with it.

useEscapeToClose only subscribes while its overlay is open, so a closed
popover neither reacts nor keeps a listener alive.

Escape while typing keeps its existing behaviour: useShortcuts blurs the
focused field and returns without broadcasting. A field inside a panel
therefore takes two presses — one to leave the field, one to close the
panel — so a stray Escape mid-typing cannot discard what was being
entered. That is pinned by a test rather than left implicit.

Verified by mutation: dropping the broadcast fails the useShortcuts test,
and dropping the subscriber fails the SavedViewsPanel test.
* Add retry support for notification delivery

* Remove trailing whitespace

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the focused test change and its current checks are green. The PR still needs a current branch update before merge because it is behind main; I will not bypass the branch policy.

@Sneha-Anand1910

Copy link
Copy Markdown
Author

Hi @utksh1, thanks for the approval! Branch is updated with main. This PR only adds a Python test and touches no frontend code, so the failing frontend checks look unrelated (likely pre-existing). I can't re-run from my fork , could you re-run them when you get a chance?

aaniya22 and others added 3 commits August 5, 2026 13:00
* test: add unit tests for _validate_lengths field length guard

Covers valid/boundary/over-limit cases for name, description, and
notes fields, plus custom resource_type substitution and None
handling for optional fields. Closes utksh1#2307.

* fix: bump undici to patch high-severity vulnerability (GHSA-8xcm-r25x-g524 and related)
@utksh1
utksh1 force-pushed the sneha/validate-doc-links-2186 branch from 39b8f78 to 3b30a95 Compare August 5, 2026 07:50
@utksh1 utksh1 closed this Aug 15, 2026
@Sneha-Anand1910

Copy link
Copy Markdown
Author

Hi @utksh1, I noticed that PR #2349 was closed as unmerged. The PR had already been approved, and my contribution (5f23dbd) was pushed to the branch, but the PR was later closed . Since the GSSoC contribution deadline has now passed, could you please let me know if the contribution can still be merged and counted? I would really appreciate your help since the changes were already reviewed and approved..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(ci): cover relative and anchor failures in documentation link validation