Skip to content

How to disable particular rule by its ID from GitHub workflow? #7937

Closed

Description

@sungam3r

Sorry but I did not find the answer in docs. For example, I want to disable cs/linq/missed-where.

#7937 (comment)

Activity

  1. aeisenberg commented on Feb 10, 2022

    @aeisenberg
    Contributor

    There is no simple way to do this. You could create a custom query suite. In your workflow's codeql init step, you would specify a config file to use:

    - uses: github/codeql-action/init@v1
      with:
        config-file: ./.github/codeql/codeql-config.yml

    And then in the config file, you specify custom queries:

    disable-default-queries: true
    queries:
      - uses: ./github/codeql/suite.qls

    And finally, you need to create the query suite itself:

    - from: codeql/csharp-queries
      apply: codeql-suites/csharp-security-and-quality.qls
    - exclude:
        query filename: MissedWhereOpportunity.ql

    Using this, you will have control over exactly which queries you want to run.

  2. sungam3r commented on Feb 10, 2022

    @sungam3r
    Author

    Understandable but I know the opposite - what queries I don't want to run, i.e. opt-out behavior instead of opt-in.

  3. sungam3r commented on Feb 10, 2022

    @sungam3r
    Author

    I see a lof of false positives (actually all results in case of aforementioned rule) and I want to disable this particular rule and continue to review security report.

  4. aeisenberg commented on Feb 11, 2022

    @aeisenberg
    Contributor

    With the above suggestion, you can choose to remove any single query from analysis.

    Alternatively, if you just want to focus on security queries, you may just want to run security-extended queries. Just change: queries: security-and-quality to queries: security-extended.

  5. sungam3r commented on Feb 11, 2022

    @sungam3r
    Author

    I understand, thanks for your explanation, but I don't want to bother with manually crafted query suites (and their combinations) and maintain them updating to be in-sync with source. Please consider adding an option in workflows to exclude particular rules.

  6. aeisenberg commented on Feb 11, 2022

    @aeisenberg
    Contributor

    Thank you for your suggestion. We will keep this under consideration.

  7. aeisenberg commented on Jun 15, 2022

    @aeisenberg
    Contributor

    Will be fixed here: github/codeql-action#1098

  8. aeisenberg commented on Jun 16, 2022

    @aeisenberg
    Contributor

    Available in next release of the codeql-action. Documentation still to come.

  9. sungam3r commented on Jun 18, 2022

    @sungam3r
    Author

    Thanks.

  10. scherersebastian commented on Sep 12, 2022

    @scherersebastian

    So you have to create a separate file just to disable / exclude a query - @aeisenberg ?

  11. aeisenberg commented on Sep 12, 2022

    @aeisenberg
    Contributor

    That's correct. We might consider alternate syntaxes later, but this is the current behaviour.

  12. sungam3r commented on Apr 14, 2023

    @sungam3r
    Author

    @aeisenberg Hi, what is the current status of this issue? I see #1127 that reverts something, but I did not understand what exactly. So how can I disable particular rule for now?

  13. sungam3r commented on Apr 18, 2023

    @sungam3r
    Author

    Probably I do it wrong in graphql-dotnet/parser#301.

    https://github.com/graphql-dotnet/parser/actions/runs/4728548769/jobs/8390195457?pr=301 :

    Error: Invalid query filter.
    Query filter must have exactly one key: {"exclude":null,"id":"cs/linq/missed-where"}
    

    https://github.com/graphql-dotnet/parser/actions/runs/4728592373/jobs/8390280163?pr=301

    Error: Invalid query filter.
    Query filter must have exactly one key: {"exclude":null,"id":["cs/linq/missed-where"]}
    
  14. aeisenberg commented on Apr 18, 2023

    @aeisenberg
    Contributor

    See my commenton your PR.

  15. sungam3r commented on Apr 19, 2023

    @sungam3r
    Author

    Thanks.

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

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions