Skip to content

fix(import): annoncer l'approbation de confiance requise au premier lancement - #196

Open
kaaloo wants to merge 4 commits into
mainfrom
fix/p154-import-trust-announce
Open

kaaloo wants to merge 4 commits into
mainfrom
fix/p154-import-trust-announce

Conversation

@kaaloo

@kaaloo kaaloo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Problème

Après un just-code import albert-code --apply réussi, le premier just-code était bloqué par la porte de confiance OpenCode, sans que l'import l'ait annoncé : la migration cassait à la première commande (#154). Dans le même rapport : la sortie de --apply affichait « Preview only. Pass --apply… » avant « Wrote… ».

Correction

  • Annonce de l'approbation requise : l'import liste maintenant, en prévisualisation comme après application, les entrées d'exécution non approuvées (par ex. opencode.json (unapproved)) avec la même formulation que l'erreur de lancement, et renvoie vers just-code trust approve. Le parcours de migration ne casse plus silencieusement. Le contrôle est en lecture seule : il ne provoque jamais d'approbation.
  • Affichage de --apply : la ligne « Preview only. Pass --apply… » était codée en dur dans le formateur du plan d'import et s'affichait sur les deux chemins. Elle n'est plus imprimée qu'en mode prévisualisation ; la sortie de --apply va directement aux écritures.

Tests

Le test existant TestAlbertCodeImportPreviewAndApplyAreSafeAndIdempotent est étendu :

  • la prévisualisation annonce l'approbation requise (opencode.json (unapproved) + trust approve) ;
  • la sortie d'application ne contient plus « Preview only » et contient l'annonce ;
  • la ré-importation idempotente continue d'annoncer l'approbation en attente.

Vérifications : go build ./..., go vet, gofmt -l (rien), go test ./... -count=1 vert.

Closes #154

👾 Generated with Letta Code

After a successful `just-code import albert-code --apply`, the first launch
was blocked by the OpenCode trust gate with no prior warning: the import never
mentioned that opencode.json still needed `trust approve` (#154).

The import now lists the unapproved execution inputs in both preview and
apply output, mirroring the launch error wording, and points at
`just-code trust approve`. The check is read-only and never approves.

Related display bug from the same report: `--apply` printed "Preview only.
Pass --apply..." before "Wrote ...". The trailer was hardcoded in the plan
formatter and printed on both paths; it now only prints in preview mode.

Closes #154

👾 Generated with [Letta Code](https://letta.com)

Model: lc-qwencloud/deepseek-v4.1-flash

Co-Authored-By: Letta Code <noreply@letta.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T16:02:14.246358Z 6368a02 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 713c95468f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/just-code/import.go Outdated
lines = append(lines, fmt.Sprintf(" %s (%s)", u.Path, u.Reason))
}
fmt.Printf("This project declares OpenCode inputs that execute code or launch processes, and they are not approved at their current content:\n%s\n"+
"The first 'just-code' run will stop for this. Review them, then run 'just-code trust approve' to record approval for the current content.\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Direct trust approval to the imported project

When the import is run with --root for a project other than the current worktree, this suggested command does not approve the project just inspected: just-code trust approve resolves its project from DiscoverProject(".") in the main dispatcher and has no --root option. Running the recommendation as written therefore approves the caller's current project (or errors outside a project), leaving the imported project blocked; tell the user to run it from projectRoot or provide an equivalent root-aware command.

Useful? React with 👍 / 👎.

'trust approve' resolves its project from the current directory, so an
import into a different --root must recommend running it from the
imported project, not from wherever the caller stands.

👾 Generated with [Letta Code](https://letta.com)

Model: lc-qwencloud/deepseek-v4.1-flash

Co-Authored-By: Letta Code <noreply@letta.com>
@kaaloo

kaaloo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review New head efdeb1d addresses the P2 finding: the trust-approval recommendation now names the imported project directory, since 'trust approve' resolves its project from the current directory.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: efdeb1dbbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… root

The Windows CI failure was not a product bug: GitHub's Windows runners
expose TEMP with the 8.3 short name (C:\Users\RUNNER~1\...), so the
t.TempDir() value differs from the root just-code prints after
DiscoverProject resolves symlinks and the git worktree root (macOS hits
the same class of difference via /var -> /private/var). Assert against
DiscoverProject's own resolution, which is the directory the
recommendation is contractually required to name.

Refs #154

👾 Generated with [Letta Code](https://letta.com)

Model: lc-qwencloud/deepseek-v4.1-flash

Co-Authored-By: Letta Code <noreply@letta.com>
@kaaloo

kaaloo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review — new head 7407cef: the CI test failure is fixed by comparing the trust-approve hint against DiscoverProject's resolved root (Windows TEMP 8.3 short-name + macOS /var symlink). Please re-review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 7407cefb35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Import preview and trust discovery read opencode.json from checkouts
that may be untrusted, so three read vectors are closed:

- ParseProjectOpenCodeConfig now reads through a no-follow, regular-only
  path with a SameFile recheck and a 1 MiB bound: a symlinked config can
  no longer read outside the worktree, a FIFO can no longer hang the
  read, and an oversized or device-backed entry can no longer exhaust
  memory.
- FindProjectOpenCodeConfig switches to Lstat and keeps reporting any
  non-directory entry, including symlinks and FIFOs. Discovery stays
  fail-closed: the entry remains in the trust flow, parse and approval
  refuse it, and launch is blocked instead of the input silently
  disappearing from discovery.
- hashFileContent refuses non-regular files before opening them and
  hashes by streaming, so approval hashing cannot hang on a FIFO or
  load a large input into memory.

Found by Codex review on #197 (applies to the import path introduced
for #154).

Refs #154

👾 Generated with [Letta Code](https://letta.com)

Model: lc-qwencloud/deepseek-v4.1-flash

Co-Authored-By: Letta Code <noreply@letta.com>
@kaaloo

kaaloo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review — new head 6368a02 adds the hardening for the P1 finding from the #197 review: readProjectConfigFile (no-follow, regular-only, SameFile recheck, 1 MiB bound) for ParseProjectOpenCodeConfig, Lstat-based discovery that keeps fail-closed reporting of symlinks/FIFOs, and a streaming regular-only hashFileContent. Please review the new head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6368a02bcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if !fi.Mode().IsRegular() {
return "", fmt.Errorf("%s is not a regular file; refusing to hash it", path)
}
file, err := os.Open(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject symlinks in parent path components

When an untrusted checkout makes .opencode/plugin or .opencode/plugins a symlink to an external directory, os.ReadDir follows that directory symlink and each discovered child reaches this open with the symlink in an intermediate component. Both Lstat and Open follow intermediate symlinks, so the regular-file and SameFile checks pass; the import preview's new trust warning can consequently hash arbitrary host .js/.ts files and spend unbounded time on a large external regular file instead of remaining confined to the checkout. Validate or open every path component without following symlinks before hashing; the nested-config reader has the same intermediate-component issue.

Useful? React with 👍 / 👎.

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.

Après import albert-code, le 1er lancement est bloqué par trust approve sans l'avoir annoncé

1 participant