Skip to content

pre-commit: refuse to commit this machine's hostname or public IP - #111

Merged
SamMausberg merged 8 commits into
mainfrom
infra/host-identity-guard
Oct 1, 2026
Merged

SamMausberg merged 8 commits into
mainfrom
infra/host-identity-guard

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

The repository is public, and on this cloud box the hostname is the public IP address written with dashes. Any server id or launch record that carries the hostname therefore publishes the address. #110 did that briefly (since fixed and force-pushed). bench/server.py also records the hostname in launch.json, though no committed evidence carries it today.

This adds a pre-commit hook, forbid-host-identity, backed by scripts/check_host_identity.sh.

  • What it matches: the hostname when it is a global IPv4 address in dashed form, and every global address that hostname -I reports (IPv4 dotted and dashed; IPv6 compressed and fully expanded, any case). Python's ipaddress decides what is global, so private, CGNAT, link-local, unique-local and other reserved ranges are skipped. File paths are checked as well as contents, and a path that contains the identity is never printed.
  • Binary files: scanned as text (grep -a), so a PDF or binary artifact that embeds the address is caught. A compressed stream can still hide it, so generated archives need checking at the source.
  • What it checks: the staged content of the staged files. The hook sets pass_filenames: false and always_run: true, so the config's top-level evidence/ exclusion does not hide evidence files from it. Given file arguments, it checks those files instead.
  • What it reports: file and line numbers only, never the matched value.

The source changes that stop writing the hostname are in each workstream's own PR: experiments/state_safety/server.py in #110, and bench/server.py in bench's next PR.

Tests (tests/test_check_host_identity.py, with hostname faked; the examples are a public address, 8.8.4.4, and 2600:1f18::/32, because the documentation ranges are not global):

  • given files with the dashed or dotted address are refused, while clean files and private addresses pass, and the report does not repeat the address;
  • by default it checks the staged copy, not the working copy;
  • a hostname that is not an address is not used as a pattern;
  • staged paths git would quote, and a symlink replaced by a file (type change), are checked;
  • binary files are scanned;
  • global IPv6 addresses are patterns, local ones are not.

scripts/check_host_identity.sh $(git ls-files) passes on main's current tree.

The repository is public, and on this cloud box the hostname is the
public IP address written with dashes, so any server id or launch record
that carries the hostname publishes the address. #110 did that briefly.

scripts/check_host_identity.sh looks for the hostname (when it is an
address) and for every public IPv4 address `hostname -I` reports, dotted
and dashed, in the staged files, and reports matches by file and line
without repeating the value. The hook passes no filenames and reads the
staged files itself, so the config's evidence/ exclusion does not hide
evidence from it.

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

ℹ️ 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 scripts/check_host_identity.sh Outdated
if [ "$#" -gt 0 ]; then
files=("$@")
else
mapfile -t files < <(git diff --cached --name-only --diff-filter=ACMR)

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 Include type-changed files in the staged scan

When a tracked symlink is replaced by a regular file containing the machine address, Git classifies the staged entry as T (type changed), but --diff-filter=ACMR omits it. The resulting files array is empty and the hook succeeds even though the staged blob leaks the identity; include T in the filter. See Git's --diff-filter documentation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5621b86: the staged list is now read with git diff --cached --name-only -z --diff-filter=ACMRT into a NUL-delimited array, so quoted paths and type changes (a symlink replaced by a file) are both checked, and the staged blob is read with git cat-file blob. test_staged_unusual_paths_and_type_changes_are_checked covers both cases and fails on bf93ca3.

Comment thread scripts/check_host_identity.sh Outdated
if [ "$#" -gt 0 ]; then
files=("$@")
else
mapfile -t files < <(git diff --cached --name-only --diff-filter=ACMR)

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 Parse staged filenames with NUL delimiters

When a staged filename contains non-ASCII characters, tabs, newlines, or other characters Git quotes by default, this command stores the quoted representation rather than the actual path. The later file check therefore skips it, allowing an identity inside such a file to be committed; use Git's documented -z output with NUL-delimited mapfile parsing. See the -z documentation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5621b86: the staged list is now read with git diff --cached --name-only -z --diff-filter=ACMRT into a NUL-delimited array, so quoted paths and type changes (a symlink replaced by a file) are both checked, and the staged blob is read with git cat-file blob. test_staged_unusual_paths_and_type_changes_are_checked covers both cases and fails on bf93ca3.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-01T12:34:16.160572Z 4f9fe87 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.

Staged paths were read from git's default output, which quotes unusual
names, so such a file was skipped. They are now read with -z. A symlink
replaced by a regular file is staged as a type change (T), which the
filter left out. Staged content is read with git cat-file, so a file
deleted from the working tree after staging is still checked.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@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: 5621b86651

ℹ️ 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 scripts/check_host_identity.sh Outdated
for f in "${files[@]}"; do
# Staged content, not the working copy, when checking a commit.
if [ -n "$staged" ]; then
hits="$(git cat-file blob ":$f" 2>/dev/null | grep -n -I -F "${args[@]}" | cut -d: -f1 | tr '\n' ' ' || true)"

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 Scan binary blobs instead of excluding them

When a staged artifact contains any NUL byte—for example, a PDF or binary evidence file that embeds the hostname or address literally—grep -I treats the entire blob as having no matches, so this hook exits successfully and permits the identity leak it is meant to prevent. GNU grep's --help defines -I as equivalent to --binary-files=without-match; scan the blob as text (for example with -a) instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in b8fe3b9. Both scans now use grep -a, so a blob with NUL bytes is searched as text instead of being treated as matching nothing. test_binary_files_are_scanned_too fails on 5621b86. The header notes that a compressed stream can still hide the address. 417b2ce also adds global IPv6 addresses as patterns.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Review on the exact head 5621b86 (bf93ca3 and 5621b86).

What I verified

  • The guard catches this box. I computed both forms of the hostname at runtime and wrote one into each of two temporary files. scripts/check_host_identity.sh refused both with exit 1, reported only file and line, and did not echo the value. A clean file passed.
  • The current tree is clean. git ls-files -z | xargs -0 scripts/check_host_identity.sh exits 0.
  • Tests: tests/test_check_host_identity.py gives 4 passed. They use only documentation (203.0.113.0/24) and private addresses.
  • The new test catches the old bug. With the bf93ca3 script, test_staged_unusual_paths_and_type_changes_are_checked fails and the other three pass.
  • Codex's two P2s on bf93ca3 (NUL-delimited paths; type changes and staged blobs) are fixed and have replies.
  • Hook configuration. The hook runs on staged content, with always_run and pass_filenames: false, so the evidence/ exclusion in the config does not hide evidence files.
  • Pre-commit passes on the three files.
  • Attribution: commits by Samuel Mausberg, with no AI lines in the commits or the PR body.

Blocking

  1. Codex P2 on 5621b86: scan binary blobs instead of excluding them (pre-commit: refuse to commit this machine's hostname or public IP #111 (comment)). It has no reply or fix yet, and it is right.
    • grep -I is --binary-files=without-match, so any staged file with a NUL byte is skipped whole. That includes a PDF, a .npy or .pt, or a pickle, any of which can carry the hostname as a literal string.
    • Use grep -a in both branches; the output is still only line numbers, so nothing binary is printed.
    • Add a test with a NUL byte before the address.
    • Compressed streams, such as most PDF page content, will still hide a string. Say so in the header comment rather than imply full coverage.

Suggestion (non-blocking). The address loop skips every IPv6 address (*:*). This box reports none today. A global IPv6 address (not fe80::, fc00::/7 or ::1) would identify a machine just as an IPv4 one does, so including those would make the guard portable.

grep -I treats any blob with a NUL byte as matching nothing, so a PDF or
binary artifact that embeds the address passed. Scan with -a instead.
…treams

Global IPv6 addresses from hostname -I are now patterns too (loopback,
link-local and unique-local ones are skipped). The header notes that a
compressed stream can still hide the address.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 417b2ce was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 417b2ce (b8fe3b9 and 417b2ce on top of 5621b86).

  • Codex P2 r4155220521 is fixed and has a reply.
    • Both scans now use grep -a, so a blob with NUL bytes is searched rather than skipped.
    • test_binary_files_are_scanned_too fails on 5621b86 and passes now.
    • I also wrote this box's address, computed at runtime, after NUL bytes in a temporary binary file. The guard refused it with exit 1, without printing the value.
  • My IPv6 suggestion is in. Global IPv6 addresses from hostname -I are now patterns, while loopback, link-local (fe80:) and unique-local (fc/fd) addresses are skipped. Its test fails on 5621b86.
  • The compressed-stream limit is stated in the header and the PR body.
  • Checks
    • tests/test_check_host_identity.py: 6 passed.
    • The whole tracked tree passes the guard (git ls-files -z | xargs -0).
    • Pre-commit passes on the three files.
    • Commits are by Samuel Mausberg, with no AI lines. The branch is MERGEABLE.

Blocking: none.

Suggestion (non-blocking). Link-local is fe80::/10, so the fe80:* glob misses the rare fe9x, feax and febx forms. [fF][eE][89aAbB]*:* would cover all of them. Skipping one by mistake only adds a pattern, which fails closed.

@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: 417b2ce199

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

for p in "${patterns[@]}"; do args+=(-e "$p"); done

status=0
for f in "${files[@]}"; do

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 Scan staged path names for host identity

In the no-argument pre-commit path, only each blob's contents are searched; the value of f itself is never checked. An artifact with clean contents but a name such as run-203-0-113-7.log therefore passes while still publishing the machine's hostname/address in the Git tree, so staged path names also need to be checked.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5652f31. Each checked path is now compared with every pattern, case-insensitively, and a match is reported as "the path contains ...", without the value. test_paths_are_checked_as_well_as_contents fails on 417b2ce.

Comment thread scripts/check_host_identity.sh Outdated
for f in "${files[@]}"; do
# Staged content, not the working copy, when checking a commit.
if [ -n "$staged" ]; then
hits="$(git cat-file blob ":$f" 2>/dev/null | grep -n -a -F "${args[@]}" | cut -d: -f1 | tr '\n' ' ' || true)"

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 Match equivalent IPv6 text forms

On a host with a global IPv6 address containing hexadecimal letters, this fixed, case-sensitive search only catches the exact spelling emitted by hostname -I. A staged file can contain the same address with uppercase digits (for example, 2001:DB8::7 instead of 2001:db8::7) or an expanded zero representation and pass the hook, so IPv6 values must be compared using normalized or equivalent representations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5652f31. For each global IPv6 address, the guard now builds both the compressed and the fully expanded spelling (Python's ipaddress), and the search ignores case. Other spellings, such as partly expanded zeros, are still not matched, and the header says so. test_ipv6_matches_any_case_and_the_expanded_form fails on 417b2ce. This box currently has no global IPv6 address.

… form

A staged path that names the address was not checked, only contents.
IPv6 addresses were matched only in the exact spelling hostname -I
prints; the search now ignores case and also looks for the fully
expanded form. Other spellings remain unmatched, as the header says.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 5652f31 was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 5652f31. My provisional approval of 417b2ce did not stand: Codex left two P2s on that head, and this commit answers both.

  • P2 r4155261999 (scan path names) is fixed and has a reply.
    • Every checked path is compared with every pattern, case-insensitively, as a literal substring. A match is reported as "the path contains ...", without the value.
    • I created two clean files whose names held this box's hostname, one uppercased and one in dotted form, both computed at runtime. Both were refused.
    • test_paths_are_checked_as_well_as_contents fails on 417b2ce.
  • P2 r4155262005 (equivalent IPv6 spellings) is fixed and has a reply.
    • Each global IPv6 address now adds its compressed and fully expanded forms, from ipaddress, and the search uses grep -i.
    • Partly expanded spellings are documented as not matched.
    • If Python fails, the script falls back to the literal address.
    • test_ipv6_matches_any_case_and_the_expanded_form fails on 417b2ce.
  • Tests: tests/test_check_host_identity.py gives 8 passed. The two new tests are the only ones that fail with the 417b2ce script.
  • Tree and hooks: the whole tracked tree passes the guard, and pre-commit passes on both files.
  • Attribution: the commit is by Samuel Mausberg, with no AI lines.

Blocking: none.

Suggestion (non-blocking, unchanged). The link-local glob still covers only fe80:* of fe80::/10. Leaving it is reasonable, since this box has no global IPv6 address, and a miss would only add a pattern, which fails closed.

@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: 5652f31fde

ℹ️ 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 scripts/check_host_identity.sh Outdated
# The path itself is published too.
for p in "${patterns[@]}"; do
if [[ ${f,,} == *"${p,,}"* ]]; then
echo "$f: the path contains this machine's hostname or IP address" >&2

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 Redact identity-bearing paths from diagnostics

When the identity appears in a staged path, this diagnostic prints the complete path and therefore repeats the hostname or IP address that the hook explicitly promises not to report. This can expose the value in terminal captures or pre-commit/CI logs even though the commit is rejected; report a redacted path or a generic path-match message instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 41fdd4e. A path that contains the identity is now shown as "(a staged path, not shown)" in both the path message and the content message. test_paths_are_checked_as_well_as_contents now checks that stderr does not repeat the address, for a path with the dashed form and one with the dotted form.

The path diagnostic printed the full path, repeating the address it
reports. A path that contains the identity is now shown as a placeholder
in both the path and the content messages.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 41fdd4e was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 41fdd4e ("check_host_identity: do not print a path that names the identity"). My provisional approval of 5652f31 did not stand, because Codex left a P2 on it.

  • Codex P2 r4155285888 (the path diagnostic printed the identity) is fixed and has a reply.
    • A path that contains a pattern is now shown as "(a staged path, not shown)", in both the path message and the line message.
    • I made a file named with this box's hostname that also contained the dotted address, both computed at runtime. The guard exited 1 with two messages, and neither contained either form.
    • test_paths_are_checked_as_well_as_contents now checks stderr, and it is the one test that fails with the 5652f31 script.
  • Checks
    • 8 tests pass, the whole tracked tree passes the guard, and pre-commit passes on both files.
    • The commit is by Samuel Mausberg, with no AI lines.

Blocking: none.

Suggestion (non-blocking). In explicit-file mode, the placeholder still says "a staged path". "(a path, not shown)" would fit both modes.

@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: 41fdd4e4f3

ℹ️ 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 scripts/check_host_identity.sh Outdated
hits="$(git cat-file blob ":$f" 2>/dev/null | grep -n -a -i -F "${args[@]}" | cut -d: -f1 | tr '\n' ' ' || true)"
else
[ -f "$f" ] || continue
hits="$(grep -n -a -i -F "${args[@]}" "$f" | cut -d: -f1 | tr '\n' ' ' || true)"

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 End grep option parsing before explicit filenames

When the advertised file-argument mode receives a basename beginning with -—for example, -v, including through the commit's suggested $(git ls-files) invocation—this operand is passed to grep without --. GNU grep's --help identifies -v as the --invert-match option; consequently, a file named -v containing the address is treated as an option, grep reads stdin instead, and the script returns success without scanning the file. Add -- before "$f".

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 68d1be3: the file operand now follows --. test_a_file_named_like_an_option_is_scanned (a file named -v that contains the address) fails on 41fdd4e.

Comment thread scripts/check_host_identity.sh Outdated
fi
for addr in $(hostname -I 2>/dev/null || true); do
case "$addr" in
::1 | [fF][eE]80:* | [fF][cCdD]*:*) continue ;; # IPv6 loopback, link-local, unique local

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 Exclude the full IPv6 link-local range

When hostname -I returns a link-local address such as fe90::1, this case does not skip it because it recognizes only the fe80: spelling, while IPv6 link-local addresses occupy fe80::/10 (fe80 through febf). The address is therefore added as if it were global, and a file mentioning that non-public interface address is rejected contrary to the hook's documented behavior; classify the parsed address or cover the full prefix.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 68d1be3. IPv6 addresses are now classified with ipaddress.IPv6Address(...).is_global, and only global ones become patterns, so all of fe80::/10, loopback and unique-local are skipped. The test now also covers fe90::1 and febf::1; it fails on 41fdd4e.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 41fdd4e (#111 (comment)), which I withdraw. Codex finished its review of 41fdd4e at 12:26:13 and left two P2s. Neither has a reply or fix yet, and both are sound and small.

Blocking

  1. End grep option parsing before explicit filenames (pre-commit: refuse to commit this machine's hostname or public IP #111 (comment)).
    • In file-argument mode, grep -n -a -i -F "${args[@]}" "$f" takes a file named -v (or any name starting with -) as an option. grep then reads stdin, and the file passes unscanned.
    • Add -- before "$f", and add a test with a file named -v that contains the address. git ls-files can list such a name, so the whole-tree check the PR suggests is exposed.
  2. Exclude the full IPv6 link-local range (pre-commit: refuse to commit this machine's hostname or public IP #111 (comment)).
    • Link-local is fe80::/10 (fe80 to febf), but the case only skips fe80:*. A fe9x, feax or febx address becomes a pattern, which contradicts the documented behaviour.
    • I raised this as non-blocking earlier because it fails closed. Codex's point that the hook then rejects a non-public address against its own header makes it worth the one-line fix.
    • Since the script already calls Python's ipaddress for IPv6, classifying with ipaddress.IPv6Address(a).is_global would be the cleanest way to cover loopback, link-local and unique-local together. Please add a fe90::1 case to the IPv6 test.

Everything else from my 41fdd4e review still holds.

…80::/10

A file named like an option (-v) was parsed by grep as one and not
scanned; the file operand now follows --. Only the fe80: spelling of
link-local IPv6 was skipped; addresses are now classified with Python's
ipaddress, and only global ones become patterns.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 68d1be3 was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 68d1be3 ("check_host_identity: end grep options before the file; skip all of fe80::/10").

  • Codex P2 r4155314605 (-- before the filename) is fixed and has a reply.
    • In file-argument mode the grep call now has -- before the filename.
    • I wrote this box's address, computed at runtime, into a file named -v and passed it by name. The guard refused it with exit 1.
    • test_a_file_named_like_an_option_is_scanned fails on 41fdd4e.
  • Codex P2 r4155314616 (the whole link-local range) is fixed and has a reply.
    • IPv6 addresses are now classified with ipaddress.IPv6Address(...).is_global. Loopback, all of fe80::/10 and unique-local addresses add no pattern. A global address adds its compressed and expanded forms.
    • The IPv6 test now covers fe90::1 and febf::1, and it fails on 41fdd4e.
    • Moving the examples off 2001:db8::/32, which is_global rejects, is right, and the comment explains why.
  • Checks
    • tests/test_check_host_identity.py: 9 passed. Only the two new or changed tests fail with the 41fdd4e script.
    • The whole tracked tree passes the guard, and pre-commit passes on both files.
    • The commit is by Samuel Mausberg, with no AI lines. The branch is MERGEABLE.

Blocking: none. Suggestions: none.

@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: 68d1be30eb

ℹ️ 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 scripts/check_host_identity.sh Outdated
127.* | 10.* | 192.168.* | 169.254.*) continue ;;
172.1[6-9].* | 172.2[0-9].* | 172.3[01].*) continue ;;
esac
patterns+=("$addr" "${addr//./-}")

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 Classify IPv4 addresses before adding patterns

When hostname -I returns a non-global address outside the few ranges handled above, such as a CGNAT address in 100.64.0.0/10 or a benchmarking address in 198.18.0.0/15, this unconditional addition treats it as public and rejects any staged file mentioning it. This contradicts the hook's documented public-address scope and can block ordinary artifacts on hosts using those ranges; classify IPv4 values with ipaddress as is already done for IPv6.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 4f9fe87. Every address from hostname -I is now classified with ipaddress.ip_address(...).is_global and becomes a pattern only if it is global (IPv4 dotted and dashed; IPv6 compressed and expanded). A dashed hostname follows the same rule. test_only_global_ipv4_addresses_are_patterns (with CGNAT 100.64.1.2, benchmarking 198.18.0.1 and private 10.0.0.2) and test_a_dashed_hostname_that_is_not_global_is_not_a_pattern both fail on 68d1be3. The tests' dashed-hostname examples moved off the documentation range, which is_global treats as non-global.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

This updates my provisional approval of 68d1be3 (#111 (comment)), which I withdraw. Codex finished its review of 68d1be3 at 12:29:37 and left one P2. It has no reply or fix yet.

Blocking

  1. Classify IPv4 addresses before adding patterns (pre-commit: refuse to commit this machine's hostname or public IP #111 (comment)).
    • The IPv4 branch skips only 127/8, 10/8, 172.16/12, 192.168/16 and 169.254/16. Any other non-global address that hostname -I reports, such as shared address space (CGNAT, 100.64.0.0/10) or the benchmarking range (198.18.0.0/15), becomes a pattern. That contradicts the header's "public IPv4 address" scope, and on such a host it would block ordinary files that mention the address.
    • It fails closed, like the link-local case I asked you to fix in the last round, so the same standard applies.
    • The script already classifies IPv6 with ipaddress, so the same Python call can classify IPv4. Add a pattern only when IPv4Address(a).is_global holds; that covers every special range at once.
    • Please apply the same rule to the dashed hostname: only add it when the address it spells is global.
    • Add test cases for a CGNAT address and a benchmarking address. These ranges are reserved and unroutable, so they are safe to put in a test.

Everything else from my 68d1be3 review still holds: the -- fix, the IPv6 classification, 9 tests passing and a clean tree.

…ress

Only RFC 1918, loopback and link-local IPv4 ranges were skipped, so CGNAT,
benchmarking and other non-global addresses became patterns, against the
hook's stated public scope. Every address from hostname -I, and a dashed
hostname, is now a pattern only if ipaddress calls it global. The tests'
dashed-hostname examples move from the documentation range, which is not
global, to a public example address.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional: Codex's review of 4f9fe87 was still running when I posted this. I will re-check its threads on this head before merge.)

Re-review on the exact head 4f9fe87 ("check_host_identity: classify IPv4 and the dashed hostname with ipaddress").

  • Codex P2 r4155343239 (classify IPv4) is fixed and has a reply.
    • Every hostname -I address now goes through ipaddress.ip_address(...).is_global. A global IPv4 address adds its dotted and dashed forms; a global IPv6 address adds its compressed and expanded forms.
    • A dashed hostname is a pattern only if the address it spells is global.
    • The two new tests (test_only_global_ipv4_addresses_are_patterns, test_a_dashed_hostname_that_is_not_global_is_not_a_pattern) are the only ones that fail with the 68d1be3 script.
  • This box is still caught. I wrote both forms of its hostname, computed at runtime, into two files. The guard exited 1 with two reports, and neither repeated the value.
  • Checks
    • 11 tests pass, the whole tracked tree passes the guard, and pre-commit passes on both files.
    • The commit is by Samuel Mausberg, with no AI lines. The branch is MERGEABLE.

Blocking: none.

Suggestion (non-blocking). When python3 is missing, an IPv4 address from hostname -I falls back to its dotted form alone; before this commit the dashed form was added as well. The dashed hostname is still covered by its own branch, so this matters only on a host without Python whose hostname is not the dashed address. Adding ${addr//./-} in the fallback would restore the old behaviour.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 4f9fe87b87

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

@SamMausberg
SamMausberg merged commit 8da1e41 into main Oct 1, 2026
@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (confirmed on 4f9fe87)

Codex finished its review of 4f9fe87 at 12:34:15 with "Didn't find any major issues". gh api --paginate shows no review threads on 4f9fe87. The newest Codex threads are on 41fdd4e and 68d1be3, and both have replies and fixes. My provisional approval of 4f9fe87 (#111 (comment)) now stands without condition. The branch head is still 4f9fe87.

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