Skip to content

chore(security): ignore key material so an identity file cannot be committed - #2171

Merged
jaylfc merged 4 commits into
devfrom
chore/secret-ignores
Jul 27, 2026
Merged

chore(security): ignore key material so an identity file cannot be committed#2171
jaylfc merged 4 commits into
devfrom
chore/secret-ignores

Conversation

@jaylfc

@jaylfc jaylfc commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Follows the leak found during the #2043 deep review: data/hub/identity.json was committed with signing_private and encryption_private in plaintext. It was removed before merge and the repo squash-merges, so it never reached dev, but nothing stopped it going in.

The existing data/ rules are a per-file allowlist (data/config.yaml, data/agents.json, and so on), so any NEW data file slips straight through. That is what happened. These replacements are pattern-based, so a future identity file cannot.

Verified before committing that no currently tracked file becomes ignored by the new patterns (checked all of git ls-files, zero hits). tinyagentos/taosnet/mesh_credentials.py and its test are source files and stay tracked.

taOS-website-dev found and closed the same gap in its repo (PR #121). This is the core half.

Summary by CodeRabbit

  • Chores
    • Improved protection against accidentally committing credentials and private key material.
    • Added ignore rules for sensitive files and data directories, including common key, identity, and credentials formats.

…mmitted

data/hub/identity.json reached PR #2043 with private keys in plaintext. It never
landed on dev, but the data/ ignore rules are a per-file allowlist so nothing
would have stopped a repeat. Adds pattern-based ignores for key material.
Verified no tracked file becomes ignored.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jaylfc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0331c0b1-6b47-4f84-82be-3d31f460d58a

📥 Commits

Reviewing files that changed from the base of the PR and between 4a0dc78 and 6eeedf7.

📒 Files selected for processing (1)
  • .gitignore
📝 Walkthrough

Walkthrough

The .gitignore file adds rules for data/hub/ and several key or credential filename patterns, with comments documenting their credential-protection purpose.

Changes

Credential protection

Layer / File(s) Summary
Ignore credential material
.gitignore
Adds ignore patterns for data/hub/, key files, private-key names, identity.json, .p8 files, and credential JSON files.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding .gitignore rules to block key material and identity files from being committed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/secret-ignores

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.

@gitar-bot

gitar-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Harden .gitignore to prevent committing identity/private key material

🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Add pattern-based .gitignore rules to block identity files and private key material.
• Close the gap where new files under data/ could be committed unintentionally.
• Document the prior incident context and confirm no tracked files become ignored.
Diagram

graph TD
  A["Developer"] --> B["git add/commit"] --> C[".gitignore patterns"] --> D["Secret files stay untracked"] --> E["No secrets in repo"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add secret scanning in CI (e.g., gitleaks/trufflehog)
  • ➕ Catches secrets even if paths/extensions differ from ignore patterns
  • ➕ Can block merges and alert on historical leaks
  • ➖ Adds CI time/configuration overhead
  • ➖ May require tuning to reduce false positives
2. Pre-commit hooks for secret detection
  • ➕ Stops leaks before they ever reach a PR
  • ➕ Fast feedback loop for developers
  • ➖ Not enforceable unless paired with CI checks
  • ➖ Requires local hook installation/maintenance
3. Narrower ignore rules scoped only to known secret directories
  • ➕ Lower risk of accidentally ignoring legitimate files elsewhere
  • ➕ More predictable developer experience
  • ➖ Less robust against future relocation/renaming of identity/key files
  • ➖ May miss new secret file locations

Recommendation: The PR’s pattern-based .gitignore hardening is the right immediate fix because it directly blocks the known failure mode (new identity/key material files slipping through the data/ allowlist). Consider following up with CI secret scanning to provide defense-in-depth for secrets that don’t match these patterns.

Files changed (1) +14 / -0

Other (1) +14 / -0
.gitignoreAdd pattern-based ignores for identity/private keys and credentials +14/-0

Add pattern-based ignores for identity/private keys and credentials

• Adds new ignore patterns targeting identity files, private key naming conventions, and common key formats (e.g., *.key, *.p8). Includes detailed incident-motivated comments and notes verification that no currently tracked files become ignored.

.gitignore

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Line 156: Correct the date in the key material and secrets comment to July 27,
2026, keeping the rest of the comment unchanged.
- Line 168: Update the credential ignore rules in .gitignore to cover temporary
credential filenames, including data/mesh_credentials.json.tmp, by adding a
data-scoped suffix-aware pattern such as data/**/*credentials.json*. Ensure the
rule protects both final and temporary files produced by the mesh_credentials.py
atomic writer.
- Around line 163-168: Scope the credential-related ignore patterns in the
.gitignore block to the data/ directory, including *.key, *_private.*,
*_private_key*, identity.json, *.p8, and *credentials.json. Preserve their
existing matching behavior within data/ while preventing unrelated source files
or test fixtures elsewhere from being ignored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ef22d8fe-3785-40ff-9947-5935b7186449

📥 Commits

Reviewing files that changed from the base of the PR and between ca1d2fe and ae0c6a4.

📒 Files selected for processing (1)
  • .gitignore

Comment thread .gitignore Outdated
Comment thread .gitignore
Comment thread .gitignore
*_private_key*
identity.json
*.p8
*credentials.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Ignore credential temp files as well.

The atomic writer creates data/mesh_credentials.json.tmp; *credentials.json does not match that filename. If the process stops before os.replace, the temporary file can retain plaintext tokens and remain committable. Add a suffix-aware, data-scoped rule such as data/**/*credentials.json*.

The same temporary-file behavior is defined in tinyagentos/taosnet/mesh_credentials.py.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitignore at line 168, Update the credential ignore rules in .gitignore to
cover temporary credential filenames, including data/mesh_credentials.json.tmp,
by adding a data-scoped suffix-aware pattern such as data/**/*credentials.json*.
Ensure the rule protects both final and temporary files produced by the
mesh_credentials.py atomic writer.

Comment thread .gitignore Outdated
# future one cannot. Verified against every tracked file: none become ignored.
data/hub/
*.key
*_private.*

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: *_private.* is overly broad — it ignores any file matching *_private.*, which includes legitimate files like test_private.py (test modules for a private module) or foo_private_data.json. This could cause legitimate files to be silently ignored, leading to data loss-by-invisibility.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread .gitignore
*.key
*_private.*
*_private_key*
identity.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: identity.json is redundant with the existing data/hub/ rule (line 96) and overly broad — it ignores identity.json repo-wide. If a legitimate identity.json is needed outside data/hub/, it will be silently ignored.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread .gitignore
*_private_key*
identity.json
*.p8
*credentials.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: *credentials.json is very broad and would ignore any file ending in credentials.json, including legitimate test fixtures or sample configurations like test_credentials.json. Consider narrowing to *_credentials.json if the intent is only to catch files with the _credentials naming convention.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • .gitignore
Previous Review Summaries (3 snapshots, latest commit 97bd98e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 97bd98e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • .gitignore

Previous review (commit 4a0dc78)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • .gitignore - 1 file reviewed, no new issues

Previous review (commit ae0c6a4)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
.gitignore 164 *_private.* is overly broad — it ignores any file matching *_private.*, which includes legitimate files like test_private.py (test modules for a private module) or foo_private_data.json. This could cause legitimate files to be silently ignored, leading to data loss-by-invisibility.
.gitignore 166 identity.json is redundant with the existing data/hub/ rule (line 96) and overly broad — it ignores identity.json repo-wide. If a legitimate identity.json is needed outside data/hub/, it will be silently ignored.

SUGGESTION

File Line Issue
.gitignore 168 *credentials.json is very broad and would ignore any file ending in credentials.json, including legitimate test fixtures or sample configurations like test_credentials.json. Consider narrowing to *_credentials.json if the intent is only to catch files with the _credentials naming convention.
Files Reviewed (1 file)
  • .gitignore - 3 issues

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash · Input: 82.9K · Output: 14.9K · Cached: 515.8K

@qodo-code-review

qodo-code-review Bot commented Jul 27, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 35 rules

Grey Divider


Informational

1. Duplicate ignore entry ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The PR adds a second data/hub/ ignore rule even though data/hub/ is already ignored earlier in
.gitignore. This doesn’t change ignore behavior, but it creates duplicated/conflicting rationale
comments that can drift and confuse future maintenance.
Code

.gitignore[R156-163]

+# Key material and secrets. Added 2026-07-28 after data/hub/identity.json was
+# committed to PR #2043 with signing_private and encryption_private in
+# PLAINTEXT. It was removed before merge and the repo squash-merges, so it never
+# reached dev, but nothing STOPPED it. The data/ rules above are a per-file
+# allowlist, so any new data file slips through; these are pattern-based so a
+# future one cannot. Verified against every tracked file: none become ignored.
+data/hub/
+*.key
Relevance

⭐⭐⭐ High

Team has accepted dedup/cleanup changes before (duplicate import removal PR#390; startup config
dedupe PR#445).

PR-#390
PR-#445

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The file already ignores data/hub/ earlier, and the PR adds the same ignore rule again in the new
block, creating duplication and two different rationale comments for the same rule.

.gitignore[95-97]
.gitignore[156-163]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`.gitignore` contains two separate `data/hub/` ignore entries with different comment rationales. While harmless functionally, this duplication increases the chance that future edits update one section but not the other, leaving stale documentation.

### Issue Context
`data/hub/` is already ignored under the “Hub identity” section earlier in the file; this PR adds another `data/hub/` entry in the new “Key material and secrets” block.

### Fix Focus Areas
- .gitignore[95-97]
- .gitignore[156-163]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread .gitignore Outdated
jaylfc added 3 commits July 27, 2026 21:55
CodeRabbit was right: the comment said 2026-07-28 but the change is dated
2026-07-27. The date came from a UTC-rolled timestamp rather than the actual
date. A comment that exists to preserve WHY a rule was added should not carry a
wrong WHEN.
qodo was right. dev already ignores data/hub/ (line 96, added in #2042); my
second copy was redundant and the two rationale comments would drift apart.

The premise of my original comment was also wrong: I ran git check-ignore
against a stale local branch rather than origin/dev, so I reported a gap dev had
already closed. The other six patterns ARE genuinely new, and that is what this
PR is now scoped to.
kilo was right that *_private.* is overly broad: it matches api_private.py,
utils_private.ts and similar plausible source names, which would be silently
untracked. Narrowed to the key-material extensions (.pem/.key/.json). Verified
again against every tracked file, and that a _private.py is no longer caught.
A pattern that silently ignores working source is worse than the hole it closes.
@jaylfc

jaylfc commented Jul 27, 2026

Copy link
Copy Markdown
Owner Author

Verdict on all four review findings, verified rather than assumed. Two were right and I acted on both, one is wrong and I proved it, one is deliberate.

qodo, duplicate data/hub/ rule: CORRECT, fixed. dev already ignores data/hub/ at line 96 (added in #2042) and my second copy was redundant with a competing rationale comment that would drift. Removed.

The reason I added it is worth recording, because it is the more useful lesson: I ran git check-ignore against my STALE LOCAL BRANCH rather than origin/dev, so I "found" a gap dev had already closed. I tested the old base, which is precisely the failure this project keeps hitting. The other six patterns really are new, and that is what this PR is now scoped to.

kilo, *_private.* is overly broad: CORRECT, fixed. Verified it matches plausible SOURCE names, not just key material:

api_private.py       -> IGNORED
utils_private.ts     -> IGNORED
helpers_private.tsx  -> IGNORED

Narrowed to *_private.pem, *_private.key, *_private.json. Re-verified against every tracked file (zero hits) and confirmed a _private.py is no longer caught. A pattern that silently un-tracks working source is a worse bug than the hole it closes.

kilo, identity.json is redundant with data/hub/: REFUTED, proved by test. In a scratch repo with ONLY data/hub/ ignored:

.gitignore:1:data/hub/    data/hub/identity.json
(other/place/identity.json and ./identity.json: NOT ignored)

data/hub/ covers that directory only. The bare identity.json pattern is deliberately broader so an identity file written anywhere else is still caught, which is the whole point given the leak came from a path nobody had anticipated. Keeping it.

kilo, *credentials.json is very broad: DELIBERATE, keeping it. It is meant to be broad. Verified it ignores nothing currently tracked, and mesh_credentials.py is source with a .py extension so it is unaffected. For a security ignore, erring broad is correct: a wrongly-ignored fixture is an annoyance solvable with git add -f, a committed credential is an incident. The narrowing above was justified because *_private.* could swallow ordinary source; *credentials.json cannot.

@jaylfc
jaylfc merged commit 077105e into dev Jul 27, 2026
17 checks passed
@jaylfc
jaylfc deleted the chore/secret-ignores branch July 27, 2026 22:44
jaylfc added a commit that referenced this pull request Jul 27, 2026
#2173)

PR #2171 closed the identity/key-material shapes but a plain creds.json still
slipped through: *credentials.json does not match creds.json. @taOS-website-dev
found this running the same audit on its own repo, which is the argument for
having every repo run the check rather than trusting one pass.

Verified on origin/dev before committing: creds.json, my_creds.json and
data/creds.json were all NOT ignored, and 0 of 3100 tracked files become
ignored by the new pattern.
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