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

Error when invalid rule ID or category name given for enable/disable #536

Open
ericwb opened this issue Jul 23, 2024 · 2 comments
Open

Error when invalid rule ID or category name given for enable/disable #536

ericwb opened this issue Jul 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ericwb
Copy link
Contributor

ericwb commented Jul 23, 2024

Describe the bug
The enable and disable argument of the CLI allows someone to filter what rules are enabled.

To Reproduce

precli --enable=JAV001-JAV999 tests/unit/rules/java/stdlib/javax_servlet_http/examples/CookieSecureFalse.java

Expected behavior
In this example, JAV999 doesn't exist. The CLI really should vet the parameters given.

Version

precli 0.5.12.dev4
Copyright 2024 Secure Sauce LLC
License BUSL-1.1: Business Source License 1.1 <https://spdx.org/licenses/BUSL-1.1.html>
  Python 3.12.4 (main, Jun 25 2024, 11:01:48) [Clang 15.0.0 (clang-1500.3.9.4)]

Additional context
n/a

@ericwb ericwb added the bug Something isn't working label Jul 23, 2024
@ericwb
Copy link
Contributor Author

ericwb commented Jul 23, 2024

Can load all the rule ID names up front in the CLI main

    all_rules = [
        rule.name 
        for lang in ("go", "java", "python") 
        for rule in metadata.entry_points(group=f"precli.rules.{lang}")
    ]

However, a category name can also be given as the argument, therefore, we need to load the rule to discover all the valid category options.

@ericwb
Copy link
Contributor Author

ericwb commented Jul 24, 2024

It may be equally useful to be able to specify a wide range without having to know the number of the largest indexed rule ID. Helps to future proof code and CLI usage in a way.

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

1 participant