Commit Graph

153 Commits

Author SHA1 Message Date
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
Henry Mercer 5602bd50bf Test loading of ML-powered queries 2022-01-06 11:57:33 +00:00
Henry Mercer 2f4be8e34b Run ML-powered queries for JS security-extended behind feature flag 2022-01-06 11:57:33 +00:00
Edoardo Pirovano bc31f604d3 Add an option to upload some debugging artifacts 2021-11-01 16:12:50 +00:00
Edoardo Pirovano 05fc5a885c Replace safeLoad with load 2021-07-27 22:12:26 +01:00
Arthur Baars f94f1ed663 Rename checkoutPath to either workspacePath or sourceRoot 2021-07-14 13:39:45 +02:00
Andrew Eisenberg 4087f37d90 Add extra integration test for packaging
Also, update the options and inputs documentation.
2021-06-25 10:07:51 -07:00
Andrew Eisenberg 6e577cfca3 Add new packs input to init action
This input allows users to specify which packs to run. It works in
unison with the packs block of the config file and it is similar to
how `queries` works. They both use `+` in the same way.

Note that the `#TODO` in the pr check is still around, but the CLI
is available. I will remove the TODO in the next commit.
2021-06-23 16:08:35 -07:00
Andrew Eisenberg 20aafcd90c Remove unnecessary type assertions 2021-06-10 11:15:03 -07:00
Andrew Eisenberg 96e7de35af Use nullish conversion for packs
Slightly simplifies the `parsePacks` function.
2021-06-09 13:18:27 -07:00
Andrew Eisenberg 1cc5f1d5dd Packaging: Address review comments
1. Better malformed data guard for PackDownloadOutput
2. Fix Packs type
3. Remove TODO in init-action
2021-06-08 10:00:22 -07:00
Andrew Eisenberg 06687e95c8 Avoid using SemVer instances
Use strings instead. They are easier to serialize and deserialize.
2021-06-04 13:34:55 -07:00
Andrew Eisenberg 9b5753ab00 Fix logic for calculating if there are queries to run
During the analyze phase.
2021-06-04 13:23:35 -07:00
Andrew Eisenberg 6cee818bf3 Add better comments and error messages for pack-related changes 2021-06-04 10:18:24 -07:00
Andrew Eisenberg 86a804f9a7 Allow the codeql-action to run packages
This commit adds a `packs` option to the codeql-config.yml file. Users
can specify a list of ql packs to include in the analysis.

For a single language analysis, the packs property looks like this:

```yaml
packs:
  - pack-scope/pack-name1@1.2.3
  - pack-scope/pack-name2   # no explicit version means download the latest
```

For multi-language analysis, you must key the packs block by lanaguage:

```yaml
packs:
  cpp:
    - pack-scope/pack-name1@1.2.3
    - pack-scope/pack-name2
  java:
    - pack-scope/pack-name3@1.2.3
    - pack-scope/pack-name4
```

This implementation adds a new analysis run (alongside custom and 
builtin runs). The unit tests indicate that the correct commands are
being run, but I have not actually tried this with a real CLI.

Also, convert `instanceof Array` to `Array.isArray` since that is
sightly better in some situations. See:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#instanceof_vs_isarray
2021-06-03 15:46:40 -07:00