Skip to content

feat(cli): review and apply saved SECURITY.md drafts - #489

Open
mldangelo-oai wants to merge 69 commits into
mdangelo/codex/security-policy-draftsfrom
mdangelo/codex/security-policy-command
Open

feat(cli): review and apply saved SECURITY.md drafts#489
mldangelo-oai wants to merge 69 commits into
mdangelo/codex/security-policy-draftsfrom
mdangelo/codex/security-policy-command

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add offline review and explicit application of saved SECURITY.md drafts. policy --apply <artifact-directory> validates the selected repository and component, previews the exact diff, and asks before writing. --write applies an already-reviewed saved draft without another prompt; it cannot write an unseen model response.

This PR remains stacked on #536 and includes its updated head and main.

Changes

  • Export saved-draft loading and application APIs, with CLI help, documentation and installed-package coverage.
  • Revalidate source checkpoints, inherited policies and aliases before and after application. Keep distinct recovery-required and written-but-unverified outcomes.
  • Preserve existing Unix and Windows security metadata, no-clobber installation, original recovery inodes and concurrent-writer checks.
  • Consolidate duplicate installation and rollback handling while retaining platform-specific copy, permission verification and atomic move operations. The PR has 59 fewer net lines after reconciliation.
  • Move the long-running policy tests to an existing lighter Windows shard. Keep all seven shards, existing timeouts and exactly-once file coverage.
  • Preserve the parent's scan/policy permission separation and the child's platform-specific test fixtures. Add the missing subprocess-error assertion to diagnose the Windows release-note test failure.

Testing

  • Initial merged policy/API/CLI/configuration run: 199 passed, 14 skipped.
  • Focused installation and recovery regressions after simplification: 14 passed, 3 Windows skips.
  • Final affected policy, CLI, API, runtime, configuration, release and package-layout suites: 773 passed, 27 skipped, 0 failed across nine files.
  • pnpm run types, pnpm run format, pnpm run build, and git diff --check: passed.
  • Windows shard-routing probe: every ordinary test file assigned exactly once across seven shards; policy tests assigned to shard 4. This does not execute Windows tests.
  • Static npm artifact check and installed-package smoke: passed, including public imports, NodeNext types, offline draft preview/apply/recovery, credential locking and bundled runtime checks.

The full repository suite was not rerun. Native Windows, SELinux and Docker validation were not performed locally. Current-head CI is left for a second pass.

Risk and rollout

Applying a draft replaces only the selected policy after explicit approval. It does not stage, commit or publish it. Retain reported recovery files until concurrent editor writes are reconciled. Filesystem generation checks do not make the final observation and following move one atomic operation.

Two follow-ups remain: filename-specific SELinux context transitions for a brand-new policy are unresolved; the Windows release-note test's null child status was not reproduced locally. The shard change addresses the observed policy-test timeout, but native timing still needs CI verification. Do not treat this first pass as merge approval.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Preexisting public history includes contributor metadata and requester-only automated review links. Those links are not reproduced here; the second attestation remains unchecked. New examples and tests are synthetic.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, b1de4d9394c8c8ef7a155d0246735405186c9a11.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b1de4d9394

ℹ️ 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".

@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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: b1de4d9394

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/src/security-policy.ts

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 5c0acd8.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact head 8ee5fe1c43eb26f92abcefb98d8dc0e9f2378d2d, including preserving existing Windows audit descriptors without changing privileges, distinguishing inherited audit rules from explicit rules, and verifying installed permissions on every platform before reporting success.

The Unix permission-race regression failed on the preceding head and passes with this change. Local TypeScript, formatting, and combined policy, CLI, API, and configuration checks passed; exact-head native Windows package and matrix checks are pending.

@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: 8ee5fe1c43

ℹ️ 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 sdk/typescript/src/security-policy.ts
Comment thread sdk/typescript/src/security-policy.ts Outdated
Comment thread sdk/typescript/src/security-policy.ts Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact head 95f168ba41e01fc13534285296585a07c7d8ba52, including complete Windows audit control flags and mandatory integrity labels, preserving Unix owners, groups, special permissions, and access-control entries, and revalidating retained recovery evidence when retrying an installed policy.

Real Unix permission-metadata and verification-retry regressions failed on the preceding head and now pass. Local TypeScript, formatting, and combined policy, CLI, API, and configuration checks passed; exact-head native Windows and macOS checks are pending.

@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: 95f168ba41

ℹ️ 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 sdk/typescript/src/security-policy.ts
Comment thread sdk/typescript/src/security-policy.ts
Comment thread sdk/typescript/src/security-policy.ts Outdated
Comment thread sdk/typescript/src/security-policy.ts Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact head a47da34698991972ac7287530215199d23be4e17, including permission-preserving atomic Unix installation and rollback without hard links, safe cross-filesystem recovery retries, recovery-content revalidation, validated snapshot state, and preserving installed-policy error classification.

Real read-only and rollback access-control regressions, cross-filesystem recovery, retry races, existing alias verification, and atomic concurrent-writer protections pass locally. Exact-head native Windows and macOS checks are pending.

@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: a47da34698

ℹ️ 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 sdk/typescript/src/security-policy.ts Outdated
Comment thread sdk/typescript/src/security-policy.ts Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review the exact current head afbdd0e8ffa9b74521a0266e17c75b1859fbef10, including Linux security-context preservation, stable recovery snapshots, cross-platform security metadata, unchanged-draft validation, and policy installation/recovery races.

Local validation: 196 tests passed, 11 platform-specific tests skipped, and no tests failed. Fresh Linux, macOS, and Windows CI is running.

@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: afbdd0e8ff

ℹ️ 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 sdk/typescript/src/security-policy.ts
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact current head 5a1ed9c1c805ca51665083f9ea6d41a5985426de, including complete ordered Windows system access-control entries, resource and scoped-policy categories, mandatory integrity labels, Linux security contexts, stable recovery snapshots, and cross-platform installation/recovery races.

Local validation: 196 tests passed, 12 platform-specific tests skipped, and no tests failed. Fresh native Windows, Linux, and macOS CI is running.

@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: 5a1ed9c1c8

ℹ️ 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 sdk/typescript/src/security-policy.ts
Comment on lines +1235 to +1238
const temporary = join(
dirname(target.targetPath),
`.SECURITY.md.${randomUUID()}.tmp`,
);

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 Apply the target SELinux label when creating a policy

On SELinux systems with a filename-specific type transition for SECURITY.md, creating the inode under this randomized .tmp name gives it the temporary file's context, and the later hard-link or rename does not recompute the label for the final name. Because the new-policy path has no metadata reference, post-write verification never notices that the installed policy has the wrong mandatory-access context. The earlier existing-policy context preservation does not cover this branch; create or relabel the inode using the target's expected context and verify it after installation.

AGENTS.md reference: sdk/typescript/AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact current head 8f061f012d56d4e1b21452481dfb9dc9499394af, particularly the new stable Windows rollback snapshot verification, complete system access-control entries, resource attributes, mandatory integrity labels, existing Linux security contexts, and cross-platform installation/recovery races.

The separate open review item concerning filename-specific SELinux context transitions for a brand-new policy remains unresolved and is intentionally not changed by this Windows-only update.

Local validation: 196 tests passed, 13 platform-specific tests skipped, and no tests failed. Fresh native Windows, Linux, and macOS CI is running.

@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: 8f061f012d

ℹ️ 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 sdk/typescript/src/security-policy.ts Outdated
Comment thread sdk/typescript/src/security-policy.ts
Comment thread sdk/typescript/src/security-policy.ts
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact current head bfac0391e2d2e851ccd7087b921a18cdf90c3279, including complete raw discretionary/system ACL bytes and control flags, stable Windows recovery snapshots after descriptor verification, reviewed installed-content rechecks, resource attributes, mandatory integrity labels, and cross-platform recovery races.

The separate open review item concerning filename-specific SELinux context transitions for a brand-new policy remains unresolved and is intentionally not changed by this update.

Local validation: 197 tests passed, 14 platform-specific tests skipped, and no tests failed. Fresh native Windows, Linux, and macOS CI is running.

@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: bfac0391e2

ℹ️ 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 sdk/typescript/src/security-policy.ts
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact current head d9b4f0678b7753874376b9896ec8744698409921, including late out-of-scope policy aliases after permission verification, complete discretionary/system ACL bytes and control flags, stable recovery snapshots, reviewed installed-content rechecks, resource attributes, mandatory integrity labels, and cross-platform recovery races.

The separate open review item concerning filename-specific SELinux context transitions for a brand-new policy remains unresolved and is intentionally not changed by this update.

Local validation: 198 tests passed, 14 platform-specific tests skipped, and no tests failed. Fresh native Windows, Linux, and macOS CI is running.

@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: d9b4f0678b

ℹ️ 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 sdk/typescript/src/security-policy.ts Outdated
Comment thread sdk/typescript/src/security-policy.ts
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review
@codex security review

Please review exact current head 645bd253eadd71d9c4dbfae14069604380b0d920, including independent Unix and Windows recovery change-generation checks, complete discretionary/system ACL bytes and control flags, open-writer metadata and content races, late out-of-scope policy aliases, resource attributes, and mandatory integrity labels.

The separate open review item concerning filename-specific SELinux context transitions for a brand-new policy remains unresolved and is intentionally not changed by this update. Filesystem change-generation checks do not make their final observation and the following operating-system move one atomic operation.

Local validation: 199 tests passed, 14 platform-specific tests skipped, and no tests failed. Fresh native Windows, Linux, and macOS CI is running.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 645bd253ea

ℹ️ 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".

@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: 255925c081

ℹ️ 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 on lines +1393 to +1394
await validatePolicyLinks(target);
if ((await readSecurityPolicy(target.targetPath)) !== draft.content) {

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 Recheck inherited policies after permission verification

When applying an existing component policy, an editor or checkout operation can change a regular ancestor SECURITY.md while the potentially slow Unix metadata or Windows descriptor verification runs. This final block revalidates aliases and the installed target only, so the changed inherited-policy hash is never checked again and the operation can report written or unchanged against guidance different from the reviewed snapshot. Repeat the inherited snapshot check after permission verification before returning success.

AGENTS.md reference: sdk/typescript/AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

Comment on lines +1328 to +1330
} finally {
// Preserve the write or recovery outcome if temporary cleanup fails.
await rm(temporary, { force: true }).catch(() => undefined);

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 Fail verification when the staging hard link remains

When a writable new policy—or a writable existing policy on Windows—is installed through the hard-link path and removing the staging name fails, this suppression still lets application report success. The leftover .SECURITY.md.*.tmp is another name for the installed inode, so a later write through that unreported path changes the reviewed policy after all verification has passed. Treat this cleanup failure as a written-but-unverified result, or ensure installation cannot leave an unverified hard-link alias.

AGENTS.md reference: sdk/typescript/AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants