Skip to content

fix(rules): match PATH lines piped through tee into a login file - #1045

Merged
kyle-elliott-asymptote merged 2 commits into
Asymptote-Labs:mainfrom
rudycelekli:fix/path-injection-tee-into-login-file
Oct 26, 2026
Merged

kyle-elliott-asymptote merged 2 commits into
Asymptote-Labs:mainfrom
rudycelekli:fix/path-injection-tee-into-login-file

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

What was wrong

path-injection-into-login-file requires a >/>> redirect into the startup file. The other everyday way to append a line, piping it into tee, was not covered. So these went unflagged:

  • echo 'export PATH=/tmp/bin:$PATH' | tee -a ~/.bashrc
  • echo 'export PATH=/srv/bin:$PATH' | sudo tee /etc/profile.d/custom.sh

sudo tee is also the usual way to write a root-owned file such as /etc/profile.d/*, because sudo echo ... >> file does not work.

The fix

The write clause accepts tee as well as a redirect: (>>?|\btee\b)\s*[^|;&]*(<startup files>). A read like grep PATH ~/.bashrc | tee path-notes.txt still does not match, because the tee target is not a startup file. I updated the description and bumped the rule version to 2.

Tests

I added two match fixtures and one no_match fixture. Before the fix:

path-injection-into-login-file/export_path_tee_into_bashrc: expected match, got no_match
path-injection-into-login-file/path_tee_into_profile_d: expected match, got no_match

What I ran

cd pkg/asymptoteobserve && go test -count=1 ./...   # all ok (go1.27.2)

@kyle-elliott-asymptote
kyle-elliott-asymptote merged commit e9a2d8d into Asymptote-Labs:main Oct 26, 2026
22 checks passed
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