Skip to content

Adds automatic domain validation and allow-listing#2092

Open
bs-shobhitkumar wants to merge 29 commits intomasterfrom
PER_6583_auto_domain_validation
Open

Adds automatic domain validation and allow-listing#2092
bs-shobhitkumar wants to merge 29 commits intomasterfrom
PER_6583_auto_domain_validation

Conversation

@bs-shobhitkumar
Copy link
Contributor

@bs-shobhitkumar bs-shobhitkumar commented Jan 13, 2026

This pull request introduces a new auto domain allow-listing feature to the Percy client and core, enabling automatic validation and management of external domains accessed during snapshot capture. This helps streamline asset handling by validating domains against project configuration and an external service, and by persisting new discoveries for future builds. The implementation includes changes to both the core logic and the client API, as well as comprehensive tests for the new functionality.

The most important changes are:

Core logic for auto domain allow-listing:

  • Added a domain validation state to the Percy class, including sets for pre-approved, pre-blocked, session-allowed, and session-blocked domains, as well as statistics tracking. (packages/core/src/percy.js)
  • Integrated domain validation checks into the network layer, including logic to check project configuration, session cache, and an external validation service, with fail-open behavior on errors. (packages/core/src/network.js) [1] [2]
  • Updated resource handling to use domain validation results for both blocking and capturing resources. (packages/core/src/network.js) [1] [2]

Project domain configuration persistence:

  • Implemented methods in the Percy class to load project domain config at startup and save newly discovered allowed/blocked domains at shutdown, integrating with the Percy client API. (packages/core/src/percy.js) [1] [2] [3]

Percy client API enhancements:

  • Added a generic patch method and new methods updateProjectDomainConfig and validateDomain to the PercyClient class to support updating project domain configuration and validating domains via an external service. (packages/client/src/client.js) [1] [2]

Test coverage for new features:

  • Added comprehensive tests for updateProjectDomainConfig and validateDomain methods, including positive and negative scenarios and request payload validation. (packages/client/test/client.test.js, packages/client/test/helpers.js) [1] [2]

Wiring and context propagation:

  • Passed the domain validation context and client through the discovery and network layers to ensure the new logic is available where needed. (packages/core/src/discovery.js, packages/core/src/network.js) [1] [2]

}

// Executes domain validation via external service
async function executeDomainValidation(network, hostname, url, domainValidation, client, workerUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ideally move this to a different file - this file is getting too long with standalone functions

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