FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow the codeql-action to run packages by aeisenberg · Pull Request #545 · github/codeql-action · GitHub

Allow the codeql-action to run packages - #545

Merged
aeisenberg merged 15 commits into
mainfrom
aeisenberg/pack-run
Jun 10, 2021
Merged

aeisenberg merged 15 commits into
mainfrom
aeisenberg/pack-run

Conversation

Copy link
Copy Markdown
Contributor

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:

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:

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

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

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
aeisenberg marked this pull request as draft June 3, 2021 22:49

edoardopirovano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Mostly looks good, a few minor comments/questions

Comment thread src/config-utils.ts
Comment thread src/analyze.ts Outdated
Comment thread src/codeql.ts
Comment thread src/codeql.ts Outdated
Comment thread src/codeql.ts Outdated
Comment thread src/config-utils.test.ts Outdated
Comment thread src/config-utils.ts
Comment thread src/config-utils.ts Outdated

Copy link
Copy Markdown
Contributor

Is now a good point to create a feature branch?

Copy link
Copy Markdown
Contributor Author

Sure. I'll create one now.

aeisenberg changed the base branch from main to packs/v1 June 4, 2021 17:19
aeisenberg force-pushed the aeisenberg/pack-run branch from 1c3dec0 to 9b5753a Compare June 4, 2021 20:23
Use strings instead. They are easier to serialize and deserialize.
aeisenberg force-pushed the aeisenberg/pack-run branch 2 times, most recently from dfde222 to 5135e45 Compare June 4, 2021 21:07
Comment thread src/codeql.ts Outdated
aeisenberg force-pushed the aeisenberg/pack-run branch 2 times, most recently from 9985119 to 0aac515 Compare June 6, 2021 06:05
Comment thread src/config-utils.ts Outdated
languages: Language[],
configFile: string
) {
const packs = {} as Packs;

RA80533 Jun 6, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should Packs be updated such that {} would be valid? This sort of pattern appears in a few other places in the codebase. It might be that empty objects are intended to be valid for various configuration types (in which case it would make sense to update those types to allow for such shapes to be valid).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I had the type definition wrong. Originally, it was:

export type Packs = Record<Partial<Language>, PackWithVersion[]>;

But it should have been:

export type Packs = Partial<Record<Language, PackWithVersion[]>>;

Comment thread src/config-utils.ts Outdated

// Exported for testing
export function parsePacks(
packsByLanguage: string[] | Record<string, string[]> | undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What is the use case for packsByLanguage to be undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This parameter is coming directly from the parsedYAML[PACKS_PROPERTY] property, parsed from the file. This field is optional and hence possibly undefined.

RA80533 Jun 8, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh, there's a conditional block right above that call site that it should be brought up inside.

const packs = parsePacks(parsedYAML[PACKS_PROPERTY], languages, configFile);

Comment thread src/config-utils.ts
Comment thread src/config-utils.ts
Comment thread src/config-utils.ts
aeisenberg force-pushed the aeisenberg/pack-run branch from 0aac515 to 2df7bd0 Compare June 6, 2021 16:04
aeisenberg force-pushed the aeisenberg/pack-run branch from 2df7bd0 to d87945e Compare June 6, 2021 16:28
1. Better malformed data guard for PackDownloadOutput
2. Fix Packs type
3. Remove TODO in init-action
aeisenberg force-pushed the aeisenberg/pack-run branch 4 times, most recently from 045cb83 to f612b8c Compare June 8, 2021 18:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL