FileNotFoundError in `LineGetter.open_file`
jsoref opened this issue · 5 comments
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: ...
detect-secrets/detect_secrets/audit/common.py
Lines 146 to 148 in 70e6cf6
detect-secrets/detect_secrets/audit/common.py
Lines 156 to 158 in 70e6cf6
detect-secrets/detect_secrets/audit/common.py
Lines 82 to 90 in 70e6cf6
detect-secrets/detect_secrets/audit/report.py
Lines 27 to 43 in 70e6cf6
detect-secrets/detect_secrets/main.py
Lines 132 to 140 in 70e6cf6
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...