Skip to content

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

Open

Description

@ericwb

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

Activity

  1. added
    bug
    on Jul 23, 2024
  2. ericwb commented on Jul 23, 2024

    @ericwb
    ContributorAuthor

    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.

  3. ericwb commented on Jul 24, 2024

    @ericwb
    ContributorAuthor

    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.

  4. added theissue type on May 5, 2025
  5. removed
    bug
    on May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions