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

--audit crashes on non-existant files #54

Closed
LouisTrezzini opened this issue Jul 9, 2018 · 2 comments
Closed

--audit crashes on non-existant files #54

LouisTrezzini opened this issue Jul 9, 2018 · 2 comments
Assignees

Comments

@LouisTrezzini
Copy link
Contributor

When you audit a baseline, if a file has been removed, it crashes the audit command and you lose all your progress.

Progress should be saved after each keystroke, and system calls should be protected by a try ... catch block

How to reproduce

  1. Create a baseline with secrets
  2. Remove one of the files referenced in the baseline
  3. Audit the baseline
@KevinHock KevinHock self-assigned this Jul 9, 2018
@KevinHock
Copy link
Collaborator

Here lies the relevant stack trace

Secrets Left: 1/1
Filename:     test_secrets/file_with_secrets.py
----------
sed: can't read test_secrets/file_with_secrets.py: No such file or directory
Traceback (most recent call last):
  File "/kevin/code/gh_detect_secrets/detect-secrets/three_six/bin/detect-secrets", line 11, in <module>
    sys.exit(main())
  File "/kevin/code/gh_detect_secrets/detect-secrets/three_six/lib/python3.6/site-packages/detect_secrets/main.py", line 43, in main
    audit.audit_baseline(args.audit[0])
  File "/kevin/code/gh_detect_secrets/detect-secrets/three_six/lib/python3.6/site-packages/detect_secrets/core/audit.py", line 40, in audit_baseline
    original_baseline['plugins_used'],
  File "/kevin/code/gh_detect_secrets/detect-secrets/three_six/lib/python3.6/site-packages/detect_secrets/core/audit.py", line 121, in _print_context
    plugin_settings,
  File "/kevin/code/gh_detect_secrets/detect-secrets/three_six/lib/python3.6/site-packages/detect_secrets/core/audit.py", line 212, in _get_secret_with_context
    filename,
  File "subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['sed', '-n', '1,9p', 'test_secrets/file_with_secrets.py']' returned non-zero exit status 2.
``

@KevinHock KevinHock changed the title Auditing is not robust --audit crashes on non-existant files Jul 10, 2018
@KevinHock
Copy link
Collaborator

Fixed by #56

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

No branches or pull requests

2 participants