Repository navigation
ci: enforce public-content rules with an intranet link check - #2635
AlexStocks wants to merge 11 commits into
Conversation
Written rules from #2634 rely on a manual grep. Add scripts/check_public_content.py, wire it into pre-commit (CI runs prek via make check -> workflow-actions-check), add regression tests and a PR checklist for names that cannot be matched mechanically, and point CONTRIBUTING.md / AGENTS.md / both RFC READMEs at the enforced command. No runtime or API change.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Scope and limits of this gate This PR is the enforcement layer for the two earlier ones: #2633 removed the link, #2634 wrote the rules, and this one makes the mechanically detectable part fail CI rather than depending on a contributor remembering a self-check command. Three things the gate intentionally does not cover, so reviewers know what still needs human attention:
To extend coverage, add a suffix to Validation performed locally: 4 pytest tests passed; ruff check/format and ty check clean; |
Fix the P1 false negative from self-review: the host capture now accepts only URL-authority characters, so CJK punctuation, full-width delimiters and Markdown backticks no longer become part of the hostname. Add regression tests for those forms and for public links next to the same delimiters. Fix P2 by stating the fixed INTERNAL_HOST_SUFFIXES list in CONTRIBUTING.md, AGENTS.md and both RFC READMEs, including what still needs a manual read.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…d files Second self-review found that a UnicodeDecodeError skipped a whole legacy-encoded text file, files over 4 MB were skipped, and skipped files were still counted as checked, producing a misleading success message. Decode text lossily, report scanned and skipped counts separately, state the remaining detection boundaries in the rule documents, and add two regression tests plus four mutation counter-proofs. Split scanning into scan_files() to satisfy the C901 complexity limit.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
hireview001
left a comment
There was a problem hiding this comment.
- CI failed: CI result (failure).
- CI failed: desktop-validation / linux (failure).
- CI failed: cindy-package (failure).
- CI failed: dsh-package (failure).
- CI failed: Main (failure). Failed steps: dsh-package / Test DSH package; cindy-package / Build and test the standalone Cindy archive; desktop-validation / linux / Run cargo clippy --locked --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
CI rerun after a base update The failures in run 43467000459 were not caused by this PR. Its eight files are documentation, a pre-commit hook, a checker script, and its tests; none of them touch the TypeScript bundles or the Rust desktop crate. All three failing jobs came from the old base 9924bb4:
I used Update branch to merge master into this branch (c18f347). The diff against the new base is still exactly the same eight files, both bundle blobs now match master byte-for-byte, and the return is gone. Run 43555935194 was triggered on the updated head; CI preflight (including prek run -a and the new check-public-content hook), docs-tests, check-website, and website-link-validation-windows have passed so far. |
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed c18f3476b6eda2edf85c80e1d11e619b8fa2c46c. Requesting changes for the unresolved URL-authority parsing defect: the configured hook reports success for a prohibited hostname when userinfo contains +. I added the hook-level reproduction to the existing thread.
`URL_RE` captured only `[A-Za-z0-9._:@-]+`, so a userinfo sub-delimiter (`+ ! $ & ' ( ) * , ; =`), a `~`, or a percent-encoded password truncated the match before the host. The suffix check then ran on the userinfo: a public document URL with `user+tag@` in front of a listed intranet host produced the finding candidate `user`, matched no suffix, and was accepted, while the same link without userinfo was rejected. The capture now stops at `/ ? #` or whitespace, and `hostname_of()` keeps the leading DNS-label run of the authority after splitting off the userinfo. Ports, trailing dots, CJK punctuation, brackets, quotes and backticks are dropped by that prefix instead of by narrowing the character class, so the existing punctuation and public-host guards keep passing unchanged. Coverage: 16 userinfo forms (sub-delimiters, password, percent-encoding, port), plus a guard that a public destination whose userinfo mentions an intranet host stays accepted and that lookalike hosts are still not matched.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Classify the public-content checker with its unit tests so future checker-only changes do not fall back to every CI suite. Keep the checker and existing regression coverage. Constraint: Shared pre-commit and CI policy changes still select full validation. Scope-risk: CI path selection only; no runtime or checker behavior change. Tested: 174 focused tests passed; Ruff and focused ty checks passed; checker scan and configured hook passed; checker-only routing selects tests. Full local prek remains blocked by Windows symlink materialization and POSIX-only APIs.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
The PR's e2e rerun timed out while Cargo fixtures waited for package-cache and artifact-directory locks. Download and compile the Gateway before starting pytest workers, then keep their incremental Cargo checks offline. Constraint: Preserve the Gateway behavior, acceptance assertions and fixture deadlines. Scope-risk: CI setup only; failed cold builds stop before tests instead of surfacing as fixture timeouts. Tested: Gateway cargo build --locked; WSL Python 3.13 pytest -n 4 tests/e2e/test_gateway_authentication.py tests/e2e/test_gateway_http1_lifecycle.py -k 'not earlier_request' -q (40 passed); checker and CI-selector tests (174 passed); YAML, whitespace and public-content hooks; git diff --check.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Two runs with 32 workers on the same head missed service startup, request, and spawned-worker deadlines. Use eight workers for the Python 3.12 e2e job via the existing Makefile setting. Constraint: Keep the existing cases and their deadlines. Scope-risk: Python 3.12 e2e may take longer on well-provisioned runners. Tested: The ten cases that failed in attempt 2 passed on Linux with Python 3.12 and pytest -n 8. Checked workflow YAML and make -n e2e-test with and without PYTEST_WORKERS=8.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
The topic worker timed out under 32 xdist workers on both Python 3.11 and 3.12. Apply the eight-worker setting to every e2e job and retain each matrix result. Constraint: Preserve all tests and deadlines. Scope-risk: Lower e2e concurrency and allowing matrix jobs to finish can increase CI time on some runs. Tested: Parsed workflow YAML, verified the Makefile worker override, and ran the ten failed scenarios from run 44840366770 attempt 2 with pytest -n 8 on Linux.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Unit jobs on all four Python versions hit child-process deadlines at 32 workers. Use the existing eight-worker limit for both suites. Run the Topic Memory head-conflict scenario serially after its 3.11 timeout at both 32 and eight workers. Constraint: Keep all cases and existing deadlines. Scope-risk: Smaller unit-test pools can take longer on unconstrained runners. Tested: Python 3.11 serial Topic Memory scenario and 12 representative unit failures on Python 3.12 with pytest -n 8 passed on Linux. Workflow YAML, make dry runs, and file hooks passed.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
hidb4ai
left a comment
There was a problem hiding this comment.
The previous userinfo and CI-path classification issues are fixed. Requesting changes for a new URL-boundary regression: markup following a pathless URL can now change the hostname being checked. Confirmed through both the standalone checker and the configured prek hook.
| # follow a bare URL in Chinese docs or Markdown inline code (full-width | ||
| # punctuation, brackets, quotes, backticks) is dropped by HOSTNAME_PREFIX_RE | ||
| # below rather than by narrowing this capture. | ||
| URL_RE = re.compile(r"https?://([^\s/?#]+)", re.IGNORECASE) |
There was a problem hiding this comment.
[P2] Bound the URL before interpreting userinfo
For url = "https://" + "yuque.antfin.com", a UTF-8 file containing f'<a href="{url}">contact@example.com</a>' now exits 0 and the configured prek hook passes; c18f3476 correctly rejected it. The capture includes ">contact@example.com<, so rsplit("@", 1) checks the link text's domain instead of the actual href. The inverse also regresses: a public GitHub href with an intranet email as its label is falsely rejected. Please establish the URL's markup/text boundary before removing userinfo, while preserving the newly fixed legal userinfo forms, and cover both directions with regression cases.
Which issue or RFC does this PR close?
No issue is closed. This follows the public-content rules in #2633 and #2634 and adds an automated check for the URL patterns that can be identified locally.
Rationale for this change
Public repository content must not depend on corporate intranet documents. Written rules and manual review remain necessary for customer names, private resources on public hosts, and unlisted domains. A local hostname check can catch common intranet links before they are merged without making network requests.
What changes are included in this PR?
scripts/check_public_content.py, a standard-library-only checker for HTTP(S) URLs whose hostname equals or is a subdomain ofantfin.com,alibaba-inc.com,alipay-inc.com, oraliyun-inc.com. It accepts explicit file paths or--allfor tracked files, reportspath:linediagnostics, and never rewrites content.make checkexecution already runsprek run -a, so no additional CI scan is needed.testsCI suite. Changes to shared pre-commit or CI policy still select full validation.AGENTS.md,CONTRIBUTING.md, and both RFC READMEs with the automated check and its limits. Add manual public-content and locale-parity checkboxes to the PR template.The checker matches four fixed host suffixes; it does not verify reachability or determine whether arbitrary content is public. Bare domains, protocol-relative links, binary or oversized content, other intranet domains, private document IDs, SSO-only spaces on public hosts, and external names still require manual review. Local examples such as
*.internal.exampleandhost.docker.internalremain allowed.Run the check directly with:
Are there any user-facing changes?
No runtime, API, dependency, or persisted-format change. Contributors receive a failing prek/CI check with file and line diagnostics for matched links, plus a count of files the checker could not scan.
How was this change tested?
Gateway CI setup validation on WSL/Linux (Python 3.13.14, Rust 1.95.0):
cargo build --locked --manifest-path gateway/Cargo.toml --target-dir gateway/target -p pc-gateway-app: passed.CARGO_NET_OFFLINE=true uv run --no-sync pytest -n 4 tests/e2e/test_gateway_authentication.py tests/e2e/test_gateway_http1_lifecycle.py -k 'not earlier_request' -q: 40 passed. These tests use real Gateway and Python Core processes with controlled local providers.RUSTFLAGSbecause the installed toolchain lacks its bundled linker. No repository linker or proxy configuration changed.git diff --checkpassed.Python 3.12 CI worker validation on WSL/Linux
Validation on the branch containing master
6763b07661846c19934044184995adf9183c28cc:uv run --no-sync pytest tests/test_check_public_content.py tests/test_ci_changes.py -q: 174 passed, including all 9 checker regression tests.uv run --no-sync ruff check --no-fix scripts/check_public_content.py tests/test_check_public_content.py: passed.uv run --no-sync ruff format --check scripts/check_public_content.py tests/test_check_public_content.py: passed.uv run --no-sync ty check --python-version 3.11 scripts/check_public_content.py tests/test_check_public_content.py: passed.uv run --no-sync python scripts/check_public_content.py --all: 3,932 files checked, 116 skipped, no matching URLs.uv run --no-sync prek run check-public-content --all-files: passed.scripts/check_public_content.pyselects exactlytests; the unclassified input selected all 32 suites before the rule was added.git diff --check: passed.Full local
prek run -awas attempted but did not pass on Windows: tracked observability symlinks are materialized as text, and the native-platform type check reports POSIX-only APIs. The hook's newline edits to those symlink placeholders were restored. A supplementary type check targeting Linux, excluding the unmaterializeddeploy/observability/stats-proxy.pysymlink, passed; this is not equivalent to a full Linux CI run. The pushed head triggers CI for validation in the supported runner environment.AI usage statement
WorkBuddy and OpenAI Codex assisted with the checker, regression tests, rule documentation, CI path classification, Gateway prebuild configuration, and validation. The commands reported above were executed locally and their outputs inspected.
Public content review
docs/en/anddocs/zh/carry the same wording and references.