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

Add support for diff-informed queries by cklin · Pull Request #2559 · github/codeql-action · GitHub

Add support for diff-informed queries - #2559

Merged
cklin merged 7 commits into
mainfrom
cklin/diff-range-filtering
Oct 31, 2024
Merged

cklin merged 7 commits into
mainfrom
cklin/diff-range-filtering

Conversation

cklin commented Oct 21, 2024

Copy link
Copy Markdown
Contributor

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.

cklin marked this pull request as ready for review October 22, 2024 15:43
cklin requested a review from a team as a code owner October 22, 2024 15:43
cklin requested a review from henrymercer October 22, 2024 15:43

henrymercer 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

Thanks! I have a bunch of comments and questions — feel free to only address the ones that make sense.

Comment thread src/actions-util.ts
Comment on lines +165 to +171
/**
* Deepen the git history of the given ref by one level. Errors are ignored.
*/
export const deepenGitHistory = async function () {

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

Two comments about the additions to this file in general:

  • Why completely ignore errors? Does it make sense to at least debug log them?
  • Nit, optional: This PR adds a bunch of functionality that interacts with git — now might be a good time to pull this functionality out into its own file.

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

The error is indeed logged centrally within runGitCommand(). By "Errors are ignored", I was trying to convey that errors are not reported back to the caller. I have update the function documentation to clarify the behavior.

Moving the git interactions to its own file sounds like a good idea, though trying to incorporate that into this PR is a bit messy. Can I defer that to a dedicated PR after this one merges?

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

Yes, that's fine!

Comment thread src/actions-util.ts
Comment thread src/actions-util.ts
Comment thread src/analyze-action.ts Outdated
Comment thread src/analyze.ts
Comment thread src/analyze.ts
Comment thread src/analyze.ts
const results = new Array<[string, number, number]>();

let changedFile = "";
for (const line of diffHunkHeaders) {

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

In general this seems to keep going when it sees certain kinds of unexpected items in the diff. It seems that there's a risk of missing changed files — should we be more robust here, or fail more eagerly, or is that not important for now?

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

Can you tell me more about the risk you see, and how the code can be made more robust?

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

Here are some examples where we seem to find unexpected items in the diff:

  • // Not an actual file path; probably /dev/null
  • Failed to parse diff hunk header line: ${line}. Skipping.

In these cases we seem to be encountering something unexpected, but we log or ignore the error and carry on. My question is could these cases where the diff isn't quite as we expect cause us to miss some files that have been changed by the PR, and therefore cause us to miss alerts? If so, we'd probably want to return undefined and fall back to a full analysis.

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

That is a great observation. Thank you! I have updated the PR accordingly.

Comment thread src/actions-util.ts
Comment thread src/analyze.ts Outdated
Comment thread src/analyze.ts Outdated
cklin force-pushed the cklin/diff-range-filtering branch from d757098 to 38487cd Compare October 23, 2024 21:48

cklin commented Oct 24, 2024

Copy link
Copy Markdown
Contributor Author

Thanks! I have a bunch of comments and questions — feel free to only address the ones that make sense.

Thanks for the detailed comments and helpful suggestions! PTAL.

cklin requested a review from henrymercer October 24, 2024 14:00
henrymercer previously approved these changes Oct 28, 2024

henrymercer 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

There's one remaining thread here, but otherwise LGTM!

cklin commented Oct 29, 2024

Copy link
Copy Markdown
Contributor Author

There's one remaining thread here, but otherwise LGTM!

I updated the PR, which implements your suggestion and also fixes a minor bug in the handling of deletion hunks (where git reports the insertion line range as 0). See diff for the latest force-push for details.

cklin requested a review from henrymercer October 29, 2024 14:09
henrymercer previously approved these changes Oct 31, 2024

henrymercer 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

Thanks @cklin!

cklin merged commit 48c3e26 into main Oct 31, 2024
cklin deleted the cklin/diff-range-filtering branch October 31, 2024 13:47
cklin mentioned this pull request Dec 9, 2024
3 tasks
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.

3 participants


Back | FazBrowse Home | New Git URL