Skip to content

Conversation

@Daverlo
Copy link
Contributor

@Daverlo Daverlo commented Apr 29, 2020

This PR adds an option for disabling the queries we run default.

A run without the ignore-default-queries set, it runs all the queries: https://github.com/github/codeql-action/runs/629305743?check_suite_focus=true
A run with ignore-default-queries: false, it runs all the queries: https://github.com/github/codeql-action/runs/629307092?check_suite_focus=true
A run with ignore-default-queries: true it only runs the custom queries: https://github.com/github/codeql-action/runs/629310667?check_suite_focus=true

Merge / deployment checklist

  • Run test builds as necessary. Can be on this repository or elsewhere as needed in order to test the change - please include links to tests in otehr repos!
    • CodeQL using init/finish actions
    • 3rd party tool using upload action
  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.

README.md Outdated
### Configuration
You may optionally specify additional queries for CodeQL to execute by using a config file. The queries must belong to a [QL pack](https://help.semmle.com/codeql/codeql-cli/reference/qlpack-overview.html) and can be in your repository or any public repository. You can choose a single .ql file, a folder containing multiple .ql files, a .qls [query suite](https://help.semmle.com/codeql/codeql-cli/procedures/query-suites.html) file, or any combination of the above. To use queries from other repositories use the same syntax as when [using an action](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses).

You can disable the default queries using `ignore-default-queries: true`.
Copy link
Contributor

@robertbrignull robertbrignull Apr 29, 2020

Choose a reason for hiding this comment

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

Any reasons why "ignore" rather than other alternatives? I see it as a non-typical name. Given that the description is "You can disable ..." then it makes me feel it should be called disable-default-queries. I think exclude-default-queries would be another possibility that's slightly more clear than "ignore". We won't be able to change this so we should be happy with the name we pick.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, i like disable.

config.name = parsedYAML.name;
}

if (parsedYAML['ignore-default-queries'] && typeof parsedYAML['ignore-default-queries'] === "boolean") {
Copy link
Contributor

Choose a reason for hiding this comment

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

curious about this, what happens if they put a string in there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jhutchings1
Copy link
Contributor

Thanks for taking the initiative on doing this!

cc: @github/product-docs-dsp because this change will affect the configuration docs.

@hubwriter
Copy link
Contributor

Thanks for the ping Justin. We'll add this to the "Configuring code scanning" topic once this is merged.

README.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be updated to "disable"

Copy link
Contributor

Choose a reason for hiding this comment

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

The behavious here has changed to remove the || [] default value. Some manual testing shows that this will generate an error trying to do push(...undefined).

Please change to queries.push(...(queriesPerLanguage[database] | | [])); or bring back the additionalQueries as it was before.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I suspected, here's what happens if a repo doesn't define any custom queries: https://github.com/Anthophila/test-electron/runs/632587165?check_suite_focus=true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I've fixed it and triggered a build without custom queries for testing it https://github.com/github/codeql-action/runs/632605173?check_suite_focus=true

@robertbrignull robertbrignull self-assigned this Apr 30, 2020
@Daverlo Daverlo force-pushed the disable-default-queries branch from 3bb38db to 6997a21 Compare April 30, 2020 09:11
Copy link
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

I tested as well in a couple of cases and I agree it's working now.

For example, what happens when you disable all queries. See https://github.com/Anthophila/test-electron/runs/632714499?check_suite_focus=true
The answer is that the codeql fails, which is reasonable, but it only does so after extracting all the code and it prints an error message which tries to be useful but for code scanning isn't very because the user can't call codeql directly. I'll raise an issue to improve this behaviour in the future: https://github.com/github/dsp-code-scanning/issues/1133.

However I think we also need signoff from one of @anaarmas or @krukow as per Justin's comment.

@krukow
Copy link

krukow commented Apr 30, 2020

Looks good to me - I have no concerns. Thanks for the ping and making completing this work.

@Daverlo Daverlo merged commit 1cdde3e into master Apr 30, 2020
@chrisgavin chrisgavin deleted the disable-default-queries branch September 2, 2020 13:24
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.

8 participants