8000 Feat: A/AAA record support by Meldiron · Pull Request #9627 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat: A/AAA record support #9627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 9, 2025
Merged

Feat: A/AAA record support #9627

merged 3 commits into from
Apr 9, 2025

Conversation

Meldiron
Copy link
Contributor
@Meldiron Meldiron commented Apr 8, 2025

What does this PR do?

Adds ipv4 and ipv6 support for custom domain verificaton. This allows apex domains without self-hosting entire nameserver.

Test Plan

  • Manual QA

CleanShot 2025-04-08 at 16 44 23@2x

CleanShot 2025-04-08 at 16 42 37@2x

CleanShot 2025-04-08 at 16 51 46@2x

Related PRs and Issues

x

Checklist

  • Have you read the Con 8000 tributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Summary by CodeRabbit

  • New Features

    • Enhanced domain configuration now supports separate settings for CNAME, IPv4, and IPv6 records, enabling more flexible custom domain management.
  • Bug Fixes

    • Improved domain validation ensures only valid configurations are accepted, providing clearer and more reliable error feedback.
  • Tests

    • Expanded test coverage verifies the new DNS record handling, ensuring robust validation across various domain setups.
    • Updated tests for the new domain validation logic and introduced new tests for the DNS validator.

Copy link
coderabbitai bot commented Apr 8, 2025

Walkthrough

This pull request restructures domain configuration and validation logic by replacing the single _APP_DOMAIN_TARGET variable with three distinct variables for CNAME, A, and AAAA records. Updates span environment files, configuration files, controllers, and tests. The domain validation process now leverages multiple validators (Domain, IP, and DNS) and consolidates error handling via an aggregated validator mechanism. Additionally, the DNS validator has been renamed and enhanced to support multiple DNS record types. Tests have been updated to reflect the new variable names and validation rules while removing legacy tests.

Changes

File(s) Change Summary
.env, docker-compose.yml Replaced _APP_DOMAIN_TARGET with _APP_DOMAIN_TARGET_CNAME, _APP_DOMAIN_TARGET_A, and _APP_DOMAIN_TARGET_AAAA in environment and service definitions.
app/config/variables.php, src/Appwrite/Utopia/Response/Model/ConsoleVariables.php Deprecated the old domain target variable and added new configuration rules for CNAME, A, and AAAA records.
app/controllers/api/console.php, app/controllers/api/proxy.php,
src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php,
.../Function/Create.php,
.../Redirect/Create.php,
.../Site/Create.php,
src/Appwrite/Platform/Tasks/Doctor.php,
src/Appwrite/Platform/Workers/Certificates.php
Updated domain validation logic: removed apex domain prevention, integrated Domain, IP, and DNS validators, and replaced single-check validations with aggregated multi-validator workflows.
src/Appwrite/Network/Validator/DNS.php Renamed class from CNAME to DNS, added constants for A, AAAA, and CNAME record types, and refactored constructor and validation logic to support dynamic DNS record handling.
tests/e2e/Services/Console/ConsoleConsoleClientTest.php,
tests/unit/Network/Validators/CNAMETest.php (removed),
tests/unit/Network/Validators/DNSTest.php
Adjusted tests to validate the new configuration and validation logic, including increased expected keys and string type checks for the new domain variables.

Sequence Diagram(s)

sequenceDiagram
    participant Client as API Client
    participant Ctrl as Controller
    participant DV as Domain Validator
    participant IPV as IP Validator
    participant DNSV as DNS Validator
    participant AnyOf as Aggregator Validator
    participant Resp as Response Document

    Client->>Ctrl: Request domain validation
    Ctrl->>DV: Validate _APP_DOMAIN_TARGET_CNAME
    DV-->>Ctrl: Domain validation result
    Ctrl->>IPV: Validate _APP_DOMAIN_TARGET_A and _APP_DOMAIN_TARGET_AAAA
    IPV-->>Ctrl: IPv4/IPv6 validation results
    Ctrl->>DNSV: Create DNS validators for CNAME, A, AAAA
    DNSV-->>Ctrl: Individual DNS validation outcomes
    Ctrl->>AnyOf: Aggregate validation results
    alt At least one validator passes
        AnyOf-->>Ctrl: Valid domain response
        Ctrl->>Resp: Return successful response with domain targets
    else No validators pass
        AnyOf-->>Ctrl: Aggregated error logs
        Ctrl->>Resp: Throw exception with error details
    end
Loading

Poem

Oh hops and bounds, my dear code friend,
Three new keys now make domain trends.
From CNAME to A and AAAA so bright,
Validations shine, easing our plight.
With DNS checks and IPs in stride,
I, the rabbit, cheer this joyful ride!
🐰✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7b6411 and dff1319.

📒 Files selected for processing (1)
  • tests/e2e/Services/Proxy/ProxyCustomServerTest.php (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/e2e/Services/Proxy/ProxyCustomServerTest.php (1)
tests/e2e/Services/Proxy/ProxyBase.php (1)
  • createAPIRule (25-35)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: E2E Service Test (Migrations)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Locale)
  • GitHub Check: E2E Service Test (Users)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Databases)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: Benchmark
  • GitHub Check: Unit Test
  • GitHub Check: E2E General Test
  • GitHub Check: scan
🔇 Additional comments (2)
tests/e2e/Services/Proxy/ProxyCustomServerTest.php (2)

56-59: Support for apex domains is well-implemented.

The test now validates apex domain support which aligns with the PR objective of enabling support for both IPv4 and IPv6 addresses in custom domain verification. The test correctly generates a unique apex domain (e.g., "uniqueid.com"), expects a successful creation (201 status code), and verifies the status is 'created'.

This change properly validates the new feature that allows using apex domains without requiring self-hosting an entire nameserver.


342-342: Domain format updated to match real-world use cases.

The change from .custom.localhost to .custom.com uses a more realistic domain format for testing, which better aligns with the domain verification system being enhanced in this PR. This is a good update that ensures tests reflect real-world domain handling scenarios.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
github-actions bot commented Apr 8, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (7)
app/config/variables.php (1)

100-126: Clarify in the docstring that at least one domain target is required.
Although the code checks for at least one of these environment variables to be set, each is marked as optional. Consider adding a line in each variable’s description indicating that at least one must be configured for custom domain setup to work.

 'description' => 'A domain that can be used as DNS CNAME record. 
+At least one of _APP_DOMAIN_TARGET_CNAME, _APP_DOMAIN_TARGET_A, or _APP_DOMAIN_TARGET_AAAA must be set 
 for proper domain validation.',
src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php (1)

115-132: Robust multi-record validation mechanism

The implementation correctly builds a flexible domain validation system that supports CNAME, A, and AAAA records. This enables apex domain validation without requiring nameserver setup, which aligns with the PR objectives.

Consider adding a brief comment explaining the purpose of the !$targetCNAME->isKnown() || $targetCNAME->isTest() condition for better maintainability.

 $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_TARGET_CNAME', ''));
+// Only validate CNAME if the target isn't a known domain or is a test domain
 if (!$targetCNAME->isKnown() || $targetCNAME->isTest()) {
     $validators[] = new DNS($targetCNAME->get(), DNS::RECORD_CNAME);
 }
src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php (1)

107-124: Enhanced domain validation with apex domain support

The implementation correctly enables apex domain validation by supporting A and AAAA records in addition to CNAME. The validation logic is consistent with the pattern used in the site rules creation.

Consider extracting this validation logic into a shared utility function since it's duplicated in both the API and Site Create classes.

app/controllers/api/console.php (1)

45-59: Comprehensive domain validation with multiple record types

The implementation validates all three DNS record types (CNAME, A, AAAA) and enables the domain feature if any of them are valid, which aligns with the PR objectives.

Consider extracting this validation logic into a helper method to avoid code duplication across different controllers and improve maintainability.

// Example helper function
function validateDomainTargets() {
    $validator = new Domain(System::getEnv('_APP_DOMAIN'));
    $isDomainValid = !empty(System::getEnv('_APP_DOMAIN', '')) && $validator->isKnown() && !$validator->isTest();
    
    $isCNAMEValid = false;
    $isAValid = false;
    $isAAAAValid = false;
    
    // CNAME validation
    $validator = new Domain(System::getEnv('_APP_DOMAIN_TARGET_CNAME'));
    $isCNAMEValid = !empty(System::getEnv('_APP_DOMAIN_TARGET_CNAME', '')) && $validator->isKnown() && !$validator->isTest();
    
    // A record validation
    $validator = new IP(IP::V4);
    $isAValid = !empty(System::getEnv('_APP_DOMAIN_TARGET_A', '')) && ($validator->isValid(System::getEnv('_APP_DOMAIN_TARGET_A')));
    
    // AAAA record validation
    $validator = new IP(IP::V6);
    $isAAAAValid = !empty(System::getEnv('_APP_DOMAIN_TARGET_AAAA', '')) && $validator->isValid(System::getEnv
8000
('_APP_DOMAIN_TARGET_AAAA'));
    
    return [
        'isDomainValid' => $isDomainValid,
        'isCNAMEValid' => $isCNAMEValid,
        'isAValid' => $isAValid,
        'isAAAAValid' => $isAAAAValid,
        'isDomainEnabled' => $isDomainValid && ($isAAAAValid || $isAValid || $isCNAMEValid)
    ];
}
app/controllers/api/proxy.php (1)

233-248: Prevent potential log overload
Aggregating logs from multiple DNS validators can produce very large output. Consider truncating or summarizing logs to avoid excessive log usage.

src/Appwrite/Platform/Workers/Certificates.php (1)

310-328: Single aggregator logic
Collecting logs from each DNS validator provides helpful debug info, but be mindful of log sizes. Consider truncating or summarizing if logs grow too large.

src/Appwrite/Network/Validator/DNS.php (1)

42-86: Robust DNS record matching
Using match expressions to dynamically check DNS record types is well-structured. However, DNS responses sometimes include trailing periods or variants in naming. Consider normalizing domain names before the check to handle such cases.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d205ea6 and 2689cce.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • .env (1 hunks)
  • app/config/variables.php (1 hunks)
  • app/controllers/api/console.php (3 hunks)
  • app/controllers/api/proxy.php (3 hunks)
  • docker-compose.yml (4 hunks)
  • src/Appwrite/Network/Validator/DNS.php (3 hunks)
  • src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php (3 hunks)
  • src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php (3 hunks)
  • src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php (3 hunks)
  • src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php (3 hunks)
  • src/Appwrite/Platform/Tasks/Doctor.php (2 hunks)
  • src/Appwrite/Platform/Workers/Certificates.php (3 hunks)
  • src/Appwrite/Utopia/Response/Model/ConsoleVariables.php (1 hunks)
  • tests/e2e/Services/Console/ConsoleConsoleClientTest.php (1 hunks)
  • tests/unit/Network/Validators/CNAMETest.php (0 hunks)
  • tests/unit/Network/Validators/DNSTest.php (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/unit/Network/Validators/CNAMETest.php
🧰 Additional context used
🧬 Code Definitions (4)
src/Appwrite/Platform/Tasks/Doctor.php (1)
src/Appwrite/Network/Validator/DNS.php (1)
  • isValid (48-86)
tests/unit/Network/Validators/DNSTest.php (1)
src/Appwrite/Network/Validator/DNS.php (2)
  • DNS (7-111)
  • isValid (48-86)
app/controllers/api/console.php (1)
src/Appwrite/Network/Validator/DNS.php (1)
  • isValid (48-86)
app/controllers/api/proxy.php (3)
src/Appwrite/Network/Validator/DNS.php (3)
  • DNS (7-111)
  • isValid (48-86)
  • getLogs (36-39)
src/Appwrite/Extend/Exception.php (1)
  • Exception (7-377)
src/Appwrite/Utopia/Response.php (2)
  • dynamic (596-629)
  • Response (131-862)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: E2E Service Test (Locale)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Users)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Migrations)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: Benchmark
  • GitHub Check: E2E General Test
  • GitHub Check: Unit Test
🔇 Additional comments (36)
tests/e2e/Services/Console/ConsoleConsoleClientTest.php (1)

27-30: Test updated to accommodate new domain target variables.

The test correctly accommodates the restructuring from a single _APP_DOMAIN_TARGET to three distinct variables (_APP_DOMAIN_TARGET_CNAME, _APP_DOMAIN_TARGET_A, and _APP_DOMAIN_TARGET_AAAA) that support different DNS record types. The assertion count has been properly incremented from 11 to 13, reflecting the addition of these new variables.

.env (1)

26-28: LGTM: Domain target split into record-specific variables.

The restructuring of the domain configuration from a single target variable to three record-specific variables enhances support for both IPv4 (A) and IPv6 (AAAA) addresses in addition to the existing CNAME record. Default values are appropriate - the previous CNAME value is preserved, and standard documentation/local addresses are used for IP targets.

docker-compose.yml (4)

118-120: Configuration updated for main appwrite service.

The environment variables for the main appwrite service have been properly updated to include all three domain target variables.


529-531: Worker certificates service updated with new domain targets.

The environment variables for the certificate worker service have been properly updated to support all three DNS record types, which is essential for domain verification and certificate management.


697-699: Worker migrations service updated with new domain targets.

The environment variables for the migrations worker service have been properly updated to support all three DNS record types.


731-733: Maintenance task service updated with new domain targets.

The environment variables for the maintenance task service have been properly updated to support all three DNS record types.

tests/unit/Network/Validators/DNSTest.php (4)

1-18: Well-structured test class setup for DNS validator.

The test class is properly organized with a clear namespace, appropriate imports, and standard setup/teardown methods. While the setup and teardown methods are currently empty, they provide a good structure for potential future enhancements.


19-27: Comprehensive CNAME record validation tests.

The test properly validates the CNAME record functionality against various input cases (empty, null, boolean) and both positive and negative DNS resolution cases.


29-38: Thorough A record validation tests with proper IPv4 documentation address.

The test correctly uses a documentation-purpose IPv4 address (203.0.113.1 from the TEST-NET-3 range) which is ideal for testing. The validation cases are comprehensive, covering edge cases and both positive and negative DNS resolution scenarios.


40-49: Complete AAAA record validation tests with proper IPv6 documentation address.

The test appropriately uses a documentation-purpose IPv6 address (2001:db8::1) and follows the same comprehensive testing pattern as the other record types, ensuring consistent validation across all DNS record types.

src/Appwrite/Platform/Tasks/Doctor.php (1)

18-18: No concerns on the added import statement.

app/config/variables.php (1)

93-93: Deprecation notice update looks correct.
You are correctly indicating that _APP_DOMAIN_TARGET is deprecated since version 1.7.0. No further issues here.

src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php (6)

8-8: Added import for DNS validator.
No concerns here.


22-22: Introduction of AnyOf validator.
Good approach to allow multiple record types simultaneously.


24-24: Added import for IP validator.
No issues.


115-126: Check the domain condition for _APP_DOMAIN_TARGET_CNAME.
You might have intended to validate only when the domain is known and not a test domain. The current condition if (!$targetCNAME->isKnown() || $targetCNAME->isTest()) { … } can invert your logic. Consider verifying correctness.

Would you like to confirm this condition is correct? If not, fix by changing it to something like:

-if (!$targetCNAME->isKnown() || $targetCNAME->isTest()) {
+if ($targetCNAME->isKnown() && !$targetCNAME->isTest()) {
     $validators[] = new DNS($targetCNAME->get(), DNS::RECORD_CNAME);
 }

127-129: Good catch for requiring at least one target.
This check enforces the user to have at least one valid _APP_DOMAIN_TARGET_* variable configured. No issues here.


131-131: AnyOf validator usage.
Nice solution to gather multiple validators into a single pass/fail check.

src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php (6)

8-8: Import DNS validator.
Straightforward addition; no issues.


21-21: Introduction of AnyOf validator.
Keeps logic consistent across domain checks. Approved.


23-23: Added IP validator import.
No concerns.


107-118: Verify the domain condition.
Similar potential issue as in the function rules: consider whether if (!$targetCNAME->isKnown() || $targetCNAME->isTest()) is correct or reversed.


119-121: At-least-one-target check.
Works well to ensure domain validation can proceed with a valid record.


123-123: AnyOf validator usage.
Same approach as the function rules. Looks good.

src/Appwrite/Utopia/Response/Model/ConsoleVariables.php (1)

13-30: LGTM: Well-structured DNS record target variables

The implementation adds support for three different DNS record types (CNAME, A, AAAA) by replacing the single _APP_DOMAIN_TARGET with three specific variables. This supports the PR objective of enabling apex domain verification through multiple DNS record types.

src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php (1)

8-24: LGTM: Appropriate imports for DNS validation

The new imports correctly support the enhanced domain validation mechanism with DNS and IP validation.

src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php (1)

8-24: LGTM: Appropriate imports for DNS validation

The new imports correctly support the enhanced domain validation mechanism with DNS and IP validation.

app/controllers/api/console.php (2)

11-13: LGTM: Required imports for enhanced validation

The Domain and IP validator imports are necessary for the improved domain validation mechanism.


70-72: LGTM: Updated response with all three DNS record targets

The response correctly includes all three DNS record target variables, which aligns with the PR objectives.

app/controllers/api/proxy.php (3)

7-7: Imports look correct
The new validators (DNS, AnyOf, IP) appear properly referenced and will be used in the updated domain verification logic.

Also applies to: 24-25


225-226: Minimum one domain target requirement
Good fallback to ensure that at least one domain target environment variable is configured before proceeding.


213-223:

❓ Verification inconclusive

Double-check domain condition
This block adds a DNS validator only if the CNAME target is unknown or is a test ((!$targetCNAME->isKnown() || $targetCNAME->isTest())). Verify if this is intentional, as one might expect domain validation to occur only for legitimate (known) domains instead.


🏁 Script executed:

#!/bin/bash
# Searching for references to domain->isKnown() or domain->isTest() in codebase
rg "->isKnown|->isTest"

Length of output: 430


Verify Domain Condition for DNS Validator

The current implementation adds a DNS validator when the CNAME target’s domain is either not known or marked as a test (i.e. using the condition (!$targetCNAME->isKnown() || $targetCNAME->isTest())). This is counterintuitive since one might expect domain validation to occur only for legitimate, known domains. However, our initial attempt to locate additional usage references for isKnown() and isTest() using a regular expression produced a shell error due to quoting issues. Please re-run the search (for example, using a command like the one below) and manually verify that this domain check is intentional and aligns with the overall validation strategy in the codebase.

  • File: app/controllers/api/proxy.php (lines 213-223)
  • Re-run Verification Script Example:
    #!/bin/bash
    # Corrected search for method usage with proper escaping
    rg "\-\>isKnown\s*\(" .
    rg "\-\>isTest\s*\(" .
  • Action: Confirm whether the use of (!$targetCNAME->isKnown() || $targetCNAME->isTest()) should indeed trigger the addition of a DNS validator or if the condition needs to be revised so that validation applies only to verified (known) domains.
src/Appwrite/Platform/Workers/Certificates.php (2)

11-11: Imports look correct
The new imports (DNS, AnyOf, IP) support the multi-record validation strategy and appear to be referenced appropriately.

Also applies to: 31-32


295-308:

❓ Verification inconclusive

Check domain validation condition
Similar to the Proxy controller, a DNS validator is added only if the CNAME target is unknown or is test. Confirm whether this condition is reversed or correct for production domains.


🏁 Script executed:

#!/bin/bash
# Searching for references to domain->isKnown() or domain->isTest() in codebase
rg "->isKnown|->isTest"

Length of output: 430


Confirm Domain Validation Logic for Production Domains

The current logic adds a DNS validator only when the CNAME target is either not recognized or flagged as a test domain:

if (!$targetCNAME->isKnown() || $targetCNAME->isTest()) {
    $validators[] = new DNS($targetCNAME->get(), DNS::RECORD_CNAME);
}

Please verify that this behavior is intentional and consistent with how validation is handled in the Proxy controller. In production, if the CNAME target is known and not a test environment, no DNS validator is added—confirm that this is as expected. If production domains require validation, the condition might need to be reversed. Manual verification is recommended due to the earlier regex issues encountered when searching the codebase.

src/Appwrite/Network/Validator/DNS.php (2)

7-11: New constants for multiple DNS record types
Defining RECORD_A, RECORD_AAAA, and RECORD_CNAME greatly expands flexibility beyond handling just CNAME records.


21-21: Enhanced constructor and generic description
Allowing the constructor to specify record type (with a default of CNAME) and providing a broader "Invalid DNS record" message is a clean, extensible design.

Also applies to: 30-30

Copy link
github-actions bot commented Apr 8, 2025

✨ Benchmark results

  • Requests per second: 934
  • Requests with 200 status code: 168,214
  • P99 latency: 0.199264126

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 934 1,262
200 168,214 227,272
P99 0.199264126 0.146740534

@Meldiron Meldiron merged commit 2be7e1e into feat-sites Apr 9, 2025
32 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 16, 2025
3 tasks
@ItzNotABug ItzNotABug deleted the feat-a-record branch May 20, 2025 13:56
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.

2 participants
0