Repository navigation
ci: harden deploy workflow (SHA-pinned actions + production approval gate) - #7
Merged
Merged
Conversation
- Pin actions/checkout and docker/setup-buildx-action to commit SHAs (with version comments) to harden against tag-hijack supply-chain attacks; the bump to current majors also clears the Node 20 runner deprecation warning. - Run the deploy job in the 'production' GitHub environment so an optional required-reviewer gate can front each deploy. Documented in the native deploy README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnmWqcAvNJzfuDtN2oxsC8
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens the existing GitHub Actions native SSH deploy pipeline by reducing supply-chain risk from third-party actions and enabling a GitHub Environment-based approval gate for production deploys.
Changes:
- Pin
actions/checkoutanddocker/setup-buildx-actionto immutable commit SHAs (with version noted in-line). - Bind the deploy job to the
productionGitHub Environment to allow environment protection rules (manual approval) to gate deploys. - Document the approval-gate setup and optional environment-scoped secrets/branch rules in
deploy/native/README.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
deploy/native/README.md |
Adds documentation for configuring a production environment approval gate and optionally scoping secrets/branches there. |
.github/workflows/deploy.yml |
Pins third-party actions to SHAs and sets environment: production on the deploy job to support manual approvals via environment protection rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+34
to
38
| # Approval gate: this job only runs once the `production` environment's | ||
| # protection rules are satisfied. Configure required reviewers under | ||
| # Settings -> Environments -> production for the gate to take effect. | ||
| environment: production | ||
| steps: |
Comment on lines
41
to
+42
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
aterga
pushed a commit
that referenced
this pull request
Jul 16, 2026
…rl mis-hints, unparsed-reply note Folds in the confirmed findings from an adversarial review of the Tier 0-1 diff (4 dimensions x per-finding verification). No high-severity findings; the security-guardrail dimension found nothing. - diagnose_empty_oql now takes an EmptyContext. On a FAILED result (trap / OQL error arm) it emits ONLY the #7 unknown-`start` repair, never the "came back empty => likely not authenticated" / "no entities here" notes — those describe an EMPTY result and would contradict a genuine error message. (Previously an anonymous query with a valid start that ERRORED got a misleading re-authenticate hint.) - diagnose_empty_oql distinguishes a FAILED schema re-read (entities: None) from a schema that genuinely lists no entities (Some([])), so a transient schema-read failure on an authenticated empty-table result no longer mislabels it "this account sees no entities" — it falls back to the benign "0 rows" note. - Dropped the "(or app_url)" hint for the OQL read tools in three places (the open_app data-access handle, the open_app description, and the server-instructions MY/OUR block): get_canister_oql_schema / run_canister_oql_query take only `derivation_origin`; `app_url` is call_canister's. Offering it sent the agent to a param those tools silently ignore -> an anonymous empty read. - The OQL Unrecognized-result arm now carries a structured `note` ("not an empty result; raw reply is in the text block"), so a structured-only consumer doesn't misread a non-tabular reply as "no data". - Fixed the candid_reply_is_empty doc to match the implementation: it recognizes `variant { none }` only; an explicit `variant { err = … }` is a real error, not "empty" (with a test assertion locking that contract in). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d
aterga
added a commit
that referenced
this pull request
Jul 17, 2026
…origin for OQL reads (Tiers 0–1) (#61) * Make per-app reads self-correcting: surface auth as the missing ingredient (Tiers 0-1) Anonymous per-app reads come back empty because the data is gated by the caller's principal, and nothing in the old tool surface signalled that authentication — not "no data" — was the missing ingredient. An agent asked a "my data in this app" question would read empty, guess bespoke method/entity names, and thrash before stumbling onto passing the app_url. This reworks the return payloads, error messages, capability flags, and the server-instructions playbook so the authenticated path is the obvious one and an empty read is self-explaining. Tier 0 #1 Empty reads now carry an auth signal. get_canister_oql_schema, run_canister_oql_query, and call_canister query results always echo is_anonymous (alongside acted_as_principal / derived_for_origin). When a read is anonymous AND empty, they append a note: empty here most likely means "not authenticated as your account", so re-run adding the origin. Computed only from local facts (anonymous && empty) — never by probing whether authenticated data exists — and the origin stays a placeholder the agent fills, never one guessed via app_url_default. Tier 1 #2 Rewrote the server-instructions playbook: open_app FIRST for a named app; a "my/our…" question is an authenticated read (pass the origin); anonymous per-app reads usually return empty and that's an auth artifact; call get_canister_api_doc only when candid says it's available; oql:true => reads via the OQL tools, call_canister is updates-only. Dropped the old "discover_app_canisters first" / "get_canister_api_doc FIRST" advice. #3 open_app / discover_app_canisters now probe each app-owned canister's Candid once (enrich_capabilities) and attach oql / api_doc_available flags plus a caller-gated data-access note bound to the resolved derivation_origin. Scoped by is_app_data_candidate to the app's own data canisters — never II/NNS/ledger/frontend — per the origin-resolution trust boundary. #4 get_canister_candid reports api_doc_available, computed with the same predicate get_canister_api_doc uses, so the api-doc call is gated on it. #5 The call_canister OQL-rejection message names the replacement path (icp_oql_guide -> get_canister_oql_schema -> run_canister_oql_query) and the auth hint (pass the origin for the user's own data). #6 get_canister_api_doc returns a structured result in every case (available/expected/retry/next), distinguishing an expected absence from an unreachable canister instead of one opaque error. #7 run_canister_oql_query validates the query's start entity on an empty result (validate-on-empty, not preflight) by re-reading the schema for the SAME principal, returning valid_entities + a did_you_mean repair (booking -> bookings). Hard-validates start only. #8 get_canister_oql_schema emits a ready-to-run run_canister_oql_query example per entity, each preserving the identity the schema was read under so copying one doesn't silently drop to anonymous. #9 Rewrote the OQL tool descriptions (guide->schema->query; entity names are often plural and differ from Candid; my-data => pass origin) and the OQL primer. Tests cover the new pure helpers (empty detection, entity extraction, did_you_mean, examples, conservative empty-reply detection, app-data-candidate scoping) and the enriched OQL-rejection message. Tier 2 (auto-authenticated reads / open_app_as_me) is left to a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d * Address adversarial review: fix empty-diagnosis on error paths, app_url mis-hints, unparsed-reply note Folds in the confirmed findings from an adversarial review of the Tier 0-1 diff (4 dimensions x per-finding verification). No high-severity findings; the security-guardrail dimension found nothing. - diagnose_empty_oql now takes an EmptyContext. On a FAILED result (trap / OQL error arm) it emits ONLY the #7 unknown-`start` repair, never the "came back empty => likely not authenticated" / "no entities here" notes — those describe an EMPTY result and would contradict a genuine error message. (Previously an anonymous query with a valid start that ERRORED got a misleading re-authenticate hint.) - diagnose_empty_oql distinguishes a FAILED schema re-read (entities: None) from a schema that genuinely lists no entities (Some([])), so a transient schema-read failure on an authenticated empty-table result no longer mislabels it "this account sees no entities" — it falls back to the benign "0 rows" note. - Dropped the "(or app_url)" hint for the OQL read tools in three places (the open_app data-access handle, the open_app description, and the server-instructions MY/OUR block): get_canister_oql_schema / run_canister_oql_query take only `derivation_origin`; `app_url` is call_canister's. Offering it sent the agent to a param those tools silently ignore -> an anonymous empty read. - The OQL Unrecognized-result arm now carries a structured `note` ("not an empty result; raw reply is in the text block"), so a structured-only consumer doesn't misread a non-tabular reply as "no data". - Fixed the candid_reply_is_empty doc to match the implementation: it recognizes `variant { none }` only; an explicit `variant { err = … }` is a real error, not "empty" (with a test assertion locking that contract in). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d * Build OQL example query with serde_json so untrusted entity names are escaped Addresses a Copilot review comment on PR #61: oql_query_examples built the example `query` JSON string with format!, so a schema entity name containing a quote or backslash — the schema is canister-supplied, hence untrusted — would produce invalid JSON in the (advisory) example. Build the query object via serde_json::json!(...).to_string() instead, which escapes it. Added a test with a quoted entity name asserting both the args and the inner query string parse as valid JSON and the name round-trips. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d * Require an origin for OQL reads: disable anonymous per-app reads for now Per maintainer direction, replace the soft "anonymous empty read" auth note on the OQL read tools with a hard precondition: get_canister_oql_schema and run_canister_oql_query now REJECT a call with no derivation_origin, since they read per-app data gated by the caller's principal (an anonymous read is signed as 2vxsx-fae and returns nothing useful). The rejection names what to pass and points at open_app / resolve_app so the agent recovers in one step. A hard reject can't be misread as "no data" the way an empty result can. Rationale for no anonymous escape hatch: authenticating never hurts a public read — the canister serves the request regardless of principal, so a caller with no account there simply isn't blocked. So there's no case that needs anonymous. Scope: - Applies to the two OQL read tools only (the definitively caller-gated per-app data surface). The guards are a two-line origin.is_none() check, so re-enabling anonymous later is a trivial revert — the is_anonymous field and the empty-read diagnostics are left intact and simply aren't reached while the guards stand. - call_canister stays permissive (keeps its soft empty-read note): it's the general-purpose tool used for genuinely public canisters like ledgers, where there's often no app origin to pass and hard-blocking would break common public reads for no gain. - Public-metadata tools (get_canister_candid, get_canister_api_doc, discover_app_canisters, resolve_app) are unaffected — they read public data and take no origin. Updated the OQL tool descriptions, the server-instructions playbook, the get_canister_candid OQL note, open_app's description + data-access note, and the OQL primer to say the OQL reads REQUIRE the origin (not "anonymous comes back empty"). Added a test that the rejection message is actionable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d * Sync README with the tool changes (capability flags, structured api-doc, require-origin OQL reads) The README tool table + flow drifted from the code. Brought them current: - get_canister_candid now advertises both `oql` and `api_doc_available` flags. - get_canister_api_doc is call-only-when-available and returns a structured available/expected/retry/next result (not "call first for an unfamiliar app"). - get_canister_oql_schema / run_canister_oql_query now REQUIRE derivation_origin (anonymous per-app reads are rejected for now); noted the per-entity examples and the empty-result start validation / did_you_mean. - open_app / discover_app_canisters now report per-canister oql/api_doc_available capability flags + the caller-gated data-access note. - Typical flow + OQL section updated to say the OQL read tools require the origin while public metadata and call_canister public reads stay anonymous. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRpq9CvXFNhkr2roH7j22d --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6 with the two hardening improvements I flagged during review (merged as-is). Both are independent and low-risk.
1. Pin third-party actions to commit SHAs
actions/checkoutanddocker/setup-buildx-actionwere pinned to floating tags (@v4/@v3), which a compromised upstream tag could repoint at malicious code — a real concern since this workflow handles the deploy SSH key. Now pinned to immutable commit SHAs, with the human-readable version in a trailing comment:actions/checkout→df4cb1c…(v6.0.3)docker/setup-buildx-action→d7f5e7f…(v4.1.0)Bumping to the current majors also clears the Node 20 runner deprecation warning seen in the first deploy run.
2. Production approval gate
The deploy job now runs in the GitHub
productionenvironment, so you can require a manual approval before each deploy to the live host.main(no behavior change). Documented indeploy/native/README.md.Validation
deploy.ymlparses as valid YAML.checkoutworks.🤖 Generated with Claude Code
Generated by Claude Code