detect-secrets
detect-secrets copied to clipboard
FileNotFoundError in `LineGetter.open_file`
We had a secret referencing a file in the secrets baseline, and then that file was deleted, the next time detect-secrets (v1.2.0) ran, it crashed with:
FileNotFoundError: [Errno 2] No such file or directory: ...
https://github.com/Yelp/detect-secrets/blob/70e6cf69f2d544a49729039a374d86d7b3e472d9/detect_secrets/audit/common.py#L146-L148
https://github.com/Yelp/detect-secrets/blob/70e6cf69f2d544a49729039a374d86d7b3e472d9/detect_secrets/audit/common.py#L156-L158
https://github.com/Yelp/detect-secrets/blob/70e6cf69f2d544a49729039a374d86d7b3e472d9/detect_secrets/audit/common.py#L82-L90
https://github.com/Yelp/detect-secrets/blob/70e6cf69f2d544a49729039a374d86d7b3e472d9/detect_secrets/audit/report.py#L27-L43
https://github.com/Yelp/detect-secrets/blob/70e6cf69f2d544a49729039a374d86d7b3e472d9/detect_secrets/main.py#L132-L140
Hi @jsoref, thanks for bringing up this issue to us. We will take a look at this issue in the next few days and keep you posted on it. Stay tuned!
@jsoref Hello. I just tested deleting a python file which had existing secrets in the baseline file. This ran fine and the secrets were deleted from the baseline file. Can you provide more information on the file you deleted?
@jsoref Can you please some more information regarding "the next time detect-secrets (v1.2.0) ran"? - Can you explain what command you are running when running detect-secrets? Is it pre-commit or CLI?
We're using https://github.com/secret-scanner/action/ to wrap detect-secrets.
The code in question is roughly: https://github.com/secret-scanner/action/blob/33d6b0b0b5f0cd113651222c196e07799d2c3d21/detect-new-secrets.sh#L30-L33
It's possible that the first detect-secret command (scan) failed and the second (audit) ran and failed (and that it perhaps shouldn't have been run if the first failed).
I'll see if I can create a sample repository that can reproduce the problem...
@Anu48 just tripped on this, I might see if I can get her to create a reduced test case...