Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow local instead of downloaded CodeQL #606

Merged
merged 3 commits into from
Jun 28, 2021

Conversation

edoardopirovano
Copy link
Contributor

@edoardopirovano edoardopirovano commented Jun 28, 2021

Closes #154

This PR allows the tools: argument to accept an argument to specify a local CodeQL distribution instead of a remote one. This will be used internally for testing CodeQL distributions for compatibility with the Action. I do not think we need a changelog entry for this as it is not something users should be using.

Reviewing note: This PR changed the indentation of a lot of a function that ended up inside of an else. Thus, the diff should be viewed with whitespace changes off for improved readability.

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.

@edoardopirovano edoardopirovano requested a review from a team as a code owner June 28, 2021 17:12
src/codeql.ts Outdated
}
let codeqlFolder: string;
let codeqlURLVersion: string;
if (codeqlURL?.startsWith("file://")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We parse this in other code paths as a URL object. Would that make sense to do here? Then you can check the scheme is file and use the URL path to find the file, instead of string manipulation.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to try to parse as a URL first, I think. file:// is not technically correct (even though it is usually accepted). file:/ and file:/// is a correct file url. But, these details could be ignored by usng new URL(codeqlURL).protocol or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, maybe let's go with @aeisenberg's suggestion below of not using file:// URLs in the first place.

src/codeql.ts Outdated
}
let codeqlFolder: string;
let codeqlURLVersion: string;
if (codeqlURL?.startsWith("file://")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to try to parse as a URL first, I think. file:// is not technically correct (even though it is usually accepted). file:/ and file:/// is a correct file url. But, these details could be ignored by usng new URL(codeqlURL).protocol or something like that.

tempDir,
logger
);
codeqlURLVersion = "local";
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know if we need to, but we could get the codeql version by runnng codeql --version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can tell, the only use of this version number is that it goes in the status report and I think from the point of view of status reports, knowing that people are pinned to a local version of the CLI is probably more useful than having the exact version they happen to be on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense.

src/codeql.ts Outdated
let codeqlURLVersion: string;
const parsedUrl: URL | undefined =
codeqlURL && codeqlURL !== "latest" ? new URL(codeqlURL) : undefined;
if (parsedUrl?.protocol === "file:") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if it would be better to just use a raw path to indicate a local file, rather than a file: url. Technically, relative file uris are not legal, so this: file://../action/codeql-bundle.tar.gz is invalid.

It's easy enough to distinguish a file path from an http(s) url (except for the degenerate case where someone has named a file https://thisisafile, which I don't think we need to handle). And doing it this way will be easier might be easier for users since they don't need to remember to use a file: protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it seems reasonable to treat everything that doesn't look like a http(s) URL as a file path, let's do that.

@edoardopirovano edoardopirovano merged commit c357ca7 into github:main Jun 28, 2021
@edoardopirovano edoardopirovano deleted the local-bundle branch June 28, 2021 23:13
@github-actions github-actions bot mentioned this pull request Jul 5, 2021
5 tasks
@github-actions github-actions bot mentioned this pull request Jul 12, 2021
5 tasks
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.

Support for locally present bundles
3 participants