GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Upload per-database diagnostic SARIFs on green and red runs by angelapwen · Pull Request #1556 · github/codeql-action

Conversation

@angelapwen

@angelapwen angelapwen commented Mar 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

On failed runs we now call codeql database diagnostic-export to create and upload a SARIF file for per-database diagnostics. If this file was not created, we fall back on the original behavior of uploading the result of codeql export diagnostics.

On successful runs, we add the --sarif-include-diagnostics option to the codeql database interpret-results command.

Both the addition of the option to the interpret-results call, and the codeql database diagnostic-export call, are gated behind the ExportDiagnosticsEnabled feature flag.

We test the green run scenario with an integration test that adds a diagnostic prior to the analyze step, with the feature flag environment variable override to enable the feature. We check the SARIF file generated to make sure it includes the manually added diagnostic.

[GitHub internal only]: we test the red run scenario by writing a similar workflow as the one in the integration test, but failing the workflow after adding the diagnostic. See run and corresponding tool status page for the surfaced diagnostic.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
angelapwen added 4 commits March 2, 2023 17:53
@angelapwen
Refactor golang autobuild env variable
5d87d01
Move the definition of the variable from util to shared-environment, and rename.
@angelapwen
Add database diagnostic command, cluster env var
6b27d47
Adds `codeql database export-diagnostics` command and `CODEQL_ACTION_IS_DATABASE_CLUSTER` internal environment variable
@angelapwen
Upload per-database failed SARIFs, if applicable
0277876
@angelapwen
Add autogenerated files
b780f5b
angelapwen
angelapwen commented Mar 3, 2023
View reviewed changes
Comment thread src/init-action-post-helper.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@angelapwen
angelapwen requested a review from henrymercer March 3, 2023 02:03
henrymercer
henrymercer reviewed Mar 3, 2023
View reviewed changes

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In the green runs path, we call codeql database interpret-results once per database to produce a SARIF file per DB, combine all these SARIF files together, and then submit a single SARIF file. This has different behaviour to uploading each SARIF file separately, since code scanning will overwrite the existing data for that category each time you upload a new SARIF file.

I think for red runs we can do something simpler — config.dbLocation should always be a DB cluster (at least for all CodeQL versions that support diagnostics). Therefore we should be able to run codeql database export-diagnostics once on that DB cluster and submit the resulting SARIF file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

angelapwen reacted with eyes emoji
All reactions
  • 👀 1 reaction
@angelapwen
Add database export-diagnostics command
1d4190a
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from e3b8c1f to 1d4190a Compare March 3, 2023 19:48
@angelapwen

angelapwen commented Mar 3, 2023

Copy link
Copy Markdown
Contributor Author

Unrelated CI failures that I'll fix in a separate PR!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

henrymercer
henrymercer reviewed Mar 6, 2023
View reviewed changes

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looking good so far. An integration test might be tricky to write due to most of the work happening in post-init. We could work around that by creating a separate Action for the test (like we did for the query filters tests), but I'd be happy to merge this with detailed unit tests instead.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/init-action-post-helper.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/init-action-post-helper.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/codeql.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

angelapwen added 4 commits March 8, 2023 13:02
@angelapwen
Call export diagnostics if there is no database
e6c90ea
@angelapwen
Add new export_diagnostics feature flag
1f1b68b
@angelapwen
Pass "--sarif-include-diagnostics" when feature flag on
3200bf1
@angelapwen
Resolve merge conflicts
1e4efb1
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from bb15428 to 1e4efb1 Compare March 13, 2023 22:54
@angelapwen
Remove --sarif-include-diagnostics from diagnotics export
ec89543
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from 0a196c3 to e5a000f Compare March 13, 2023 23:39
@angelapwen
Fix export-diagnostics call
6cce51b
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from e5a000f to 6cce51b Compare March 13, 2023 23:45
@angelapwen
angelapwen marked this pull request as ready for review March 14, 2023 00:00
@angelapwen
angelapwen requested a review from a team as a code owner March 14, 2023 00:00
@angelapwen angelapwen changed the title [WIP] Upload per-database diagnostic SARIFs on failed runs Upload per-database diagnostic SARIFs on failed runs Mar 14, 2023
@angelapwen

angelapwen commented Mar 14, 2023

Copy link
Copy Markdown
Contributor Author

I've addressed the existing comments other than testing. I need to update some of the existing unit tests to reflect the new behavior, as well as write new ones to confirm that the appropriate export command is called as expected ✍️

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

angelapwen added 2 commits March 14, 2023 15:38
@angelapwen
Improve unit tests
ed73efb
@angelapwen
Merge remote-tracking branch 'upstream/main' into failed-database-dia…
c193f61
…gnostic
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from 090a18c to c193f61 Compare March 15, 2023 16:11
henrymercer
henrymercer reviewed Mar 15, 2023
View reviewed changes
Comment thread src/init-action-post-helper.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@angelapwen
Gate database export-diagnostics behind feature flag
30ddec6
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from d3e5288 to b025421 Compare March 15, 2023 23:33
@angelapwen
angelapwen dismissed stale reviews from ghost via 3f5acf0 March 17, 2023 21:36
@angelapwen
Check SARIF in test for expected properties
18c0c1a
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from 3f5acf0 to 18c0c1a Compare March 17, 2023 21:52
@angelapwen angelapwen changed the title Upload per-database diagnostic SARIFs on failed runs Upload per-database diagnostic SARIFs on green and red runs Mar 17, 2023
@angelapwen
Rename test for consistency, stop db upload
817a0e5
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from 016ce45 to 817a0e5 Compare March 18, 2023 00:19
@angelapwen
Comment/import cleanup
cb3dd65
@angelapwen
angelapwen requested a review from henrymercer March 18, 2023 00:28
henrymercer
henrymercer previously approved these changes Mar 20, 2023
View reviewed changes

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nice!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pr-checks/checks/config-export.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/diagnostics-export.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/diagnostics-export.yml Outdated
Comment on lines +41 to +44
const diagnosticToolExecutionNotification = toolExecutionNotifications[toolExecutionNotifications.length - 1];
if (diagnosticToolExecutionNotification.descriptor.id !== 'lang/diagnostics/example' || diagnosticToolExecutionNotification.message.text !== 'Plaintext message') {
core.setFailed('`toolExecutionNotification` related to this diagnostic was not found in SARIF');
}

@henrymercer henrymercer Mar 20, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this will work with the current implementation, but we probably don't want to rely on the ordering of the SARIF file in general. Could we convert this to instead check inclusion?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

angelapwen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@angelapwen angelapwen Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yep! Done. Not sure if there's a cleaner way to check for inclusion (maybe if I used a filter and checked if there were any elements left afterwards..?)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Mar 20, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Filtering might be slightly neater. You could then also check we have exactly one diagnostic with that ID.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@angelapwen angelapwen Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ah, that's a benefit — done!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pr-checks/checks/diagnostics-export.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/diagnostics-export.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/init-action-post-helper.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/init-action-post-helper.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/init-action-post-helper.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/codeql.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

angelapwen added 3 commits March 20, 2023 12:12
@angelapwen
Test nightly-latest for diagnostics, config export
6ea3eb9
@angelapwen
Stop relying on SARIF ordering
9e6750d
@angelapwen
Print database diagnostics args if unit test fails
1954584
@angelapwen
angelapwen dismissed stale reviews from ghost and henrymercer via 1954584 March 20, 2023 19:26
angelapwen and others added 2 commits March 20, 2023 12:29
@angelapwen @henrymercer
Apply suggestions from code review
9116cc1
Co-authored-by: Henry Mercer <[email protected]>
@angelapwen
Add JSDoc comment
0271b54
@angelapwen
angelapwen force-pushed the failed-database-diagnostic branch from 92c75df to 0271b54 Compare March 20, 2023 19:33
@angelapwen
Improve failure message, some autogenerated fixes
3465159
@angelapwen
angelapwen requested a review from henrymercer March 20, 2023 19:37
henrymercer
henrymercer previously approved these changes Mar 20, 2023
View reviewed changes

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd recommend using some functional list methods to simplify the tests, otherwise LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

angelapwen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@angelapwen
Refactor inclusion check
e7e7280
@angelapwen
angelapwen dismissed henrymercer’s stale review via e7e7280 March 20, 2023 20:11
@angelapwen
angelapwen requested a review from henrymercer March 20, 2023 20:12
henrymercer
henrymercer approved these changes Mar 20, 2023
View reviewed changes
@angelapwen
angelapwen enabled auto-merge (squash) March 20, 2023 20:23
@angelapwen
angelapwen merged commit 3cbd063 into github:main Mar 20, 2023
@angelapwen
angelapwen deleted the failed-database-diagnostic branch March 21, 2023 18:12
@github-actions github-actions Bot mentioned this pull request Mar 22, 2023
Merge main into releases/v2 #1601
Merged
4 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@henrymercer henrymercer henrymercer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@angelapwen @henrymercer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.