Skip to content

chore(codeql): reconcile protected main into #2106 - #2195

Merged
seonghobae merged 1 commit into
fix/codeql-versioned-handler-bootstrapfrom
main
Sep 14, 2026
Merged

chore(codeql): reconcile protected main into #2106#2195
seonghobae merged 1 commit into
fix/codeql-versioned-handler-bootstrapfrom
main

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Ordinary non-force reconciliation of protected main@91be6442906c7b6b4f600272c953699708394327 into canonical CodeQL bootstrap branch fix/codeql-versioned-handler-bootstrap after #2194 advanced the protected base. This helper carries the protected-main Pingora/OpenCode artifact-path delta without changing #2106's seven-path canonical CodeQL repair. No predecessor check/review evidence transfers; #2106 must reacquire exact-head acceptance after this merge.


Devin Review

…2194)

Let a repository declare literal path prefixes in
.github/edge-policy-artifact-paths.txt that hold research/data
artifacts (SPSS .sav, serialized model objects, numeric arrays, ...)
not shaped like documentation, and admit binary content there on the
same evidence terms documentation paths already get.

Security property: evaluate_pull_request now threads an optional
base_ref and resolves the declaration only from that ref, never the
pull-request head, so a PR cannot self-authorize admission of its own
binary by adding or widening the declaration in the same diff. A new
test proves the same-PR case is refused. .github/workflows/opencode-
review.yml threads the pull_request_target event's already-available
github.event.pull_request.base.sha with no new permissions.

Suffix decision: a declared-prefix file whose suffix has no
BINARY_DOCUMENT_MAGIC entry (most research formats) is admitted only
on "no diff patch + fetched bytes are not valid UTF-8" evidence, so a
file that decodes as valid UTF-8 is always still content-scanned.
Runtime-named files (_runtime_path_rule) stay rejected inside a
declared prefix exactly as inside docs/ today.

Declaration parsing is bounded (64 entries, 8-segment depth) and
rejects absolute paths, ".." traversal, and globs with a PolicyError
naming the offending entry; a missing declaration file behaves
identically to before this feature existed.

pingora_edge_policy.py stays at 100% branch coverage and 100%
interrogate docstring coverage.

Refs #2193, #2149, #2116.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c93ace3b-448d-443c-8c18-6c01d7cd9583

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae merged commit 9defd52 into fix/codeql-versioned-handler-bootstrap Sep 14, 2026
19 of 31 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 5 potential issues.

Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Description understates functional scope

The description presents a reconciliation helper, while the diff changes organization-wide artifact admission and required-workflow behavior. Review evidence needs the functional policy scope.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +639 to +643
if suffix not in BINARY_DOCUMENT_MAGIC:
try:
raw.decode("utf-8")
except UnicodeDecodeError:
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Large declared artifacts remain blocked

Declared artifacts over 1 MiB never reach _binary_documentation_evidence_confirms's non-UTF-8 admission. The size exception admits only PDFs, so large SAV, RDS, and NPZ changes remain unmergeable.

Learn more

The Contents API stops inlining files above MAX_FILE_BYTES. In that case, _load_raw_file_bytes raises ContentSizeExceededError before these lines receive any bytes. The exception handler immediately above admits only .pdf, so the new declared-prefix path does not support large opaque research formats.

Example: A base declaration contains local, and a PR adds local/model.npz at 2 MiB. GitHub returns encoding: "none" and the accurate size. The scanner rejects the file instead of applying the declared non-UTF-8 artifact rule.

Recommended fix: For declared artifacts, follow the Contents response's blob SHA through the bounded Git Blobs API and apply the same UTF-8 test to those bytes. Preserve a hard upper bound and fail closed when the blob cannot be fetched or validated.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +61 to +65
# A base ref threaded into evaluate_pull_request may be either a branch name
# (e.g. "main", "release/2026.09") or a commit SHA -- whatever the calling
# workflow already has on the pull_request event without new permissions.
# Bounded charset/length, no ".." traversal, and no leading/trailing "/".
BASE_REF_RE = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9._/-]{0,253}[A-Za-z0-9])?$")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Valid base refs are rejected

BASE_REF_RE rejects valid branch names ending in - or _. evaluate_pull_request therefore fails before loading declarations from those documented refs.

Learn more

Git branch names may end in - or _; only a trailing slash and Git's other ref-format restrictions need rejection here. The regular expression instead requires an alphanumeric final character, despite evaluate_pull_request documenting branch names as supported base refs.

Example: A caller passes the valid branch release- as base_ref. Validation raises PolicyError("Pull-request base ref is malformed"), and no declaration or PR evidence is loaded.

Recommended fix: Validate the bounded character set independently from the no-leading-or-trailing-slash rule. Accept legal terminal characters such as - and _, while retaining the existing traversal and length checks.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +468 to +471
if isinstance(exc, HTTPError) and exc.code == 404:
raise ArtifactDeclarationNotFoundError(
f"GitHub API reported no resource for policy evidence at {url}"
) from exc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟥 Ambiguous 404s disable declarations

_github_open_json maps every 404 to declaration absence. A hidden repository or unavailable base ref silently removes its policy prefixes instead of failing closed.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +639 to +643
if suffix not in BINARY_DOCUMENT_MAGIC:
try:
raw.decode("utf-8")
except UnicodeDecodeError:
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟨 Opaque bytes bypass format validation

Any non-UTF-8 file under a declared prefix passes without format evidence. Broad declarations therefore admit arbitrary opaque payloads as research artifacts.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant