Skip to content

Add UploadSource header to Partner Center Ingestion API requests#120

Merged
RafaelHinojosa merged 1 commit into
mainfrom
users/rafaelh/UploadSource-PackageUploaderCLI
May 14, 2026
Merged

Add UploadSource header to Partner Center Ingestion API requests#120
RafaelHinojosa merged 1 commit into
mainfrom
users/rafaelh/UploadSource-PackageUploaderCLI

Conversation

@RafaelHinojosa
Copy link
Copy Markdown
Collaborator

Adds an UploadSource HTTP header to every Partner Center Ingestion API request made by PackageUploader CLI. This enables server-side telemetry to distinguish which tool originated a given API call.

New file

  • UploadSourceConfig.cs — Internal config class with PackageUploaderSource constant, case-insensitive allowlist, and
    IsAllowedValue() validation. Fully documented with XML doc comments.

Modified files

  • HttpRestClient.cs — Validates the upload source against the allowlist in the constructor; adds the UploadSource header in
    CreateJsonRequestMessage().
  • IngestionHttpClient.cs — Accepts UploadSourceConfig as a 4th constructor parameter, passes it to the base class.
  • PackageUploaderExtensions.cs — Registers UploadSourceConfig as a singleton in DI. Adds an optional uploadSource parameter (defaults to "PackageUploader").

Tests

  • 5 unit tests — default value, config value, empty fallback, unknown rejection, whitespace trimming.
  • 37 adversarial tests — CRLF injection, null bytes, SQL injection, XSS, SSTI, Log4Shell, Unicode homoglyphs, buffer overflow,
    header duplication, and more.

Design decisions

  • Allowlist validation — Only pre-approved values are sent on the wire. Unknown values silently fall back to "PackageUploader"
    (no exceptions), consistent with the existing IngestionSdkVersion pattern.
  • Scope — Header is added only to Partner Center metadata API requests (HttpRestClient). XFUS binary upload calls are unaffected.
  • Future extensibility — Adding XGPM as a source requires only adding a constant + allowlist entry + passing it at the DI call
    site.

Testing
All 464 tests pass (59 ClientApi + 66 Application + 339 UI + 4 Real HTTP tests not included).

@RafaelHinojosa
Copy link
Copy Markdown
Collaborator Author

@microsoft-github-policy-service agree company="Microsoft"

@RafaelHinojosa RafaelHinojosa marked this pull request as ready for review May 13, 2026 19:45
@RafaelHinojosa RafaelHinojosa force-pushed the users/rafaelh/UploadSource-PackageUploaderCLI branch from 6c24ef1 to 1f0edb9 Compare May 13, 2026 21:10
Identifies the calling tool ("PackageUploader") via an allowlisted HTTP header on every Partner Center request. Validated by a case-insensitive allowlist with silent fallback to the default value.
@RafaelHinojosa RafaelHinojosa force-pushed the users/rafaelh/UploadSource-PackageUploaderCLI branch from 1f0edb9 to 7c656a0 Compare May 14, 2026 21:25
@RafaelHinojosa RafaelHinojosa merged commit 9e03de3 into main May 14, 2026
7 checks passed
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.

3 participants