Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tartufo pre-commit command does not scan files committed via git commit -am command #412

Open
jwinders-godaddy opened this issue Nov 29, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@jwinders-godaddy
Copy link

jwinders-godaddy commented Nov 29, 2022

🐛 Bug Report

To Reproduce

Using tartufo 3.2.1 or 3.3.1

Following steps assume a local .pre-commit-config.yaml file with the following content:

repos:
- repo: https://github.com/godaddy/tartufo
  rev: v3.3.1
  hooks:
  - id: tartufo
mkdir tartufo-pre-commit-test
cd tartufo-pre-commit-test/
git init
touch test_file
git status
git add .
git commit
pre-commit install
cat test_file # file is empty
openssl rand -base64 40 > test_file # add some content that tartufo would flag
git commit -am "test" # this should result in tartufo complaining about the content, but with issue shows passing scan

Expected Behavior

Tartufo:pre-commit should scan files not explicitly staged via git add, but added via git commit -am
report issue.

Perhaps additionally, the command should indicate when there are no files being operated on by the command.

Environment

@jwinders-godaddy jwinders-godaddy added the bug Something isn't working label Nov 29, 2022
@jwinders-godaddy jwinders-godaddy changed the title Tartufo pre-commit command does not scan files committed via git -am command Tartufo pre-commit command does not scan files committed via git commit -a command Nov 29, 2022
@jwinders-godaddy jwinders-godaddy changed the title Tartufo pre-commit command does not scan files committed via git commit -a command Tartufo pre-commit command does not scan files committed via git commit -am command Nov 29, 2022
@mgaspar-godaddy
Copy link
Contributor

I'll add to this that I tested back to version 3.1.3 and found that the pre-commit check would fail and present tartufo output indicating the offending content. However, as of version 3.1.4 the same test results in the pre-commit check passing.

Looking at v3.1.3...v3.1.4 it looks like #351 introduced a cached=True option into the code.

Pulling down the latest 3.3.1 version and taking out line 962

cached=True,

and testing in my dev environment with poetry I found removing the cached=True line results in the pre-commit check failing as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants