Skip to content

test : added unit tests for _is_absolute_path helper - #2299

Closed
tmdeveloper007 wants to merge 940 commits into
utksh1:mainfrom
tmdeveloper007:#2294
Closed

test : added unit tests for _is_absolute_path helper#2299
tmdeveloper007 wants to merge 940 commits into
utksh1:mainfrom
tmdeveloper007:#2294

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2294.

Summary of What Has Been Done:
Extracted _is_absolute_path into a small import-safe module backend/secuscan/plugins_helpers.py, and added 7 comprehensive unit tests covering Unix absolute paths, Windows drive letters (forward and backslash), UNC paths, relative paths, and edge cases. Updated backend/secuscan/plugins.py to re-export the helper so existing import paths keep working.

Changes Made:

  • New file: backend/secuscan/plugins_helpers.py (contains _is_absolute_path)
  • Modified: backend/secuscan/plugins.py (re-exports from plugins_helpers)
  • New file: testing/backend/unit/test_plugins_is_absolute_path.py (7 tests)

Impact it Made:
Improves test coverage for a security-critical path validation helper. Ensures the function correctly identifies absolute paths on different OSes, preventing potential security bypasses in plugin path resolution.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Rakshak05 and others added 30 commits June 30, 2026 08:45
utksh1#1398

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
- 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.
…1546)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…h1#1542)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
namann5 and others added 25 commits July 17, 2026 15:48
The dev workflow in start.sh advertises /docs, /redoc, and
/openapi.json but never sets SECUSCAN_DEBUG. With the new default
of debug=False, these routes 404 unless developers manually set
the env var. Export SECUSCAN_DEBUG=true before launching uvicorn
so the dev server has full API docs and hot-reload.
Fix two issues flagged by the bot review:

1. Debug guard check: The original logic used content.split(line) which
   incorrectly sliced strings. Replace with proper backward scan that
   checks the 10 lines above traceback.format_exc for an
   if-settings.debug guard.

2. Secret scan regex: Replace character class quoting with hex-escaped
   patterns to avoid YAML/Python shell quoting conflicts that caused
   SyntaxError. Also simplify the POSTGRES_PASSWORD pattern.

All f-string interpolations replaced with .format() to avoid nested
quote escaping issues in YAML run blocks.
…-parser-validation

fix(plugins): enforce strict validation and integrity checks for missing custom parser utksh1#1812
…to ID generation

Addresses Bandit HIGH severity findings:
- finding_intelligence.py:75 - stable ID generation
- platform_resources.py:29 - asset ID generation

These SHA1 usages are for deterministic hashing to create stable IDs,
not for cryptographic security purposes. Adding usedforsecurity=False
clarifies the intent and resolves the security linter warnings.
The debug default was changed from True to False in the security fix.
Update the test to match the new secure default.
The saved_views_router now has require_api_key dependency.
Override it in tests to bypass authentication for unit testing.
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.
@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 Jul 30, 2026 — with ChatGPT Codex Connector
@utksh1 utksh1 closed this Aug 15, 2026
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 : add unit tests for _is_absolute_path helper