Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
722eaf3
Add Sourcepoint first-party integration
ChristianPavilonis Apr 8, 2026
494e919
Rewrite Sourcepoint script body so webpack chunks and API calls route…
ChristianPavilonis Apr 8, 2026
16aa02d
Fix 500: request uncompressed content from Sourcepoint CDN before scr…
ChristianPavilonis Apr 8, 2026
f8e069d
Inject head script to trap window._sp_ and rewrite Sourcepoint config…
ChristianPavilonis Apr 8, 2026
c4b26cb
Address review findings: scope Accept-Encoding, add logging, tighten …
ChristianPavilonis Apr 8, 2026
8594ea6
Fix Prettier formatting in Sourcepoint test file
ChristianPavilonis Apr 8, 2026
a211eb0
Remove geo.privacymanager.io support — not used by current publishers
ChristianPavilonis Apr 8, 2026
748fd39
Address blocking review findings: SSRF guard, dead code, Prettier
ChristianPavilonis Apr 10, 2026
d7913d5
Harden Sourcepoint proxy: UTF-8 safety, redirects, CORS, quote handling
ChristianPavilonis Apr 10, 2026
6d92a50
Clean up rewrite guard, add docs and validation tests
ChristianPavilonis Apr 10, 2026
205be64
Fix CodeQL URL sanitization alerts, add response body size guard
ChristianPavilonis Apr 10, 2026
bd71ea8
Address round-3 review: body-size guard, header preservation, redirec…
ChristianPavilonis Apr 14, 2026
e2fdb0c
Align sourcepoint flagging, validation, and rewrite response handling
ChristianPavilonis Apr 21, 2026
a4c0b6b
Reject query strings and fragments in sourcepoint CDN origin
ChristianPavilonis Apr 21, 2026
1a40868
Forward Sourcepoint cookies safely and disable caching for cookie res…
ChristianPavilonis Apr 22, 2026
e296d62
Merge branch 'main' into feature/sourcepoint-integration
ChristianPavilonis Apr 22, 2026
bec43a9
npm format
ChristianPavilonis Apr 22, 2026
a6ab10e
Merge branch 'feature/sourcepoint-integration' of github.com:IABTechL…
ChristianPavilonis Apr 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/js/lib/src/integrations/sourcepoint/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { log } from '../../core/log';

import { installSourcepointGuard } from './script_guard';

if (typeof window !== 'undefined') {
installSourcepointGuard();
Comment thread
ChristianPavilonis marked this conversation as resolved.
log.info('Sourcepoint integration initialized');
}
53 changes: 53 additions & 0 deletions crates/js/lib/src/integrations/sourcepoint/script_guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { createScriptGuard } from '../../shared/script_guard';

const SOURCEPOINT_CDN_HOST = 'cdn.privacy-mgmt.com';

function normalizeSourcepointUrl(url: string): string | null {
if (!url) return null;

const trimmed = url.trim();
if (!trimmed) return null;

if (trimmed.startsWith('//')) return `https:${trimmed}`;
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) return trimmed;

// Bare domain or path — attempt to parse as https URL.
// The host === check in isSourcepointUrl rejects non-matching domains.
return `https://${trimmed}`;
}
Comment thread
ChristianPavilonis marked this conversation as resolved.

function parseSourcepointUrl(url: string): URL | null {
const normalized = normalizeSourcepointUrl(url);
if (!normalized) return null;

try {
return new URL(normalized);
} catch {
return null;
}
}

export function isSourcepointUrl(url: string): boolean {
const parsed = parseSourcepointUrl(url);
return parsed?.host === SOURCEPOINT_CDN_HOST;
Comment thread
ChristianPavilonis marked this conversation as resolved.
Outdated
}

export function rewriteSourcepointUrl(originalUrl: string): string {
const parsed = parseSourcepointUrl(originalUrl);
if (!parsed) return originalUrl;

const query = parsed.search || '';

return `${window.location.origin}/integrations/sourcepoint/cdn${parsed.pathname}${query}`;
}

const guard = createScriptGuard({
displayName: 'Sourcepoint',
id: 'sourcepoint',
isTargetUrl: isSourcepointUrl,
rewriteUrl: rewriteSourcepointUrl,
});

export const installSourcepointGuard = guard.install;
export const isGuardInstalled = guard.isInstalled;
export const resetGuardState = guard.reset;
82 changes: 82 additions & 0 deletions crates/js/lib/test/integrations/sourcepoint/script_guard.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import {
installSourcepointGuard,
isGuardInstalled,
isSourcepointUrl,
resetGuardState,
rewriteSourcepointUrl,
} from '../../../src/integrations/sourcepoint/script_guard';

describe('Sourcepoint SDK Script Interception Guard', () => {
let originalAppendChild: typeof Element.prototype.appendChild;
let originalInsertBefore: typeof Element.prototype.insertBefore;

beforeEach(() => {
resetGuardState();
originalAppendChild = Element.prototype.appendChild;
originalInsertBefore = Element.prototype.insertBefore;
});

afterEach(() => {
resetGuardState();
});

it('detects Sourcepoint CDN URLs', () => {
expect(isSourcepointUrl('https://cdn.privacy-mgmt.com/wrapper/v2/messages')).toBe(true);
expect(isSourcepointUrl('//cdn.privacy-mgmt.com/mms/v2/get_site_data')).toBe(true);
expect(isSourcepointUrl('cdn.privacy-mgmt.com/consent/tcfv2')).toBe(true);
expect(isSourcepointUrl('https://example.com/script.js')).toBe(false);
expect(isSourcepointUrl('https://geo.privacymanager.io/')).toBe(false);
});

it('rejects subdomain-spoofing URLs', () => {
expect(isSourcepointUrl('cdn.privacy-mgmt.com.evil.com/script.js')).toBe(false);
expect(isSourcepointUrl('https://cdn.privacy-mgmt.com.evil.com/')).toBe(false);
expect(isSourcepointUrl('notcdn.privacy-mgmt.com/path')).toBe(false);
});

it('rewrites CDN URLs to the first-party proxy path', () => {
expect(rewriteSourcepointUrl('https://cdn.privacy-mgmt.com/wrapper/v2/messages?env=prod')).toBe(
`${window.location.origin}/integrations/sourcepoint/cdn/wrapper/v2/messages?env=prod`
);
});

it('installs and resets the guard', () => {
expect(isGuardInstalled()).toBe(false);
installSourcepointGuard();
expect(isGuardInstalled()).toBe(true);
expect(Element.prototype.appendChild).not.toBe(originalAppendChild);
expect(Element.prototype.insertBefore).not.toBe(originalInsertBefore);
resetGuardState();
expect(Element.prototype.appendChild).toBe(originalAppendChild);
expect(Element.prototype.insertBefore).toBe(originalInsertBefore);
});

it('rewrites dynamically inserted Sourcepoint scripts', () => {
installSourcepointGuard();

const container = document.createElement('div');
const script = document.createElement('script');
script.src = 'https://cdn.privacy-mgmt.com/wrapperMessagingWithoutDetection.js';

container.appendChild(script);

expect(script.src).toContain(
'/integrations/sourcepoint/cdn/wrapperMessagingWithoutDetection.js'
);
expect(script.src).not.toContain('cdn.privacy-mgmt.com');
});

it('does not rewrite unrelated scripts', () => {
installSourcepointGuard();

const container = document.createElement('div');
const script = document.createElement('script');
script.src = 'https://example.com/app.js';

container.appendChild(script);

expect(script.src).toBe('https://example.com/app.js');
});
});
2 changes: 2 additions & 0 deletions crates/trusted-server-core/src/integrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod nextjs;
pub mod permutive;
pub mod prebid;
mod registry;
pub mod sourcepoint;
pub mod testlight;

pub use registry::{
Expand All @@ -37,6 +38,7 @@ pub(crate) fn builders() -> &'static [IntegrationBuilder] {
permutive::register,
lockr::register,
didomi::register,
sourcepoint::register,
google_tag_manager::register,
datadome::register,
gpt::register,
Expand Down
Loading
Loading