[468][592] Populate NCMEC reports with the ipAddress schema field role#641
[468][592] Populate NCMEC reports with the ipAddress schema field role#641juanmrad wants to merge 1 commit into
ipAddress schema field role#641Conversation
📝 WalkthroughWalkthroughThis PR extends NCMEC reporting to capture IP addresses from configured item type field role mappings. When users and media items have an ChangesNCMEC IP address to capture events
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
This PR completes ipAddress schema field role support for NCMEC submissions by carrying role-derived IPs from reported users and media into CyberTip payloads while preserving Additional Info webhook data as the first source.
Changes:
- Adds role-derived
ipAddressextraction when building NCMEC report params from decisions. - Merges webhook, explicit param, and role-derived IP events into user and media NCMEC payloads.
- Adds unit coverage and updates NCMEC integration docs for the new behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
server/services/ncmecService/ncmecReporting.ts |
Adds IP event merging and applies role IPs to reported user and media submissions. |
server/services/ncmecService/ncmecReporting.test.ts |
Covers merge behavior, ordering, trimming, and empty-source handling. |
server/services/ncmecService/buildSubmitReportParamsFromDecision.ts |
Reads ipAddress schema field roles from user and media item data. |
server/services/ncmecService/buildSubmitReportParamsFromDecision.test.ts |
Adds regression coverage for role-derived user/media IP propagation. |
docs/integrations/ncmec.md |
Documents appended role-derived IP events in NCMEC submissions and webhook responses. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/integrations/ncmec.md (1)
216-216: 💤 Low valueAdd timestamp detail for consistency.
For consistency with line 350, consider mentioning the timestamp for the synthesized
Unknownevent. Line 350 states "as anUnknownevent at the report's incident time" which provides helpful clarity.📝 Suggested revision
- - `ipCaptureEvent`: IP addresses associated with the user (e.g. login, upload events), from your Additional Info endpoint. Providing IP data significantly improves NCMEC's ability to identify and locate the suspect. If the user item's item type maps the `ipAddress` schema field role, that IP is also appended as an `Unknown` event. + - `ipCaptureEvent`: IP addresses associated with the user (e.g. login, upload events), from your Additional Info endpoint. Providing IP data significantly improves NCMEC's ability to identify and locate the suspect. If the user item's item type maps the `ipAddress` schema field role, that IP is also appended as an `Unknown` event at the report's incident time.🤖 Prompt for 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. In `@docs/integrations/ncmec.md` at line 216, Update the ipCaptureEvent documentation to mention the timestamp for the synthesized `Unknown` event: when an item's `ipAddress` schema field role is appended as an `Unknown` event, state that it is created "at the report's incident time" (same phrasing used on line 350) so readers understand the event's timestamp; update the sentence that references `ipCaptureEvent`, `ipAddress`, and `Unknown` to include this timestamp detail for consistency.
🤖 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.
Nitpick comments:
In `@docs/integrations/ncmec.md`:
- Line 216: Update the ipCaptureEvent documentation to mention the timestamp for
the synthesized `Unknown` event: when an item's `ipAddress` schema field role is
appended as an `Unknown` event, state that it is created "at the report's
incident time" (same phrasing used on line 350) so readers understand the
event's timestamp; update the sentence that references `ipCaptureEvent`,
`ipAddress`, and `Unknown` to include this timestamp detail for consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7d8088a2-3837-4c13-b594-2dcdffb5047b
📒 Files selected for processing (5)
docs/integrations/ncmec.mdserver/services/ncmecService/buildSubmitReportParamsFromDecision.test.tsserver/services/ncmecService/buildSubmitReportParamsFromDecision.tsserver/services/ncmecService/ncmecReporting.test.tsserver/services/ncmecService/ncmecReporting.ts
julietshen
left a comment
There was a problem hiding this comment.
looks fine, left one comment about lint likely to fail
| ...paramEventsArray, | ||
| ]; | ||
| if (trimmedRoleIp !== '') { | ||
| events.push({ |
There was a problem hiding this comment.
this might fail linting
The repo enforces functional/immutable-data. I hit this rule on PR #643 and had to rewrite rows.push(...) to spread instead. Even though events is a fresh local array, the rule typically fires on the call site. Maybe:
const events: IPNCMECEvent[] = [
...(webhookEvents ?? []),
...paramEventsArray,
...(trimmedRoleIp !== ''
? [{ ipAddress: trimmedRoleIp, eventName: synthesisedEvent.eventName, dateTime: synthesisedEvent.dateTime }]
: []),
];
return events.length > 0 ? events : undefined;
| @@ -147,13 +153,20 @@ export async function buildSubmitReportParamsFromDecision( | |||
| if (createdAt === undefined) { | |||
There was a problem hiding this comment.
this is separate from your change but should we do format validation here? could add a Date.parse(createdAt) sanity check in a follow-up at some point
Fixes #468
Fixes #592
Context & Requests for Reviewers
Adopters can already tag User and Content items with the new
ipAddressschema field role from previous prs. This PR closes the loop by sending those IPs to NCMEC.When
buildSubmitReportParamsFromDecisionassembles a CyberTip payload it now reads theipAddressrole off the reported user and each reported media item.submitReportappends those IPs to<ipCaptureEvent>on the user (Unknownevent at the report's incident time) and on each file (Uploadat the media'screatedAt).The additional-info webhook stays the authoritative source. Its events come first, and the role IP is appended alongside, so adopters who haven't yet wired the webhook still get the reported IP into the submission.
If neither source has data, the element is omitted entirely as usual.
Summary by CodeRabbit
New Features
Documentation