Skip to content

XRAY-129161 - Send curation audit id in headers for email batching - #897

Merged
gauriy-tech merged 2 commits into
jfrog:devfrom
gauriy-tech:feature/XRAY-129161-add-jf-ca-id
Sep 29, 2026
Merged

gauriy-tech merged 2 commits into
jfrog:devfrom
gauriy-tech:feature/XRAY-129161-add-jf-ca-id

Conversation

@gauriy-tech

@gauriy-tech gauriy-tech commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

jf curation-audit sends per-request X-Artifactory-Curation-* headers so Xray can identify and batch its curation-audit traffic on the server side:

  • X-Artifactory-Curation-Run-Id (Go constant: CurationAuditIdHeader): a UUID generated once per Run() invocation, threaded through every curation HTTP request (main audit tree, waiver requests, CVS/npm-log fallback paths) via a new ca.createHttpClientDetails() helper. Xray correlates all requests sharing one audit ID and batches its blocked-package email notifications into a single message per jf ca run instead of one email per package.
  • X-Artifactory-Curation-Source: jf-curation-audit: identifies traffic as coming from jf curation-audit specifically (as opposed to a plain package download), independent of the on-demand/cache path Artifactory routes it through. Sent unconditionally on every curation request (main path and the npm curation-probe fallback), since it identifies the caller rather than a specific run.
  • uuid.New() -> uuid.NewRandom(): uuid.New() panics on an entropy-read failure; NewRandom() surfaces the same failure as a normal, handleable error instead, so a rare OS-level hiccup cannot crash the whole jf ca invocation.

Why

Xray previously had no way to associate multiple package-check requests from the same jf ca invocation, so a run blocking N packages sent N separate notification emails. The audit ID lets Xray's backend batch these into one email per run. The Source header separately lets Xray's audit trail classify jf ca traffic as its own event-origin category, distinct from real package downloads.

Test plan

  • go build ./... passes
  • go vet ./... / go fmt ./... clean
  • New unit tests: TestRunGeneratesAuditIdForHttpDetails, TestSendWaiverRequestsSendsCurationAuditIdHeader, TestCreateHttpClientDetails_AuditIdHeaderOmittedWhenEmpty (also covers the Source header), TestProbeBlockedPnpmDirectDepsSendsCurationAuditIdHeader
  • Manually verified end-to-end against a local Xray/Artifactory: header reaches Xray's package_status handler and correlates the batched notification email

Screenshots of before/after are on the Jira ticket: https://jfrog-int.atlassian.net/browse/XRAY-129161

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 82cadd04-dbda-46a5-b8d3-536b4ebeeb12

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-129161-add-jf-ca-id branch from 49150f6 to cdc16b6 Compare September 24, 2026 04:51
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Sep 24, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 24, 2026
@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-129161-add-jf-ca-id branch from adaafc4 to b8825ee Compare September 28, 2026 05:39
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Sep 28, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 28, 2026
@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-129161-add-jf-ca-id branch from 7a7dc5a to 5547020 Compare September 28, 2026 07:17
@Phavya-jfrog

Copy link
Copy Markdown
Contributor

This simple-index GET (buildPoetryDownloadUrlsMap/buildPipenvDownloadUrlsMap in sca/bom/buildinfo/technologies/python/python.go:289/501) never receives the run's audit ID, unlike the npm/yarn probe this PR updated — while the actual curation block/allow decision for Poetry/Pipenv already carries the header via the shared treeAnalyzer, this GET hits the same simple-index endpoint that CVS enforces against (see python_cvs_fallback.go's CvsBlockedError doc comment), so it's plausible this touchpoint also matters for the batching the header exists for. Worth confirming with the Xray/CVS backend side whether this GET needs the header too; if so, consider threading params.AuditId through both functions the same way npm's curationprobe.go does (if auditId != "" { ... }).


Review generated by xray-pr-review

Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
@Phavya-jfrog

Copy link
Copy Markdown
Contributor

The description here is the unmodified checklist template (all boxes unchecked) with just a link to the Jira ticket for screenshots. Consider adding a short summary of what changed (audit-ID header threading, panic-safety of ID generation) and why (Xray email-batching correlation), so reviewers and future readers don't need to reconstruct intent from the diff alone.


Review generated by xray-pr-review

@Phavya-jfrog

Copy link
Copy Markdown
Contributor

pnpm.go's probeBlockedPnpmDirectDeps delegates to the same shared npm.ProbeBlockedDirectDeps that yarn's equivalent calls, which already forwards AuditId correctly (curationprobe.go:298-300) — no bug here. yarn_test.go got a new TestProbeBlockedDirectDepsSendsCurationAuditIdHeader asserting this for yarn; consider adding the pnpm-side equivalent too, so the shared behavior stays guarded on both sides if either wrapper is ever refactored to stop delegating.


Review generated by xray-pr-review

@Phavya-jfrog

Copy link
Copy Markdown
Contributor

The auditId field comment says it's "generated once per Run(), shared across every --working-dirs project in that invocation" — but no test verifies that claim. Note: a naive test that just calls Run() with empty temp dirs and checks ca.auditId is a valid UUID afterward won't actually prove sharing — with no dependency manifest present, Run() makes zero HTTP calls (confirmed by re-running the existing TestRunGeneratesAuditIdForHttpDetails, which relies on exactly that empty-dir/no-op path). A real regression test would need two working dirs, each with a manifest pointing at a shared mock server, asserting the captured header value is identical and non-empty across both requests.


Review generated by xray-pr-review

@gauriy-tech

Copy link
Copy Markdown
Collaborator Author

Verified this manually: ca.auditId is assigned once before Run()'s per---working-dirs loop and never touched inside it, so sharing is correct by construction. Confirmed end-to-end too — ran jf ca --working-dirs=.,child-project against a local Xray/Artifactory; one audit ID logged for the whole invocation, and both projects' rows landed under it in the DB.

Skipping an automated test for this specific claim: a real one needs Run()'s actual loop (the existing harness calls doCurateAudit() directly, bypassing auditId generation) with real npm/yarn/pnpm subprocess execution — disproportionate for a guarantee that's already trivially true by inspection. Leaving as a known gap.

@Phavya-jfrog

Copy link
Copy Markdown
Contributor

One thing worth confirming before merge: the description and test-plan say "Manually verified end-to-end against a local Xray/Artifactory: header reaches Xray's package_status handler" for X-Artifactory-Curation-Audit-Id — but the header that's actually shipping here is X-Artifactory-Curation-Run-Id (utils/paths.go:33). Git history shows the string was renamed from Audit-Id to Run-Id partway through this PR, and the description's E2E claim wasn't updated to match — the timing suggests the description was last touched after the rename, so it's possible the E2E check that's cited was run against the old string and never re-verified against Run-Id.

Could you confirm: (1) was the E2E test re-run against the current X-Artifactory-Curation-Run-Id value, and (2) does Xray's backend actually key its batching off that string? If not, the batching feature could ship working against nothing. Separately, the Go constant name CurationAuditIdHeader still doesn't match its own Run-Id value — worth renaming for clarity either way.


Review generated by xray-pr-review

@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Sep 29, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@gauriy-tech gauriy-tech added the improvement Automatically generated release notes label Sep 29, 2026
@gauriy-tech

Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

@attiasas attiasas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@gauriy-tech
gauriy-tech merged commit 7217672 into jfrog:dev Sep 29, 2026
74 of 77 checks passed

This branch was previously deployed

1 inactive deployment
frogbot — a9a03705 Deployed Sep 29, 2026 by gauriy-tech via scan-pull-request #4616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants