Commit Graph

167 Commits

Author SHA1 Message Date
Andrew Eisenberg 1a17c59fb0 More renaming
Avoid usage of "Feature Flag" unless we are talking specifically about
the response from github features api. Otherwise, use terms like
"Toggleable features".

Note both "toggleable" and "togglable" appear to be valid spellings of
the word. I chose the first for no good reason.
2022-10-07 11:33:32 -07:00
Andrew Eisenberg 6de05e4b24 Rename FeatureFlag -> Feature 2022-10-06 13:06:10 -07:00
Andrew Eisenberg e5c3375225 Refactor handling of feature flags
This commit centralizes how feature flags are handled. All feature flags
must now add an entry in the `featureFlagConfig` dictionary. This
dictionary associates the flag with an environment variable name and
optionally a minimum version for CodeQL.

The new logic is:

- if the environment variable is set to false: disabled
- if the minimum version requirement specified and met: disabled
- if the environment variable is set to true: enable
- Otherwise check feature flag enablement from the server
2022-10-05 16:40:56 -07:00
Andrew Eisenberg 5960ce1190 Extract logging statements to separate function 2022-10-03 09:35:40 -07:00
Andrew Eisenberg 6ace05baa3 Add logging statements declaring state of the cli_config_file_enabled
It's possible to determine this otherwise, but this makes it easier to
spot.
2022-10-01 12:03:01 -07:00
Andrew Eisenberg e37b0d6470 Add the CliConfigFileEnabled feature flag
Also, wire it up to the `useCodeScanningConfigInCli` function.
2022-09-27 07:58:31 -07:00
Andrew Eisenberg 6085805a3a Append / to end of registries url
Avoids a bug in 2.10.4. Also, add some better handling for invalid
registries blocks.
2022-09-08 08:00:24 -07:00
Andrew Eisenberg 4fa3e8b483 Gate the new registries input behind version constraints 2022-09-07 14:38:44 -07:00
Andrew Eisenberg bf97a6da5b Apply suggestions from code review 2022-09-06 10:41:32 -07:00
Andrew Eisenberg abdf26c28f Convert from json to yaml for registries input 2022-09-02 15:03:51 -07:00
Andrew Eisenberg e9b47b1898 Change to using a single input 2022-09-01 16:07:26 -07:00
Andrew Eisenberg 0e98efa2bb Add support for downloading packs from GHES
This change adds:

- new `registries` block allowed in code scanning config file
- new `registries-auth-tokens` input in init action
- Change the downloadPacks function so that it accepts new parameters:
    - registries block
    - api auth
- Generate a qlconfig.yml file with the registries block if one is
  supplied. Use this file when downloading packs.
- temporarily set the `GITHUB_TOKEN` and `CODEQL_REGISTRIES_AUTH` based
  on api auth

TODO:

1. integration test
2. handle pack downloads when the config is generated by the CLI
2022-08-30 10:04:30 -07:00
Andrew Eisenberg 7294b404d8 Fix call to endGroup
Also, rename variable and change a comment.
2022-08-30 09:16:05 -07:00
Andrew Eisenberg 0a2b0d236c Moves calls to pack download to the init action
This ensures all steps to gather queries happens in the init action.
This is where checking out queries in other repos happens as well.
2022-08-26 16:04:57 -07:00
Andrew Eisenberg ac92a02de7 Merge remote-tracking branch 'upstream/main' into aeisenberg/better-error-message 2022-08-23 09:29:19 -07:00
Henry Mercer c72f566aae Explicitly import performance for Node 12 compatibility 2022-08-22 12:59:22 +01:00
Edoardo Pirovano b29194f0ac Address review comments from @henrymercer 2022-08-16 13:30:49 +01:00
Edoardo Pirovano 4139682b64 Add telemetry for TRAP caching 2022-08-16 11:54:31 +01:00
Andrew Eisenberg fba13b0092 More readable error message for invalid queries block
When someone creates an invalid `queries` entry in the codeql config
file, like this:

```
queries:
  - foo.ql
```

THe error message is confusing, looking like this:

```
  Error: Cannot use 'in' operator to search for 'uses' in ql/ql/src
  TypeError: Cannot use 'in' operator to search for 'uses' in ql/ql/src
      at loadConfig (/home/runner/work/_actions/github/codeql-action/71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca/lib/config-utils.js:577:41)
```

With this change, the error message is more comprehensible:

`queries must be an array, with each entry having a 'uses' property`
2022-08-15 07:56:00 -07:00
Andrew Eisenberg fa2bc211fd Merge branch 'aeisenberg/unrevert-query-filters' into aeisenberg/fix-config-files 2022-08-11 14:57:16 -07:00
Andrew Eisenberg a09a029937 Fix failing test and address PR comments 2022-08-11 09:56:08 -07:00
Andrew Eisenberg 2314063848 Add the defaultAugmentationProperties constant
This makes some syntax in tests somewhat simpler.
2022-08-10 15:42:45 -07:00
Andrew Eisenberg 0403fb7d8c Merge branch 'main' into aeisenberg/fix-config-files 2022-08-10 15:39:35 -07:00
Andrew Eisenberg 44f42da9ca Merge branch 'main' into aeisenberg/unrevert-query-filters 2022-08-10 15:22:40 -07:00
Edoardo Pirovano 6df93613d7 Address review comments from @henrymercer 2022-08-09 18:37:22 +01:00
Edoardo Pirovano 8f867dcb21 Introduce TRAP caching 2022-08-05 17:48:05 +01:00
Andrew Eisenberg 01d16b1e01 Merge branch 'main' into aeisenberg/fix-config-files 2022-07-13 14:05:48 -07:00
Henry Mercer 4792297702 Fix test failures on Windows related to path separators 2022-06-29 18:59:32 +01:00
Andrew Eisenberg 6fabde2be8 Add packs and queries from input
This commit adds the packs and queries from the actions input to the
config file used by the CodeQL CLI.

When the `+` is used, the actions input value is combined with the
config value and when it is not used, the input value overrides the
config value.

This commit also adds a bunch of integration tests for this feature.
In order to avoid adding too many new jobs, all of the tests are
run sequentially in a single job (matrixed across relevant operating
systems and OSes).
2022-06-28 14:07:51 -07:00
Henry Mercer 41d6ac4d2a Remove toolcache decorator
This decorator enabled us to use the functionality of the Actions
toolcache within the runner too.
Now that we've deleted the runner we no longer need it.
2022-06-28 18:22:09 +01:00
Andrew Eisenberg 2a70419420 Revert "Revert "Add capability to filter queries #1098""
This reverts commit 99d4397d88.
2022-06-27 13:13:55 -07:00
Andrew Eisenberg 1653a84fbc Allow scans with packs for languages not being scanned
Previously, we were being too strict about checking that a pack's
language was being scanned. It was a failure if a pack language
was specified for a language not being scanned.
2022-06-22 14:37:31 -07:00
Andrew Eisenberg 99d4397d88 Revert "Add capability to filter queries #1098"
https://github.com/github/codeql-action/pull/1098
This reverts commit 777b778409.
This reverts commit 59ca9b59cb.
This reverts commit eec34d5f05.
This reverts commit 40b280032c.
2022-06-21 13:49:33 -07:00
Andrew Eisenberg 59ca9b59cb Extract query-filters test into a composite action
Removes duplicated yaml.

Also add some better typings.
2022-06-15 16:32:33 -07:00
Andrew Eisenberg 40b280032c Add capability to filter queries
This change adds a `query-filters` property to the codeql-config file.

This property is an array of `exclude`/`include` entries for a query
suite. These filters are appended to the generated query suite files
and used to filter queries after they are selected.

A related change is that now, all pack references are run in a single
query suite, which has the query filters appended to them.
2022-06-14 12:07:49 -07:00
Henry Mercer 533ce91971 Merge remote-tracking branch 'origin/main' into henrymercer/run-atm-on-windows 2022-05-11 19:32:14 +01:00
Andrew Eisenberg 06b15c22b1 Allow pack specifiers to include paths
Also, this cleans up our pack-related integration tests.
We are now testing with the most recent CLIs.
2022-04-28 17:14:30 -07:00
Henry Mercer d9e30cb001 Run ML-powered queries on Windows with CodeQL CLI 2.9.0+ 2022-04-28 19:18:15 +01:00
Henry Mercer 2c03704a6c Allow the version of the ML-powered pack to depend on the CLI version 2022-03-31 14:58:29 +01:00
Henry Mercer e83a1d469e Stop running ML-powered queries on Windows 2022-03-30 18:05:12 +01:00
Edoardo Pirovano d625a00cee Start running ATM queries again 2022-03-28 09:06:45 +01:00
Tobias Speicher 0a713019c3 refactor: replace deprecated String.prototype.substr()
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-20 17:08:43 +01:00
Henry Mercer 03c64ef07d Add more documentation for ML-powered JS queries status report
Also be more explicit about which version strings are reportable in
the code.
2022-02-07 16:46:53 +00:00
Henry Mercer f888be73ce Nit: Simplify code with optional chaining 2022-02-07 14:24:40 +00:00
Henry Mercer 9f32fc9b9d Only add ML-powered queries pack if the user didn't manually request it 2022-02-04 16:34:17 +00:00
Henry Mercer 1cddec9558 Add ML-powered queries enablement to init status report
We report this information in the `init` status report rather than the
`analyze` status report so we can gather data about timeouts.
2022-02-03 16:29:28 +00:00
Edoardo Pirovano e677af3fd0 Make name of debugging artifact and DB within it configurable 2022-01-07 15:10:26 +00:00
Henry Mercer e7fe6da378 Allow patch version of ML-powered queries pack to be bumped 2022-01-06 11:58:03 +00:00
Henry Mercer 2159631658 Only run ML-powered queries with v2.7.5 or newer of the CLI 2022-01-06 11:58:03 +00:00
Henry Mercer efded22908 Bump the version of the ATM query pack to 0.0.2 2022-01-06 11:57:33 +00:00