fix(directory): harden VMACS query construction#226
Conversation
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
=======================================
Coverage 44.49% 44.50%
=======================================
Files 895 895
Lines 51778 51783 +5
Branches 4834 4836 +2
=======================================
+ Hits 23041 23045 +4
- Misses 28165 28166 +1
Partials 572 572
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the Directory area’s VMACS lookup by URL-encoding the loginID value before it’s interpolated into the outbound query string, preventing reserved characters from altering the request.
Changes:
- Encode
loginIDviaUri.EscapeDataString(loginID ?? string.Empty)before building the VMACS query URL. - Remove a no-op
.ToString()call on an already-stringinterpolated value.
c372293 to
2767fcb
Compare
4a2c7c9 to
81e0601
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
📝 WalkthroughWalkthroughVMACSService now reads the VMACS AUTH token from configuration, URL-encodes ChangesVMACS trust query update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/Areas/Directory/Services/VMACSService.cs`:
- Around line 27-28: The URL construction in VMACSService is still embedded in
the lookup logic, so pull the request-building portion out into a small helper
method (for example, in the same service near the login lookup path) that takes
the login ID and returns the encoded query string. Then add focused tests
against that helper to cover null, spaces, +, &, and = cases so the
Uri.EscapeDataString behavior and request format in the lookup path are
independently verifiable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: bd9770b9-c6b2-4fcf-885c-070c57819dc7
📒 Files selected for processing (1)
web/Areas/Directory/Services/VMACSService.cs
- URL-encode the login ID (Uri.EscapeDataString) before interpolating it into the VMACS query URL so reserved characters can't alter the request. - Extract the fixed AUTH token into a named VmacsAuthToken constant instead of a magic literal in the URL string. - Drop a no-op .ToString() on the interpolated string. loginID is a DB-sourced campus login (low exploitability) and the AUTH token is a fixed internal-endpoint value, so this is hygiene/hardening, not a vulnerability fix.
Read the VMACS trust-endpoint AUTH token from the Credentials config section instead of a hardcoded constant, matching how DB and other secrets are sourced. Requires the Credentials:VmacsAuthToken value to exist in AWS SSM Parameter Store before deploy.
81e0601 to
b778bc5
Compare
Pull request-path construction out of Search into BuildSearchPath so the URL-encoding is unit-testable; add cases for null, spaces, +, &, and = to guard against encoding regressions. Also marks the shared HttpClient readonly.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/Areas/Directory/Services/VMACSService.cs`:
- Around line 56-60: BuildSearchPath currently escapes loginID but interpolates
authToken raw into the query string. Update the VMACSService.BuildSearchPath
method to URL-encode authToken the same way as encodedLoginId before composing
the AUTH parameter, so the generated search URL stays valid even if the token
contains reserved characters.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3ca30a2c-857d-46bb-ac12-ad21b0181103
📒 Files selected for processing (2)
test/Areas/Directory/VMACSServiceTest.csweb/Areas/Directory/Services/VMACSService.cs
06b8f8e to
b4f691e
Compare
Rework the advisory Development merge check so it fits how the team actually merges into Development: a direct `git merge` + push (npm run merge), not a PR. The old merged-PR detection never matched, so the check was meaningless. It is now a single red/green PR check: green when the head commit is in Development (detected by ancestry, with a merged-PR squash fallback), red when it is not. It re-evaluates on every PR commit, and a push-on-Development run re-runs any still-red PR so it flips to green once the branch lands there. Advisory only; it never blocks merging.
b4f691e to
fa5b4a6
Compare
|
@bsedwards This removes the hardcoded auth token from the VMACS API and also fixes the GitHub action to check whether a branch has been merged into Development. The check must be green/red and will block branches if they are not merged into Development first. |
What
Hardening changes to
VMACSService.Search, plus a rewrite of the advisory Development-merge CI check carried on this branch.VMACSService:Uri.EscapeDataString(loginID ?? string.Empty)before interpolating into the query URL, so reserved characters can't alter the request. Also drops a no-op.ToString().AUTHtoken from config. Read from theCredentials:VmacsAuthTokenconfig section (AWS SSM Parameter Store) instead of a hardcoded constant in source, matching how DB and other secrets are sourced.BuildSearchPath, covered by unit tests for thenull, space,+,&, and=encoding cases.Why
Both hardening items surfaced during the CodeQL/agy review work.
loginIDis a DB-sourced campus login (AaudUser.LoginId, passed by bothDirectoryControllercall sites), so exploitability is low. Moving theAUTHtoken out of source removes a hardcoded credential from version control and brings it in line with the rest of the app's secret handling.Deploy note
Requires the
Credentials:VmacsAuthTokenparameter to exist in AWS SSM Parameter Store (under/Shared/Credentials/) before this deploys. Until it does, VMACS phone/pager/unit enrichment in the Directory search returns empty (the endpoint still returns results). Verified on dev: a Directory search now shows the VMACS-sourced "M: ... (VMACS)" line, confirming the token loads from SSM and the lookup succeeds.CI: Development merge check
Unrelated to VMACS, but carried on this branch: a rewrite of the advisory
Development merge checkworkflow so it actually works for our flow.Why it was needed: we merge into Development with a direct
git merge+ push (npm run merge), not through a PR, so the old "find a merged PR into Development" detection never matched and the check was meaningless.Now: a single check per PR, green when the head commit is in Development (detected by ancestry, with a merged-PR squash fallback), red when it isn't. It re-evaluates on every PR commit, and because merging into Development adds no PR commit, a push-on-Development run re-runs any still-red PR so its check flips green once the branch lands there. Advisory only; it never blocks merging.
Scope note
The agy review also suggested reading the response stream directly instead of string→bytes→
MemoryStream, and a full static→DI refactor ofVMACSService. Those remain out of scope here; recommend a separate ticket for the static→DI refactor.