trufflesecurity / trufflehog

Find, verify, and analyze leaked credentials
https://trufflesecurity.com
GNU Affero General Public License v3.0
17.39k stars 1.72k forks source link

homebrew - trufflehog updater file permission check #3217

Open sdavids opened 3 months ago

sdavids commented 3 months ago

TruffleHog Version

3.81.8

Trace Output

2024-08-14T13:38:38+02:00   error   trufflehog  error occurred with trufflehog updater 🐷    {"error": "cannot move binary (exit status 1)"}

Expected Behavior

The latest version is installed, the binary does not need to be moved, so no error.

Actual Behavior

TruffleHog exits without doing its thing.

Steps to Reproduce

Non-admin user (i.e. a user which did not execute brew install trufflehog):

$ trufflehog git file://. --only-verified

Environment

Additional Context

I have two users on my macOS: one admin and one regular user.

The admin user is used to manage the homebrew installation.

Also, my macOS runs with a custom umask.

https://support.apple.com/en-us/HT201684

$ printf "umask 077\n" > ~/.zshrc
$ chmod 600 ~/.zshrc
$ sudo launchctl config user umask 077
$ cat /private/var/db/com.apple.xpc.launchd/config/user.plist
$ sudo reboot  

My admin user has a script to invoke homebrew:

#!/usr/bin/env sh

# ~/.local/bin/brew

umask 0022

/opt/homebrew/bin/brew "$@"

Current installation:

$ brew info trufflehog
==> trufflehog: stable 3.81.8 (bottled), HEAD
Find and verify credentials
https://trufflesecurity.com/
Installed
/usr/local/Cellar/trufflehog/3.81.8 (6 files, 111.8MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-08-14 at 13:30:54
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/t/trufflehog.rb
License: AGPL-3.0-only
==> Dependencies
Build: go ✘
==> Options
--HEAD
    Install HEAD version
$  tree -p /usr/local/Cellar/trufflehog
[drwxr-xr-x]  /usr/local/Cellar/trufflehog
└── [drwxr-xr-x]  3.81.8
    ├── [-rw-r--r--]  INSTALL_RECEIPT.json
    ├── [-rw-r--r--]  LICENSE
    ├── [-rw-r--r--]  README.md
    ├── [drwxr-xr-x]  bin
    │   └── [-r-xr-xr-x]  trufflehog
    └── [-rw-r--r--]  sbom.spdx.json

Suggestion

If there is no update pending then TruffleHog should not check whether it can move a potential future update.

amoralesc commented 2 months ago

Hey, had the same problem with a non-root user.

Solved by adding the --no-update flag which omits the update check.