Skip to content

Add shared path-under-base helper and migrate Path.Combine test usages #452

Closed

Description

@akrock

Summary

PR #449 added TestPathUtils.PathUnder(...) and TestPathUtils.RelativePath(...) in Web/ForgeTrust.AppSurface.Docs.Tests to avoid recurring CodeQL feedback where Path.Combine(...) may silently drop earlier arguments when a later segment is rooted.

This follow-up should find the existing test usages that still compose paths with multi-argument Path.Combine(...), decide the right shared home for the helper, and migrate the obvious call sites.

Why

The same review feedback has come back multiple times:

  • Path.Combine(base, dynamicSegment, child) can reset to dynamicSegment if it is rooted.
  • Review fixes are easy one-offs, but repeated one-offs make tests inconsistent.
  • A named helper expresses intent better: “build this known-relative path under this base”.

Suggested Scope

  • Inventory Path.Combine(...) usage in test projects first.
  • Promote the docs-test helper into a broader shared test utility if multiple test assemblies need it.
  • Use the helper for “path under base + relative segments” cases.
  • Leave legitimate Path.Combine(...) calls alone when they are not susceptible to rooted dynamic segments or when production code intentionally relies on framework semantics.
  • Add/keep tests that prove rooted relative segments are rejected rather than silently resetting the base.

Starting Point

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions