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

Clearer usage commands #51

Merged
merged 2 commits into from
Jul 6, 2018
Merged

Clearer usage commands #51

merged 2 commits into from
Jul 6, 2018

Conversation

domanchi
Copy link
Contributor

@domanchi domanchi commented Jul 5, 2018

Previously, scanning and auditing were command line flags. This meant that technically, they could be used in the following manner:

$ detect-secrets --audit .secrets.baseline --scan test_data

which doesn't really make any sense.

This change clarifies the API a little, so we avoid this situation.

@domanchi domanchi requested a review from KevinHock July 5, 2018 16:18
Copy link
Collaborator

@KevinHock KevinHock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does --help look like? (i.e. the usage message.)

@@ -194,6 +230,11 @@ def consolidate_args(args):

:param args: output of `argparse.ArgumentParser.parse_args`
"""
# Using `--hex-limit` as a canary to identify whether this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This seems a little hacky.

# Favors --import argument over stdin.
if getattr(args, 'import'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ Much better :D

@domanchi
Copy link
Contributor Author

domanchi commented Jul 6, 2018

$ detect-secrets --help
usage: detect-secrets [-h] [-v] [--version] {scan,audit} ...

positional arguments:
  {scan,audit}

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Verbose mode.
  --version      Display version information.
$
$ detect-secrets scan -h
usage: detect-secrets scan [-h] [--exclude EXCLUDE]
                           [--import OLD_BASELINE_FILE] [--string [STRING]]
                           [--base64-limit [BASE64_LIMIT]]
                           [--hex-limit [HEX_LIMIT]] [--no-hex-string-scan]
                           [--no-base64-string-scan] [--no-private-key-scan]
                           [path]

positional arguments:
  path                  Scans the entire codebase and outputs a snapshot of
                        currently identified secrets.

optional arguments:
  -h, --help            show this help message and exit
  --exclude EXCLUDE     Pass in regex to specify ignored paths during
                        initialization scan.
  --import OLD_BASELINE_FILE
                        Import settings from previous existing baseline.

plugins:
  Configure settings for each secret scanning ruleset. By default, all
  plugins are enabled unless explicitly disabled.

  --base64-limit [BASE64_LIMIT]
                        Sets the entropy limit for high entropy strings. Value
                        must be between 0.0 and 8.0.
  --hex-limit [HEX_LIMIT]
                        Sets the entropy limit for high entropy strings. Value
                        must be between 0.0 and 8.0.
  --no-hex-string-scan  Disables scanning for hex high entropy strings
  --no-base64-string-scan
                        Disables scanning for base64 high entropy strings
  --no-private-key-scan
                        Disables scanning for private keys.
$
$ detect-secrets audit --help
usage: detect-secrets audit [-h] filename

positional arguments:
  filename    Audit a given baseline file to distinguish the difference
              between false and true positives.

optional arguments:
  -h, --help  show this help message and exit

@domanchi domanchi merged commit 116dfa2 into master Jul 6, 2018
@KevinHock
Copy link
Collaborator

Random: What is your opinion on adding that to the README? To much/ugly or helpful? e.g. https://github.com/python-security/pyt#usage

@domanchi
Copy link
Contributor Author

domanchi commented Jul 6, 2018

¯\_(ツ)_/¯

I've seen it some places; no real preference. I figure, examples to get going are better, and if people want the "advanced" options, they can read -h themselves.

The README needs to be updated with this API change, but I'll do that with the version bump.

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

Successfully merging this pull request may close these issues.

None yet

2 participants