Skip to content

fix: am-i-compromised portability, host [dir], README - #24

Open
IsaacBell wants to merge 4 commits into
mainfrom
fix/am-i-compromised-portability
Open

IsaacBell wants to merge 4 commits into
mainfrom
fix/am-i-compromised-portability

Conversation

@IsaacBell

@IsaacBell IsaacBell commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

User description

Follow-up to the 1.2.0 host audit. Makes it work on more setups and fixes what a portability review found.

  • Scanner no longer dies on the macOS system bash (needs 4.2+; re-runs under a newer bash if installed, otherwise says what to install)
  • host takes an optional project dir, defaults to the current folder, no root or sudo
  • host: ZDOTDIR and XDG_CONFIG_HOME, empty-args crash on bash 3.2, no claim that persistence was checked on an unsupported OS, fewer false positives (toolchain dirs, bare sendMessage, hooks in ~/.local/bin)
  • Listener port is read from the URL authority, not a greedy regex
  • README rewritten: highlights, overview, host audit section, corrected requirements
  • 26 pending (skipped) tests for known gaps, so they show up in every run

Checks: shellcheck, shfmt, 235 bats tests (26 skipped), scanner gate, Semgrep clean with suppressions off.


CodeAnt-AI Description

Make project scanning portable and host audits safer across environments

What Changed

  • Project scans now detect unsupported macOS Bash versions, automatically use an available newer Bash, or explain how to install one instead of failing with shell errors.
  • Host audits accept an optional project directory, default to the current directory, and validate invalid paths without requiring root or sudo.
  • Host checks honor relocated configuration files and Zsh startup directories, correctly identify listener ports, and avoid claiming persistence was checked on unsupported operating systems.
  • Reduced false positives for common toolchain and shell-framework files, ordinary sendMessage functions, and hooks installed in standard language-tool directories.
  • Documentation now explains project scans, host audits, requirements, findings, and supported usage; tests cover portability and environment-specific behavior.

Impact

✅ Clear scanner guidance on macOS
✅ Host audits work against any selected project
✅ Fewer false security findings

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 8b87d3c Sep 26, 2026 · 04:23 04:25

@codeant-ai

codeant-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 26, 2026
@codeant-ai

codeant-ai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit: 8b87d3c0
Scan Time: 2026-09-26 04:23:51 UTC

✅ Overall Status: PASSED

Quality Gate Details

Quality Gate Status Details
Secrets ✅ PASSED 0 secrets found, 1 false positive secret suppressed
Duplicate Code ✅ PASSED 0.0% duplicated
SAST ✅ PASSED No security issues
IAC ✅ PASSED No IAC issues
SCA (Dependencies) ✅ PASSED Rating S: No vulnerabilities

View Full Results

Comment on lines +643 to 644
RC_EXEMPT='/[.](cargo|deno|bun|rvm|nvm|pyenv|rbenv|sdkman|asdf|volta|fnm|ghcup|opam|orbstack|oh-my-zsh|zinit|zplug|antigen|zprezto|fzf|tmux|conda|local/bin|config/(fish|zsh|nvm|gh))/' \
rc_rule "$f" "$disp" MEDIUM "A startup file loads a script from a writable or hidden directory" '(^|[^[:alnum:]_])(source|\.)[[:space:]]+[^#]*(([$]home|~)?/(tmp|var/tmp|private/tmp|var/folders|users/shared|downloads)/|application support|/[.][[:alnum:]_-]+/)' "Confirm you know this file. A sourced script runs with the same access you have."

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: RC_EXEMPT skips the whole line when any trusted toolchain path appears, allowing a second malicious source from /tmp or another hidden directory on that line to evade detection.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Incorrect condition logic

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/am-i-compromised/bin/host-audit.sh
**Line:** 643:644
**Comment:**
	*Incorrect Condition Logic: `RC_EXEMPT` skips the whole line when any trusted toolchain path appears, allowing a second malicious source from `/tmp` or another hidden directory on that line to evade detection.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +691 to +696
if [[ -n "${ZDOTDIR:-}" && "$ZDOTDIR" != "$HOME_DIR" && -d "$ZDOTDIR" ]]; then
for f in "$ZDOTDIR"/.zshrc "$ZDOTDIR"/.zprofile "$ZDOTDIR"/.zshenv "$ZDOTDIR"/.zlogin; do
[[ -f "$f" ]] || continue
audit_rc_file "$f" "ZDOTDIR/${f##*/}"
done
fi

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: When ZDOTDIR is assigned inside ~/.zshenv, this inherited environment value is empty, so the actual zsh startup directory is never scanned.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Possible bug

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/am-i-compromised/bin/host-audit.sh
**Line:** 691:696
**Comment:**
	*Possible Bug: When `ZDOTDIR` is assigned inside `~/.zshenv`, this inherited environment value is empty, so the actual zsh startup directory is never scanned.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +868 to +871
# Language-toolchain bin directories are where pipx, cargo, bun and friends install tools.
if has "$cmd" '/\.(local/bin|cargo/bin|bun/bin|volta/bin|nvm/versions|pnpm)/'; then
return 1
fi

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: The early return exempts commands containing a toolchain-looking path even when the same hook also loads code from another dangerous hidden or writable path.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Security

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/am-i-compromised/bin/host-audit.sh
**Line:** 868:871
**Comment:**
	*Security: The early return exempts commands containing a toolchain-looking path even when the same hook also loads code from another dangerous hidden or writable path.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +55 to +59
for newer_bash in /opt/homebrew/bin/bash /usr/local/bin/bash /opt/local/bin/bash /home/linuxbrew/.linuxbrew/bin/bash; do
if [[ -x "$newer_bash" ]] && "$newer_bash" -c '((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2)))' 2>/dev/null; then
exec "$newer_bash" "${BASH_SOURCE[0]}" "$@"
fi
done

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: Under old Bash, a compatible interpreter located elsewhere on PATH is ignored, so the source scan fails even though the promised newer Bash is installed and available.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** apps/am-i-compromised/bin/scanner.sh
**Line:** 55:59
**Comment:**
	*Api Mismatch: Under old Bash, a compatible interpreter located elsewhere on `PATH` is ignored, so the source scan fails even though the promised newer Bash is installed and available.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Sep 26, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. URLs with a query directly after the authority, such as 127.0.0.1:4319?x=1, retain the query in p, so valid loopback URLs lose listener attribution.

Logic error · apps/am-i-compromised/bin/host-audit.sh:735-744

This branch was successfully deployed

1 active deployment
staging — 8b87d3c0 Deployed Sep 26, 2026 by IsaacBell via Run CodeAnt CI scan #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant