Skip to content

Prioritize readability in security/detect-object-injection cleanup#2106

Merged
pmcelhaney merged 9 commits into
mainfrom
copilot/reduce-security-detect-object-injection-warnings-again
May 23, 2026
Merged

Prioritize readability in security/detect-object-injection cleanup#2106
pmcelhaney merged 9 commits into
mainfrom
copilot/reduce-security-detect-object-injection-warnings-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

Summary

This PR now takes a readability-first approach to security/detect-object-injection handling.

  • Rolled back the broad refactors that introduced readability-unfriendly Reflect/Object.entries/switch-based rewrites in runtime, REPL, generator, and related tests.
  • Kept simple, low-risk hardening where it remains clear and maintainable (for example, known-key guarding for CLI config merge and targeted trusted-dynamic access documentation).
  • Explicitly accepts remaining object-injection warnings in places where a clean, simple fix is not available without harming readability.
  • Preserves existing behavior for CLI resolution, route dispatching, REPL flows, and generator/runtime interactions.
Original Prompt

Reduce security/detect-object-injection warnings by replacing ambiguous dynamic object indexing with safer access patterns or documenting trusted usage.

Context and motivation

Many warnings come from map-like structures and route/context registries where dynamic keys are expected. We need a consistent pattern for safe keyed access so this rule remains useful.

Acceptance criteria

  • All current security/detect-object-injection warning sites are triaged
  • Risky dynamic lookups are refactored (for example, validated key guards or Map usage)
  • Remaining suppressions include clear justification for why access is safe
  • Net warning count for this rule is reduced

Manual acceptance tests

  • Running yarn lint shows no new readability-unfriendly refactor patterns (Reflect/Object.entries/switch rewrites) introduced by this PR, and object-injection warnings remain only in accepted locations.
  • Starting the CLI with a config file containing unknown keys does not fail, ignores unknown keys, and keeps CLI-provided options taking precedence.
  • REPL .scenario completion and scenario invocation still resolve valid group/file/function targets and reject invalid targets with existing error behavior.
  • Request parameter coercion and exploded object query reconstruction behavior remains unchanged for known OpenAPI parameter locations.
  • Response/example generation still resolves status/content/example values from OpenAPI response dictionaries as before.

Tasks

  • Triaged warning-related changes and identified patterns flagged as readability regressions.
  • Reverted readability-unfriendly Reflect/Object.entries/switch rewrites across affected runtime/REPL/generator/test files.
  • Retained only clear, maintainable fixes and targeted trusted-dynamic documentation.
  • Ran lint, targeted tests, build, and full test suite validation after rollback.
  • Updated PR discussion with the follow-up commit implementing the rollback.

Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
4 tasks
Copilot AI changed the title [WIP] Refactor code to reduce security/detect-object-injection warnings Reduce security/detect-object-injection warnings with safer keyed access patterns May 22, 2026
Copilot AI requested a review from pmcelhaney May 22, 2026 23:42
Copy link
Copy Markdown
Collaborator

@pmcelhaney pmcelhaney left a comment

Choose a reason for hiding this comment

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

@copilot Reflect.set() makes the code harder to read. Can't these objects be turned into Maps instead?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 23, 2026

@copilot Reflect.set() makes the code harder to read. Can't these objects be turned into Maps instead?

Updated in 5bb8d56: I removed Reflect.set usage and switched to clearer patterns (direct assignment with tightly scoped, justified suppressions where keys are trusted, plus Map usage where it improved clarity). I also deduplicated the repeated test export-tracking writes into a helper to keep the suppression scope minimal.

Copilot AI changed the title Reduce security/detect-object-injection warnings with safer keyed access patterns Reduce security/detect-object-injection warnings with clearer keyed access patterns May 23, 2026
Copilot AI requested a review from pmcelhaney May 23, 2026 00:27
Copy link
Copy Markdown
Collaborator

@pmcelhaney pmcelhaney left a comment

Choose a reason for hiding this comment

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

@copilot I don't like the changes that use Reflect or Object.entries. If there's not a simple way to address lint warnings in those cases we'll just live with the warning.

Also I don't like the switch statement.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 23, 2026

@copilot I don't like the changes that use Reflect or Object.entries. If there's not a simple way to address lint warnings in those cases we'll just live with the warning.

Also I don't like the swit...

Updated in 6db77f9. I reverted the readability-unfriendly refactors that introduced Reflect/Object.entries/switch-based rewrites in the affected files and restored the simpler prior implementations, accepting the related lint warnings in those spots.

Copilot AI changed the title Reduce security/detect-object-injection warnings with clearer keyed access patterns Prioritize readability in security/detect-object-injection cleanup May 23, 2026
Copilot AI requested a review from pmcelhaney May 23, 2026 00:39
@pmcelhaney pmcelhaney marked this pull request as ready for review May 23, 2026 01:09
@pmcelhaney pmcelhaney enabled auto-merge May 23, 2026 01:09
@pmcelhaney pmcelhaney added this pull request to the merge queue May 23, 2026
Merged via the queue into main with commit 5b4ce6c May 23, 2026
8 of 10 checks passed
@pmcelhaney pmcelhaney deleted the copilot/reduce-security-detect-object-injection-warnings-again branch May 23, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce security/detect-object-injection warnings

2 participants